Author: yradtsevich
Date: 2009-08-14 09:54:07 -0400 (Fri, 14 Aug 2009)
New Revision: 17083
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3888/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3888/JBIDE-3888.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuDoubleInsertionTest_JBIDE3888.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuTestAbstract.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
Log:
issue JBIDE-3888: Taglib declaration for empty page doesn't appear correctly from
context menu.
https://jira.jboss.org/jira/browse/JBIDE-3888
- The issue has been fixed.
- JUnit test for the issue has been created.
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3888/JBIDE-3888.jsp
===================================================================
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 2009-08-14
13:48:33 UTC (rev 17082)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -16,6 +16,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.ContextMenuDoubleInsertionTest_JBIDE3888;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1105Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1460Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE1479Test;
@@ -98,6 +99,7 @@
suite.addTestSuite(JsfComponentTest.class);
suite.addTestSuite(Jsf20ComponentContentTest.class);
suite.addTestSuite(JBIDE3519Test.class);
+ suite.addTestSuite(ContextMenuDoubleInsertionTest_JBIDE3888.class);
suite.addTestSuite(JBIDE4037Test.class);
suite.addTestSuite(JBIDE3734Test.class);
suite.addTestSuite(JBIDE3617Test.class);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuDoubleInsertionTest_JBIDE3888.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuDoubleInsertionTest_JBIDE3888.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuDoubleInsertionTest_JBIDE3888.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jboss.tools.vpe.editor.menu.InsertType;
+import org.jboss.tools.vpe.editor.menu.action.InsertAction2;
+
+
+/**
+ * Tests for JIRA issue JBIDE-3888: Taglib declaration for empty page
+ * doesn't appear correctly from context menu.
+ * (
https://jira.jboss.org/jira/browse/JBIDE-3519 )
+ *
+ * @author yradtsevich
+ */
+public class ContextMenuDoubleInsertionTest_JBIDE3888
+ extends ContextMenuTestAbstract {
+ private static final String TEST_PAGE_NAME
+ = "JBIDE/3888/JBIDE-3888.jsp"; //$NON-NLS-1$
+ private static final String INSERTION_ITEM_PATH
+ = "%Palette%/JSF/HTML/column"; //$NON-NLS-1$
+ private static final String REQUIRED_STRING
+ = "http://java.sun.com/jsf/html"; //$NON-NLS-1$
+
+ public ContextMenuDoubleInsertionTest_JBIDE3888(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /**
+ * Tests JBIDE-3888.
+ * <P>
+ * This method implements the following test case:
+ * <ol>
+ * <li>Open a blank JSP page.</li>
+ * <li>Open the context menu
+ * and select Insert Into->JSF->HTML->h:column</li>
+ * <li>Delete all text.</li>
+ * <li>Open the context menu
+ * and select Insert Into->JSF->HTML->h:column</li>
+ * </ol>
+ * EXPECTED RESULT: A taglib declaration
http://java.sun.com/jsf/html
+ * and a pair of opening/closing h:column tag is inserted.<BR>
+ * ACTUAL RESULT (if the test fails):
+ * The taglib declaration is not inserted.
+ */
+ public void testDoubleInsertion() {
+ final InsertAction2 firstInsertAction = new InsertAction2(
+ "Insert Action", insertionItem, //$NON-NLS-1$
+ sourceEditor, InsertType.INSERT_INTO);
+ firstInsertAction.run();
+ textWidget.setText("");
+ final InsertAction2 secondInsertAction = new InsertAction2(
+ "Insert Action", insertionItem, //$NON-NLS-1$
+ sourceEditor, InsertType.INSERT_INTO);
+ secondInsertAction.run();
+ assertTrue(textWidget.getText()
+ .contains(REQUIRED_STRING));
+ }
+
+ @Override
+ protected String getInsertionItemPath() {
+ return INSERTION_ITEM_PATH;
+ }
+
+ @Override
+ protected String getTestPagePath() {
+ return TEST_PAGE_NAME;
+ }
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuTestAbstract.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuTestAbstract.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/ContextMenuTestAbstract.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.jface.text.IUndoManager;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.util.ModelUtilities;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+/**
+ * @author yradtsevich
+ *
+ */
+public abstract class ContextMenuTestAbstract extends VpeTest {
+ protected VpeController vpeController;
+ protected StructuredTextEditor sourceEditor;
+ protected StructuredTextViewer textViewer;
+ protected StyledText textWidget;
+ protected IUndoManager undoManager;
+ protected XModelObject insertionItem;
+
+ public ContextMenuTestAbstract(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ vpeController = openInVpe(JsfAllTests.IMPORT_PROJECT_NAME,
+ getTestPagePath());
+ sourceEditor = vpeController.getSourceEditor();
+ textViewer = sourceEditor.getTextViewer();
+ textWidget = textViewer.getTextWidget();
+ undoManager = textViewer.getUndoManager();
+ insertionItem = ModelUtilities.getPreferenceModel()
+ .getByPath(getInsertionItemPath());
+ }
+
+ protected abstract String getTestPagePath();
+ protected abstract String getInsertionItemPath();
+}
Deleted:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java 2009-08-14
13:48:33 UTC (rev 17082)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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.jface.text.IUndoManager;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.ui.util.ModelUtilities;
-import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
-import org.jboss.tools.vpe.editor.VpeController;
-import org.jboss.tools.vpe.editor.menu.InsertType;
-import org.jboss.tools.vpe.editor.menu.action.InsertAction2;
-import org.jboss.tools.vpe.ui.test.TestUtil;
-import org.jboss.tools.vpe.ui.test.VpeTest;
-
-/**
- * Test for JIRA issue JBIDE-3519: Ctrl+Z (Undo) doesn't work
- * properly for "Replace With" operation from context menu.
- * (
https://jira.jboss.org/jira/browse/JBIDE-3519 )
- *
- * @author yradtsevich
- */
-public class JBIDE3519Test extends VpeTest {
- private static final Point SELECTION_START = new Point(5, 9);
- private static final Point SELECTION_END = new Point(7, 23);
- private static final String TEST_PAGE_NAME
- = "JBIDE/3519/JBIDE-3519.xhtml"; //$NON-NLS-1$
- private static final String INSERTION_ITEM_PATH
- = "%Palette%/JSF/HTML/column"; //$NON-NLS-1$
-
- private VpeController vpeController;
- private StructuredTextEditor sourceEditor;
- private StructuredTextViewer textViewer;
- private StyledText textWidget;
- private String originalText;
- private IUndoManager undoManager;
- private int selectionStartOffset;
- private int selectionEndOffset;
- private XModelObject insertionItem;
-
- public JBIDE3519Test(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- vpeController = openInVpe(JsfAllTests.IMPORT_PROJECT_NAME,
- TEST_PAGE_NAME);
- sourceEditor = vpeController.getSourceEditor();
- textViewer = sourceEditor.getTextViewer();
- textWidget = textViewer.getTextWidget();
- originalText = textWidget.getText();
-
- undoManager = textViewer.getUndoManager();
-
- selectionStartOffset = TestUtil.getLinePositionOffcet(
- textViewer, SELECTION_START.x, SELECTION_START.y);
- selectionEndOffset = TestUtil.getLinePositionOffcet(
- textViewer, SELECTION_END.x, SELECTION_END.y);
-
- insertionItem = ModelUtilities.getPreferenceModel()
- .getByPath(INSERTION_ITEM_PATH);
- }
-
-// known issue, will fail
-// public void testInsertAround() {
-// insertAndUndo(InsertType.INSERT_AROUND);
-// }
-
- public void testInsertAfter() {
- insertAndUndo(InsertType.INSERT_AFTER);
- }
-
- public void testInsertBefore() {
- insertAndUndo(InsertType.INSERT_BEFORE);
- }
-
- public void testInsertInto() {
- insertAndUndo(InsertType.INSERT_INTO);
- }
-
- public void testReplaceWith() throws Throwable {
- insertAndUndo(InsertType.REPLACE_WITH);
- }
-
- private void insertAndUndo(final InsertType insertType) {
- textWidget.setSelection(selectionStartOffset, selectionEndOffset);
- final InsertAction2 insertAction = new InsertAction2(
- "Insert Action", insertionItem, //$NON-NLS-1$
- sourceEditor, insertType);
- insertAction.run();
- undoManager.undo();
- assertEquals(insertType.getMessage()
- + " action has been performed. The content is "//$NON-NLS-1$
- + " not reverted after UNDO operation.", //$NON-NLS-1$
- originalText, textWidget.getText());
- }
-}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3519Test.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.swt.graphics.Point;
+import org.jboss.tools.vpe.editor.menu.InsertType;
+import org.jboss.tools.vpe.editor.menu.action.InsertAction2;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+
+/**
+ * Tests for JIRA issue JBIDE-3519: Ctrl+Z (Undo) doesn't work
+ * properly for "Replace With" operation from context menu.
+ * (
https://jira.jboss.org/jira/browse/JBIDE-3519 )
+ *
+ * @author yradtsevich
+ */
+public class JBIDE3519Test extends ContextMenuTestAbstract {
+ private static final Point SELECTION_START = new Point(5, 9);
+ private static final Point SELECTION_END = new Point(7, 23);
+ private static final String TEST_PAGE_NAME
+ = "JBIDE/3519/JBIDE-3519.xhtml"; //$NON-NLS-1$
+ private static final String INSERTION_ITEM_PATH
+ = "%Palette%/JSF/HTML/column"; //$NON-NLS-1$
+
+ private String originalText;
+ private int selectionStartOffset;
+ private int selectionEndOffset;
+
+ public JBIDE3519Test(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ originalText = textWidget.getText();
+ selectionStartOffset = TestUtil.getLinePositionOffcet(
+ textViewer, SELECTION_START.x, SELECTION_START.y);
+ selectionEndOffset = TestUtil.getLinePositionOffcet(
+ textViewer, SELECTION_END.x, SELECTION_END.y);
+ }
+
+// known issue, will fail
+// public void testInsertAround() {
+// insertAndUndo(InsertType.INSERT_AROUND);
+// }
+
+ public void testInsertAfter() {
+ insertAndUndo(InsertType.INSERT_AFTER);
+ }
+
+ public void testInsertBefore() {
+ insertAndUndo(InsertType.INSERT_BEFORE);
+ }
+
+ public void testInsertInto() {
+ insertAndUndo(InsertType.INSERT_INTO);
+ }
+
+ public void testReplaceWith() throws Throwable {
+ insertAndUndo(InsertType.REPLACE_WITH);
+ }
+
+ private void insertAndUndo(final InsertType insertType) {
+ textWidget.setSelection(selectionStartOffset, selectionEndOffset);
+ final InsertAction2 insertAction = new InsertAction2(
+ "Insert Action", insertionItem, //$NON-NLS-1$
+ sourceEditor, insertType);
+ insertAction.run();
+ undoManager.undo();
+ assertEquals(insertType.getMessage()
+ + " action has been performed. The content is "//$NON-NLS-1$
+ + " not reverted after UNDO operation.", //$NON-NLS-1$
+ originalText, textWidget.getText());
+ }
+
+ @Override
+ protected String getTestPagePath() {
+ return TEST_PAGE_NAME;
+ }
+
+ @Override
+ protected String getInsertionItemPath() {
+ return INSERTION_ITEM_PATH;
+ }
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2009-08-14
13:48:33 UTC (rev 17082)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2009-08-14
13:54:07 UTC (rev 17083)
@@ -87,13 +87,14 @@
referenceNode = null; //TODO study when we really need refresh
setReferenceNode(refNode);
} else {
+ //if we on jsp page we will set taglibs
+ //TODO Max Areshkau Find other possibility to check if we on jsp page
List<TaglibData> taglibs = getIncludeTaglibs();
- //if we on jsp page we will set taglibs
- //TODO Max Areshkau Find other possibility to check if we on jsp page
- // FIX FOR
https://jira.jboss.org/jira/browse/JBIDE-3888
- // in some cases list of taglibs is not refreshed
-// if(taglibs != null /*&& taglibs.size()>0*/) {
- if(taglibs != null && taglibs.size()>0) {
+
+ // FIX FOR
https://jira.jboss.org/jira/browse/JBIDE-3888
+ // in some cases list of taglibs is not refreshed
+ // if(taglibs != null && taglibs.size()>0) {
+ if(taglibs != null) {
setTaglibs(taglibs);
}
}