Author: scabanovich
Date: 2011-05-04 19:27:11 -0400 (Wed, 04 May 2011)
New Revision: 31076
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/WEB-INF/myLibrary.tld
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/tldTagsHyperlinkTests.jsp
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java
Log:
JBIDE-8845
https://issues.jboss.org/browse/JBIDE-8845
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/WEB-INF/myLibrary.tld
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/WEB-INF/myLibrary.tld
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/WEB-INF/myLibrary.tld 2011-05-04
23:27:11 UTC (rev 31076)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<taglib version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
+ <tlib-version>1.0</tlib-version>
+ <short-name>myLibrary</short-name>
+ <uri>myLibrary</uri>
+ <tag>
+ <name>myTag</name>
+ <tag-class>String</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>myattr</name>
+ <rtexprvalue>false</rtexprvalue>
+ <type>String</type>
+ </attribute>
+ </tag>
+</taglib>
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/WEB-INF/myLibrary.tld
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/tldTagsHyperlinkTests.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/tldTagsHyperlinkTests.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/tldTagsHyperlinkTests.jsp 2011-05-04
23:27:11 UTC (rev 31076)
@@ -0,0 +1,19 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="myLibrary" prefix="m"%>
+
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<f:view>
+ <h:form>
+ <h:outputText value="#{bean1.property3.property1}" />
+ <h:commandButton action="page2" value="Go to page2" />
+ <h:commandButton action="page3" value="Go to page3" />
+ <m:myTag myattr=""/>
+ </h:form>
+</f:view>
+</body>
+</html>
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/HiperlinksTestProject/WebContent/tldTagsHyperlinkTests.jsp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java 2011-05-04
23:26:11 UTC (rev 31075)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/OpenOnsTest.java 2011-05-04
23:27:11 UTC (rev 31076)
@@ -20,6 +20,7 @@
import org.jboss.tools.common.model.ui.editors.multipage.DefaultMultipageEditor;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
import org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPTagNameHyperlinkDetector;
+import org.jboss.tools.jsf.text.ext.hyperlink.TLDTagHyperlink;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.WorkbenchUtils;
@@ -571,4 +572,120 @@
String fileName = editor.getEditorInput().getName();
assertTrue("style1.css".equals(fileName));
}
+
+ public static final String TAGLIB_TAGS_TEST_FILE = OPENON_TEST_PROJECT +
"/WebContent/tldTagsHyperlinkTests.jsp";
+
+ public void testTaglibAttributeFromJarOpenOn() throws BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(TAGLIB_TAGS_TEST_FILE);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+ IDocument document =
jspMultyPageEditor.getSourceEditor().getTextViewer().getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ "value", true, true, false, false);
+ IHyperlink[] links = new JsfJSPTagNameHyperlinkDetector().detectHyperlinks(viewer, reg,
true);
+ assertNotNull(links);
+ assertTrue(links.length!=0);
+ //assertNotNull(links[0].getHyperlinkText());
+ assertNotNull(links[0].toString());
+ links[0].open();
+ JobUtils.waitForIdle();
+
+ editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+
+ String fileName = editor.getEditorInput().getName();
+ assertTrue("html_basic.tld".equals(fileName));
+
+ assertModelObjectSelection(links[0], "value");
+ }
+
+ public void testTaglibTagsFromJarOpenOn() throws BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(TAGLIB_TAGS_TEST_FILE);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+ IDocument document =
jspMultyPageEditor.getSourceEditor().getTextViewer().getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ "h:outputText", true, true, false, false);
+ IHyperlink[] links = new JsfJSPTagNameHyperlinkDetector().detectHyperlinks(viewer, reg,
true);
+ assertNotNull(links);
+ assertTrue(links.length!=0);
+ //assertNotNull(links[0].getHyperlinkText());
+ assertNotNull(links[0].toString());
+ links[0].open();
+ JobUtils.waitForIdle();
+
+ editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+
+ String fileName = editor.getEditorInput().getName();
+ assertTrue("html_basic.tld".equals(fileName));
+
+ try {
+ assertModelObjectSelection(links[0], "outputText");
+ } finally {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor,
false);
+ }
+ }
+
+ public void testTaglibTagsInWebInfOpenOn() throws BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(TAGLIB_TAGS_TEST_FILE);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+ IDocument document =
jspMultyPageEditor.getSourceEditor().getTextViewer().getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ "m:myTag", true, true, false, false);
+ IHyperlink[] links = new JsfJSPTagNameHyperlinkDetector().detectHyperlinks(viewer, reg,
true);
+ assertNotNull(links);
+ assertTrue(links.length!=0);
+ //assertNotNull(links[0].getHyperlinkText());
+ assertNotNull(links[0].toString());
+ links[0].open();
+ JobUtils.waitForIdle();
+
+ editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+
+ String fileName = editor.getEditorInput().getName();
+ assertTrue("myLibrary.tld".equals(fileName));
+
+ assertModelObjectSelection(links[0], "myTag");
+ }
+
+ public void testTaglibAttributeInWebInfOpenOn() throws BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(TAGLIB_TAGS_TEST_FILE);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+ IDocument document =
jspMultyPageEditor.getSourceEditor().getTextViewer().getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ "myattr", true, true, false, false);
+ IHyperlink[] links = new JsfJSPTagNameHyperlinkDetector().detectHyperlinks(viewer, reg,
true);
+ assertNotNull(links);
+ assertTrue(links.length!=0);
+ //assertNotNull(links[0].getHyperlinkText());
+ assertNotNull(links[0].toString());
+ links[0].open();
+ JobUtils.waitForIdle();
+
+ editor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+
+ String fileName = editor.getEditorInput().getName();
+ assertTrue("myLibrary.tld".equals(fileName));
+
+ assertModelObjectSelection(links[0], "myattr");
+ }
+
+ void assertModelObjectSelection(IHyperlink link, String name) {
+ assertTrue(link instanceof TLDTagHyperlink);
+ TLDTagHyperlink tagLink = (TLDTagHyperlink)link;
+ String objectName = tagLink.getObjectName();
+ int i = objectName.lastIndexOf(":");
+ if(i > 0) objectName = objectName.substring(i + 1).trim();
+ assertEquals(name, objectName);
+ }
+
}