Author: yradtsevich
Date: 2009-01-29 06:43:24 -0500 (Thu, 29 Jan 2009)
New Revision: 13316
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.css
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3617Test.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/util/VpeStyleUtil.java
Log:
RESOLVED - issue JBIDE-3617: Exception is appeared if .css file has " #url "
style class
https://jira.jboss.org/jira/browse/JBIDE-3617
- the patch from the JIRA-attachment of the issue has been applied
- JUnit test has been written
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.css
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.css
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.css 2009-01-29
11:43:24 UTC (rev 13316)
@@ -0,0 +1,4 @@
+#url {
+ color: blue;
+ text-decoration: underline;
+}
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3617/JBIDE-3617.jsp 2009-01-29
11:43:24 UTC (rev 13316)
@@ -0,0 +1,12 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<html>
+ <head>
+
+ </head>
+ <body>
+ <f:view>
+ <span id="url">ddddd</span>
+ </f:view>
+ </body>
+</html>
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-01-29
04:00:14 UTC (rev 13315)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-01-29
11:43:24 UTC (rev 13316)
@@ -49,6 +49,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3441Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3473Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3482Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3617Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3632Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
@@ -80,6 +81,7 @@
// $JUnit-BEGIN$
suite.addTestSuite(JsfComponentTest.class);
suite.addTestSuite(Jsf20ComponentContentTest.class);
+ suite.addTestSuite(JBIDE3617Test.class);
suite.addTestSuite(JBIDE3473Test.class);
suite.addTestSuite(JBIDE3441Test.class);
suite.addTestSuite(JsfJbide1467Test.class);
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3617Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3617Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3617Test.java 2009-01-29
11:43:24 UTC (rev 13316)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+* 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.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+
+/**
+ * Test case for issue <a
href='https://jira.jboss.org/jira/browse/JBIDE-3617'>JBIDE-361...;:
+ * Exception is appeared if .css file has " #url " style class
+ *
+ *
+ * @author yradtsevich
+ */
+public class JBIDE3617Test extends VpeTest {
+
+ private static final String TEST_FILE_NAME = "JBIDE/3617/JBIDE-3617.jsp";
//$NON-NLS-1$
+ private static final String INSERTED_STRING = "<link
rel=\"stylesheet\" type=\"text/css\" media=\"print\"
href=\"JBIDE-3617.css\">"; //$NON-NLS-1$
+ private static final Point INSERTION_POINT = new Point(5, 9);
+ public JBIDE3617Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests <a
href='https://jira.jboss.org/jira/browse/JBIDE-3617'>JBIDE-361...
+ *
+ * @throws Throwable
+ */
+ public void testJBIDE3617() throws Throwable {
+ // wait
+ TestUtil.waitForJobs();
+
+ setException(null);
+
+ VpeController vpeController = openInVpe(JsfAllTests.IMPORT_PROJECT_NAME,
TEST_FILE_NAME); //$NON-NLS-1$
+
+ StructuredTextViewer textViewer = vpeController.getSourceEditor().getTextViewer();
+
+ int offset = TestUtil.getLinePositionOffcet(textViewer, INSERTION_POINT.x,
INSERTION_POINT.y);
+ // get editor control
+ StyledText styledText = textViewer.getTextWidget();
+
+ styledText.setCaretOffset(offset);
+ styledText.insert(INSERTED_STRING);
+
+ // refresh the view
+ vpeController.visualRefresh();
+ TestUtil.waitForJobs();
+ try {
+ TestUtil.delay(500);
+ } catch (Throwable e) {
+ fail("Seems like JBIDE-3617 has occured.\n" + e);//$NON-NLS-1$
+ }
+
+ if(getException()!=null) {
+ throw getException();
+ }
+ }
+
+ /**
+ * Opens specified file in VPE editor
+ *
+ * @param projectName the name of the project
+ * @param fileName the name of the file
+ *
+ * @return VpeController
+ * @throws Throwable
+ */
+ private VpeController openInVpe(String projectName, String fileName) throws Throwable {
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(fileName,
+ projectName);
+ assertNotNull("Could not open specified file. componentPage = " +
fileName//$NON-NLS-1$
+ + ";projectName = " + projectName, file);//$NON-NLS-1$
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
+
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ VpeController vpeController = TestUtil.getVpeController(part);
+
+ return vpeController;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-29
04:00:14 UTC (rev 13315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-29
11:43:24 UTC (rev 13316)
@@ -360,7 +360,7 @@
int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
startPathIndex + 1);
- if (startPathIndex == -1 || endPathIndex == -1) {
+ if (startPathIndex < 0 || endPathIndex < 0) {
continue;
}
@@ -491,9 +491,14 @@
int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
int endPathIndex = urls[i].indexOf(CLOSE_BRACKET,
startPathIndex + 1);
+
+ if (startPathIndex < 0 || endPathIndex < 0) {
+ continue;
+ }
+
String filePath = urls[i].substring(startPathIndex + 1,
endPathIndex);
-
+
IFile sourceFile = null;
try {
URL url1 = new URL(href_val);