Author: yzhishko
Date: 2010-03-17 06:43:49 -0400 (Wed, 17 Mar 2010)
New Revision: 20870
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VisualRefreshComment_JBIDE6067.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6067 - fixed.
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp 2010-03-17
10:43:49 UTC (rev 20870)
@@ -0,0 +1,27 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<f:loadBundle var="msg" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title> Test h:selectManyListbox in VPE </title>
+ <style type="text/css">
+ .myStyle0 {background: aqua; }
+ .myStyle1 {background: yellow;}
+ .myStyle2 {background: green; font-style: italic;}
+ </style>
+ </head>
+ <body>
+ <f:view>
+ <h:selectManyListbox id="sub1" value="#{user.name}"
+ disabled="false"
+ dir="LTR" size="3"
+ style="color: red; font-size: large;"
+ styleClass="myStyle0"
+ enabledClass="myStyle1" disabledClass="myStyle2" >
+ <!-- --> <f:selectItem id="it1_2" itemLabel="Sports"
itemValue="2" />
+ </h:selectManyListbox>
+ </f:view>
+ </body>
+</html>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/6067/JBIDE-6067.jsp.xml 2010-03-17
10:43:49 UTC (rev 20870)
@@ -0,0 +1,7 @@
+<tests>
+ <test id="sub1">
+ <SELECT CLASS="myStyle0" STYLE="color: red; font-size: large;"
MULTIPLE="multiple" SIZE="3">
+<!-- <f:selectItem id="it1_2" itemLabel="Sports"
itemValue="2" />-->
+</SELECT>
+ </test>
+</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-03-17
04:57:29 UTC (rev 20869)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2010-03-17
10:43:49 UTC (rev 20870)
@@ -97,6 +97,7 @@
import
org.jboss.tools.jsf.vpe.jsf.test.jbide.TestForUsingComponentsLibrariesWithDefaultNamespace;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestOpenOnForXhtmlFiles_JBIDE5577;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.VPERefreshTest;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.VisualRefreshComment_JBIDE6067;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.VpeI18nTest_JBIDE4887;
import org.jboss.tools.vpe.ui.test.VpeTestSetup;
@@ -213,6 +214,7 @@
suite.addTestSuite(FacetProcessingTest.class);
suite.addTestSuite(RefreshBundles_JBIDE5460.class);
suite.addTestSuite(ExceptionInVPEComments_JBIDE5143.class);
+ suite.addTestSuite(VisualRefreshComment_JBIDE6067.class);
// $JUnit-END$
return new VpeTestSetup(suite);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VisualRefreshComment_JBIDE6067.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VisualRefreshComment_JBIDE6067.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/VisualRefreshComment_JBIDE6067.java 2010-03-17
10:43:49 UTC (rev 20870)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditorPart;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+
+/**
+ *
+ * @author yzhishko
+ *
+ */
+
+public class VisualRefreshComment_JBIDE6067 extends VpeTest {
+
+ public VisualRefreshComment_JBIDE6067(String name) {
+ super(name);
+ }
+
+ public void testVisualRefreshComment() throws Throwable{
+ setException(null);
+ IFile file = (IFile) TestUtil.getComponentPath("JBIDE/6067/JBIDE-6067.jsp",
//$NON-NLS-1$
+ JsfAllTests.IMPORT_PROJECT_NAME);
+ IEditorInput editorInput = new FileEditorInput(file);
+ JSPMultiPageEditor part = openEditor(editorInput);
+ TestUtil.delay(3000);
+ TestUtil.waitForIdle();
+ StyledText styledText = part.getSourceEditor().getTextViewer()
+ .getTextWidget();
+ String delimiter = styledText.getLineDelimiter();
+ int offset = styledText.getOffsetAtLine(23);
+ offset = offset - delimiter.length() - "--> <f:selectItem
id=\"it1_2\" itemLabel=\"Sports\" itemValue=\"2\"
/>".length(); //$NON-NLS-1$
+ styledText.setCaretOffset(offset);
+ styledText.setSelection(offset, offset + 3);
+ styledText.insert(""); //$NON-NLS-1$
+ TestUtil.delay(1000);
+ TestUtil.waitForIdle();
+ offset = styledText.getOffsetAtLine(23)-delimiter.length();
+ styledText.setCaretOffset(offset);
+ styledText.insert(">"); //$NON-NLS-1$
+ TestUtil.delay(1000);
+ TestUtil.waitForIdle();
+ styledText.insert("-"); //$NON-NLS-1$
+ TestUtil.delay(1000);
+ TestUtil.waitForIdle();
+ styledText.insert("-"); //$NON-NLS-1$
+ TestUtil.delay(1000);
+ TestUtil.waitForIdle();
+ checkVisualPart(part);
+ }
+
+ private void checkVisualPart (JSPMultiPageEditorPart editorPart){
+ nsIDOMDocument visualDoc =
TestUtil.getVpeVisualDocument((JSPMultiPageEditor)editorPart);
+ nsIDOMNodeList nodeList = visualDoc.getElementsByTagName("SELECT");
//$NON-NLS-1$
+ assertNotNull("There are no SELECT elements in a visual DOM", nodeList);
//$NON-NLS-1$
+ assertTrue("There are no SELECT elements in a visual DOM",
nodeList.getLength() > 0); //$NON-NLS-1$
+ nsIDOMNode commentNode = nodeList.item(0).getChildNodes().item(1);
+ String nodeValue = commentNode.getNodeValue();
+ assertEquals("SELECT element contents incorrect comment node",
nsIDOMNode.COMMENT_NODE, commentNode.getNodeType()); //$NON-NLS-1$
+ assertEquals(" <f:selectItem id=\"it1_2\"
itemLabel=\"Sports\" itemValue=\"2\" />", nodeValue);
//$NON-NLS-1$
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-03-17
04:57:29 UTC (rev 20869)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2010-03-17
10:43:49 UTC (rev 20870)
@@ -197,6 +197,8 @@
private boolean mouseDownSelectionFlag;
private boolean sourceChangeFlag;
private boolean commentNodeChanged;
+ private int commentRemoveCount = 0;
+ private int commentAddCount = 0;
private VpePageContext pageContext;
private BundleMap bundle;
private VpeEditorPart editPart;
@@ -705,6 +707,9 @@
* we should remove all parent nodes from vpe cash
*/
visualBuilder.removeNode((Node) newValue);
+ commentAddCount--;
+ } else if (newValue instanceof Node && Node.COMMENT_NODE == ((Node)
newValue).getNodeType()) {
+ commentAddCount++;
}
break;
@@ -715,9 +720,11 @@
* structure, only the comment node should be updated.
*/
if (Node.COMMENT_NODE == ((Node) feature).getNodeType()) {
+ commentRemoveCount++;
visualBuilder.updateNode((Node) feature);
commentNodeChanged = true;
} else {
+ commentRemoveCount--;
visualBuilder.stopToggle((Node) feature);
visualBuilder.removeNode((Node) feature);
}
@@ -728,13 +735,20 @@
*
https://jira.jboss.org/jira/browse/JBIDE-4102 Do not update
* parent tag when a comment was changed,
*/
- if (!commentNodeChanged) {
+
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-6067 Update if action
+ * is connected with add or remove comment
+ */
+ if (!commentNodeChanged ||(commentNodeChanged && (commentAddCount != 1 ||
commentRemoveCount != 1))) {
visualEditor.hideResizer();
visualBuilder.setSelectionRectangle(null);
visualBuilder.updateNode((Node) notifier);
} else {
commentNodeChanged = false;
}
+ commentAddCount = 0;
+ commentRemoveCount = 0;
break;
case INodeNotifier.CONTENT_CHANGED:
if (!sourceChangeFlag) {