Author: yradtsevich
Date: 2010-01-21 14:39:06 -0500 (Thu, 21 Jan 2010)
New Revision: 19857
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2JSPLinkHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2LinkHyperlink.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5382/OpenOnJsf20.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnJsf20Test_JBIDE5382.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5382
add openOn action for name param for h:outputStylesheet, h:outputScript, h:graphicImage
jsf 2.0 tags
- basic support for the OpenOn action has been added (without support of .jar files and it
does not takes into account the locale)
- JUnit tests have been added
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2010-01-21 17:38:43 UTC (rev
19856)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2010-01-21 19:39:06 UTC (rev
19857)
@@ -403,13 +403,14 @@
</hyperlinkPartitioner>
<hyperlinkPartitioner
-
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JSFJSPLinkHyperlinkPartitioner"
-
class="org.jboss.tools.jsf.text.ext.hyperlink.JSFJSPLinkHyperlinkPartitioner">
+
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JSF2JSPLinkHyperlinkPartitioner"
+
class="org.jboss.tools.jsf.text.ext.hyperlink.JSF2JSPLinkHyperlinkPartitioner">
<contentType id="org.eclipse.jst.jsp.core.jspsource">
<partitionType id="org.jboss.tools.common.text.ext.jsp.JSP_LINK"
/>
<partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
<axis
path="*/[http://java.sun.com/jsf/html]:outputStylesheet/name/" />
<axis
path="*/[http://java.sun.com/jsf/html]:outputScript/name/"
/>
+ <axis
path="*/[http://java.sun.com/jsf/html]:graphicImage/name/"
/>
</partitionType>
</contentType>
<contentType id="org.eclipse.wst.html.core.htmlsource">
@@ -417,6 +418,7 @@
<partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
<axis
path="*/[http://java.sun.com/jsf/html]:outputStylesheet/name/" />
<axis
path="*/[http://java.sun.com/jsf/html]:outputScript/name/"
/>
+ <axis
path="*/[http://java.sun.com/jsf/html]:graphicImage/name/"
/>
</partitionType>
</contentType>
</hyperlinkPartitioner>
@@ -953,6 +955,17 @@
<partitiontype id="org.jboss.tools.common.text.ext.jsp.JSF_JSP_LINK"
/>
</contenttypeidentifier>
</hyperlink>
+
+ <hyperlink
+ class="org.jboss.tools.jsf.text.ext.hyperlink.JSF2LinkHyperlink"
+ id="org.jboss.tools.common.text.ext.jsf.hyperlink.JSF2LinkHyperlink">
+ <contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.jsp.JSF2_JSP_LINK"
/>
+ </contenttypeidentifier>
+ <contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.jsp.JSF2_JSP_LINK"
/>
+ </contenttypeidentifier>
+ </hyperlink>
<hyperlink
class="org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPXmlNsHyperlink"
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2JSPLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2JSPLinkHyperlinkPartitioner.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2JSPLinkHyperlinkPartitioner.java 2010-01-21
19:39:06 UTC (rev 19857)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.text.ext.hyperlink;
+
+/**
+ * Partitioner for the {@code name} attribute of
+ * {@code h:outputStylesheet, h:outputScript, h:graphicImage} tags.
+ *
+ * @see JSF2LinkHyperlink
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBIDE-5382">JBIDE-5...
+ *
+ * @author yradtsevich
+ */
+public class JSF2JSPLinkHyperlinkPartitioner extends JSFJSPLinkHyperlinkPartitioner {
+ public static final String JSF2_JSP_LINK_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSF2_JSP_LINK"; //$NON-NLS-1$
+
+ @Override
+ protected String getPartitionType() {
+ return JSF2_JSP_LINK_PARTITION;
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2LinkHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2LinkHyperlink.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSF2LinkHyperlink.java 2010-01-21
19:39:06 UTC (rev 19857)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.text.ext.hyperlink;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Opens hyperlinks in the following form:
+ * {@code <h:a_jsf_2_tag lib="a_lib_name"
name="SELECTED_HYPERLINK">}.
+ *
+ * @see JSF2JSPLinkHyperlinkPartitioner
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBIDE-5382">JBIDE-5...
+ *
+ * @author yradtsevich
+ */
+public class JSF2LinkHyperlink extends JSFLinkHyperlink {
+ private static final String JSF2_RESOURCES_FOLDER = "/resources";
//$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.text.ext.hyperlink.LinkHyperlink#getFilePath(org.eclipse.jface.text.IRegion)
+ */
+ @Override
+ protected String getFilePath(IRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) {
+ return null;
+ }
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof Attr) ) {
+ return null;
+ }
+
+ Element element = ((Attr)n).getOwnerElement();
+ Attr libraryAttr = element.getAttributeNode("library"); //$NON-NLS-1$
+ String name = getDocument().get(region.getOffset(), region.getLength());
+ if (libraryAttr != null && libraryAttr.getNodeValue() != null) {
+ String library = libraryAttr.getNodeValue().trim();
+ if (library.length() != 0) {
+ return JSF2_RESOURCES_FOLDER + '/' + library + '/' + name;
+ }
+ }
+ return JSF2_RESOURCES_FOLDER + '/' + name;
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
+}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5382/OpenOnJsf20.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5382/OpenOnJsf20.xhtml 2010-01-21
17:38:43 UTC (rev 19856)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5382/OpenOnJsf20.xhtml 2010-01-21
19:39:06 UTC (rev 19857)
@@ -4,9 +4,10 @@
xmlns:h="http://java.sun.com/jsf/html">
<h:head />
<h:body>
- <h:outputScript name="/resources/scripts/f1.js"
id="outputScript1"/>
- <h:outputStylesheet name="/resources/css/stylesRed.css"
id="outputStylesheet1"/>
- <h:outputStylesheet name="/resources/css/stylesBlue.css"
id="outputStylesheetBlue"/>
+ <h:outputScript name="scripts/f1.js" id="outputScript1"/>
+ <h:outputScript library="scripts" name="f2.js"
id="outputScript2"/>
+ <h:outputStylesheet name="css/stylesRed.css"
id="outputStylesheet1"/>
+ <h:outputStylesheet library="css" name="stylesBlue.css"
id="outputStylesheet2"/>
<span>Blue text</span>
</h:body>
</html>
\ 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/jbide/OpenOnJsf20Test_JBIDE5382.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnJsf20Test_JBIDE5382.java 2010-01-21
17:38:43 UTC (rev 19856)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/OpenOnJsf20Test_JBIDE5382.java 2010-01-21
19:39:06 UTC (rev 19857)
@@ -32,11 +32,18 @@
public class OpenOnJsf20Test_JBIDE5382 extends VpeTest {
private static final String OUTPUT_STYLESHEET_ELEMENT_ID
= "outputStylesheet1"; //$NON-NLS-1$
+ private static final String OUTPUT_STYLESHEET_LIB_ELEMENT_ID
+ = "outputStylesheet2"; //$NON-NLS-1$
private static final String OUTPUT_SCRIPT_ELEMENT_ID
= "outputScript1"; //$NON-NLS-1$
+ private static final String OUTPUT_SCRIPT_LIB_ELEMENT_ID
+ = "outputScript2"; //$NON-NLS-1$
private static final String SCRIPT_FILE_NAME = "f1.js"; //$NON-NLS-1$
+ private static final String SCRIPT_LIB_FILE_NAME = "f2.js"; //$NON-NLS-1$
private static final String STYLESHEET_FILE_NAME
= "stylesRed.css"; //$NON-NLS-1$
+ private static final String STYLESHEET_LIB_FILE_NAME
+ = "stylesBlue.css"; //$NON-NLS-1$
private static final String TEST_FILE_PATH
= "JBIDE/5382/OpenOnJsf20.xhtml"; //$NON-NLS-1$
private VpeController vpeController;
@@ -62,12 +69,23 @@
.getAttributeNode(JSF.ATTR_NAME));
assertActiveEditorInputNameEquals(STYLESHEET_FILE_NAME);
}
+
+ public void testSourceOpenOnOutputStylesheetLib() throws Throwable {
+ openOnSourceNode(getOutputStylesheetLibNode()
+ .getAttributeNode(JSF.ATTR_NAME));
+ assertActiveEditorInputNameEquals(STYLESHEET_LIB_FILE_NAME);
+ }
public void testSourceOpenOnOutputScript() throws Throwable {
openOnSourceNode(getOutputScriptNode().getAttributeNode(JSF.ATTR_NAME));
assertActiveEditorInputNameEquals(SCRIPT_FILE_NAME);
}
+ public void testSourceOpenOnOutputScriptLib() throws Throwable {
+ openOnSourceNode(getOutputScriptLibNode().getAttributeNode(JSF.ATTR_NAME));
+ assertActiveEditorInputNameEquals(SCRIPT_LIB_FILE_NAME);
+ }
+
public void testVisualOpenOnOutputStylesheet() {
showInvisibleTags();
openOnCorrespondingVisualNode(getOutputStylesheetNode());
@@ -86,11 +104,19 @@
private Element getOutputScriptNode() {
return sourceDocument.getElementById(OUTPUT_SCRIPT_ELEMENT_ID);
}
+
+ private Element getOutputScriptLibNode() {
+ return sourceDocument.getElementById(OUTPUT_SCRIPT_LIB_ELEMENT_ID);
+ }
private Element getOutputStylesheetNode() {
return sourceDocument.getElementById(OUTPUT_STYLESHEET_ELEMENT_ID);
}
+ private Element getOutputStylesheetLibNode() {
+ return sourceDocument.getElementById(OUTPUT_STYLESHEET_LIB_ELEMENT_ID);
+ }
+
private void openOnSourceNode(Node sourceNode) throws Throwable {
int offset = NodesManagingUtil.getStartOffsetNode(sourceNode);
OpenOnUtil.performOpenOnAction(vpeController.getSourceEditor(), offset);