Author: dazarov
Date: 2009-08-14 11:15:00 -0400 (Fri, 14 Aug 2009)
New Revision: 17087
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlink.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlinkPartitioner.java
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4380
Modified: trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml 2009-08-14 14:32:47
UTC (rev 17086)
+++ trunk/common/plugins/org.jboss.tools.common.text.ext/plugin.xml 2009-08-14 15:15:00
UTC (rev 17087)
@@ -215,6 +215,24 @@
</contentType>
</hyperlinkPartitioner>
+ <hyperlinkPartitioner
+ class="org.jboss.tools.common.text.ext.hyperlink.xml.IncludeHyperlinkPartitioner"
+ id="org.jboss.tools.common.text.ext.hyperlink.xml.IncludeHyperlinkPartitioner">
+ <contentType id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ <axis
path="*/[http://java.sun.com/jstl/core]:import/url" />
+ <axis
path="*/[http://java.sun.com/jstl/core]:redirect/url"
/>
+ </partitionType>
+ </contentType>
+ <contentType id="org.eclipse.jst.jsp.core.jspsource">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ <axis
path="*/[http://java.sun.com/jstl/core]:import/url" />
+ <axis
path="*/[http://java.sun.com/jstl/core]:redirect/url"
/>
+ </partitionType>
+ </contentType>
+ </hyperlinkPartitioner>
+
+
<!-- End of Common XML hyperlink partitioners -->
<!-- Common HTML and/or JSP hyperlink partitioners -->
@@ -935,6 +953,17 @@
<partitiontype
id="org.jboss.tools.common.text.ext.hyperlink.xml.PORTLET_RESOURCE" />
</contenttypeidentifier>
</hyperlink>
+
+ <hyperlink
+ class="org.jboss.tools.common.text.ext.hyperlink.xml.IncludeHyperlink"
+ id="org.jboss.tools.common.text.ext.hyperlink.xml.IncludeHyperlink">
+ <contenttypeidentifier
id="org.eclipse.wst.html.core.htmlsource">
+ <partitiontype
id="org.jboss.tools.common.text.ext.hyperlink.xml.INCLUDE_FILE" />
+ </contenttypeidentifier>
+ <contenttypeidentifier
id="org.eclipse.jst.jsp.core.jspsource">
+ <partitiontype
id="org.jboss.tools.common.text.ext.hyperlink.xml.INCLUDE_FILE" />
+ </contenttypeidentifier>
+ </hyperlink>
</extension>
</plugin>
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlink.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlink.java 2009-08-14
15:15:00 UTC (rev 17087)
@@ -0,0 +1,57 @@
+package org.jboss.tools.common.text.ext.hyperlink.xml;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Node;
+
+public class IncludeHyperlink extends AbstractHyperlink {
+ private String hyperlinkText = ""; //$NON-NLS-1$
+
+ @Override
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ Node n = IncludeHyperlinkPartitioner.getNode(getDocument(), offset);
+
+ int start = Utils.getValueStart(n);
+ if(start < 0) return null;
+ int end = Utils.getValueEnd(n);
+
+ Region region = new Region(start, end-start);
+
+ return region;
+ }
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ if (region == null)
+ return;
+
+ try {
+ IDocument document = getDocument();
+ hyperlinkText = document
+ .get(region.getOffset(), region.getLength());
+ } catch (BadLocationException ex) {
+ ExtensionsPlugin.getPluginLog().logError(ex);
+ }
+
+ String fileName = Utils.trimQuotes(hyperlinkText);
+
+ IFile file = getFileFromProject(fileName);
+
+ if(file != null)
+ openFileInEditor(file);
+ else
+ openFileFailed();
+ }
+
+ @Override
+ public String getHyperlinkText() {
+ return hyperlinkText;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlinkPartitioner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlinkPartitioner.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlinkPartitioner.java 2009-08-14
15:15:00 UTC (rev 17087)
@@ -0,0 +1,53 @@
+package org.jboss.tools.common.text.ext.hyperlink.xml;
+
+import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class IncludeHyperlinkPartitioner extends AbstractHyperlinkPartitioner {
+ public static final String INCLUDE_FILE_PARTITION =
"org.jboss.tools.common.text.ext.hyperlink.xml.INCLUDE_FILE"; //$NON-NLS-1$
+ public static final String URL_NAME="url";
+
+ public static Node getNode(IDocument document, int superOffset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null)
+ return null;
+
+ Node node = Utils.findNodeForOffset(xmlDocument, superOffset); // #text
+
+ return node;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ @Override
+ protected IHyperlinkRegion parse(IDocument document,
+ IHyperlinkRegion superRegion) {
+
+ Node node = getNode(document, superRegion.getOffset());
+
+ if(!URL_NAME.equals(node.getNodeName()))
+ return null;
+
+ int start = Utils.getValueStart(node);
+ if(start < 0) return null;
+ int end = Utils.getValueEnd(node);
+
+ String contentType = superRegion.getContentType();
+ String axis = getAxis(document, superRegion);
+
+ IHyperlinkRegion hyperRegion = new HyperlinkRegion(start, end-start,
+ axis, contentType, INCLUDE_FILE_PARTITION);
+ return hyperRegion;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/xml/IncludeHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain