Author: scabanovich
Date: 2009-09-25 11:01:55 -0400 (Fri, 25 Sep 2009)
New Revision: 17747
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.classpath
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.cvsignore
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.options.template
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.project
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.ruleset
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/org.eclipse.jdt.core.prefs
trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.text.ext/about.html
trunk/jst/plugins/org.jboss.tools.jst.text.ext/build.properties
trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.properties
trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin_ja.properties
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/JSTExtensionsPlugin.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/FilterNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/RoleNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ServletNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TLDAttributeNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementAttributeValueHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeValueHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTextHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/CSSTextScanner.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/TaglibManagerWrapper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4950
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.classpath
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.classpath (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/.classpath 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.cvsignore
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.cvsignore (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/.cvsignore 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1 @@
+bin
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.cvsignore
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.options.template
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.options.template
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/.options.template 2009-09-25 15:01:55
UTC (rev 17747)
@@ -0,0 +1 @@
+org.jboss.tools.jsf.text.ext/debug=false
\ No newline at end of file
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.project
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.project (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/.project 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.jst.text.ext</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.pmd.runtime.pmdBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>net.sourceforge.pmd.runtime.pmdNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/.ruleset
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.ruleset (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/.ruleset 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ruleset
xmlns="http://pmd.sf.net/ruleset/1.0.0" name=""
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema....
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd">
+<description></description>
+<rule class="net.sourceforge.pmd.rules.XPathRule" dfa="false"
externalInfoUrl="" message="Exception catch is too generic"
name="Avoid Catching Excetpion" typeResolution="true">
+<description></description>
+<priority>1</priority>
+<properties>
+<property name="xpath">
+<value><![CDATA[//CatchStatement/FormalParameter/Type
+ /ReferenceType/ClassOrInterfaceType[@Image='Exception']]]></value>
+</property>
+</properties>
+<example></example>
+<example></example>
+<example></example>
+</rule>
+</ruleset>
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/org.eclipse.jdt.core.prefs 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,9 @@
+#Fri Sep 25 18:49:45 GMT+03:00 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.source=1.5
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/MANIFEST.MF 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Eclipse-LazyStart: true
+Bundle-Activator: org.jboss.tools.jst.text.ext.JSTExtensionsPlugin
+Export-Package: org.jboss.tools.jst.text.ext,
+ org.jboss.tools.jst.text.ext.hyperlink,
+ org.jboss.tools.jst.text.ext.hyperlink.jsp,
+ org.jboss.tools.jst.text.ext.util
+Bundle-Version: 2.0.0
+Bundle-Name: %Bundle-Name.0
+Bundle-ManifestVersion: 2
+Bundle-Vendor: %providerName
+Plugin-Class: org.jboss.tools.jst.text.ext.JSTExtensionsPlugin
+Bundle-SymbolicName: org.jboss.tools.jst.text.ext;singleton:=true
+Bundle-Localization: plugin
+Require-Bundle: org.jboss.tools.common.model,
+ org.jboss.tools.common.text.ext,
+ org.eclipse.ui.ide,
+ org.eclipse.ui,
+ org.eclipse.jface.text,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.jdt.ui,
+ org.eclipse.wst.sse.core;visibility:=reexport,
+ org.eclipse.wst.sse.ui;visibility:=reexport,
+ org.eclipse.jst.jsp.core;visibility:=reexport,
+ org.eclipse.wst.common.modulecore;visibility:=reexport,
+ org.eclipse.pde.ui,
+ org.jboss.tools.common.el.core;bundle-version="2.0.0",
+ org.eclipse.emf.ecore;bundle-version="2.5.0",
+ org.eclipse.wst.css.core,
+ org.eclipse.wst.html.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/about.html
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/about.html (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/about.html 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<HTML>
+
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+
+<BODY lang="EN-US">
+
+<H3>About This Content</H3>
+
+<P>©2007 Red Hat, Inc. All rights reserved</P>
+
+<H3>License</H3>
+
+<P>Red Hat Inc., through its JBoss division, makes available all content in this
plug-in
+("Content"). Unless otherwise indicated below, the Content is provided to you
+under the terms and conditions of the Eclipse Public License Version 1.0
+("EPL"). A copy of the EPL is available at
+<A
href="http://www.eclipse.org/org/documents/epl-v10.php">http...;.
+For purposes of the EPL, "Program" will mean the Content.</P>
+
+<P>If you did not receive this Content directly from Red Hat Inc., the
+Content is being redistributed by another party ("Redistributor") and different
+terms and conditions may apply to your use of any object code in the Content.
+Check the Redistributor's license that was provided with the Content. If no such
+license exists, contact the Redistributor. Unless otherwise indicated below, the
+terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at
+ <A
href="http://www.jboss.org/tools">http://www.jboss.org/tools...
+
+</BODY>
+</HTML>
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/about.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/build.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/build.properties
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/build.properties 2009-09-25 15:01:55
UTC (rev 17747)
@@ -0,0 +1,10 @@
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+bin.includes = .,\
+ plugin.xml,\
+ plugin.properties,\
+ META-INF/,\
+ about.html
+src.includes = src/,\
+ plugin.xml
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/build.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.properties
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.properties 2009-09-25 15:01:55
UTC (rev 17747)
@@ -0,0 +1,3 @@
+providerName=JBoss by Red Hat
+
+Bundle-Name.0 = Text Editors Extensions
\ No newline at end of file
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.xml (rev
0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.xml 2009-09-25 15:01:55 UTC (rev
17747)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+</plugin>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin_ja.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin_ja.properties
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin_ja.properties 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,2 @@
+providerName=JBoss by Red Hat
+Bundle-Name.0=\u30C6\u30AD\u30B9\u30C8\u30FB\u30A8\u30C7\u30A3\u30BF\u30FC\u62E1\u5F35
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.text.ext/plugin_ja.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/JSTExtensionsPlugin.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/JSTExtensionsPlugin.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/JSTExtensionsPlugin.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.jboss.tools.common.log.IPluginLog;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * @author Jeremy
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class JSTExtensionsPlugin extends BaseUIPlugin implements IAdaptable {
+ //The shared instance.
+ private static JSTExtensionsPlugin plugin;
+
+ public static final String PLUGIN_ID = "org.jboss.tools.common.text.ext";
//$NON-NLS-1$
+
+ /**
+ * The constructor.
+ */
+ public JSTExtensionsPlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static JSTExtensionsPlugin getDefault() {
+ return plugin;
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (adapter == IHyperlinkDetector.class) {
+ return HyperlinkDetector.getInstance();
+ }
+ return null;
+ }
+
+
+ /**
+ * @return IPluginLog object
+ */
+ public static IPluginLog getPluginLog() {
+ return getDefault();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/JSTExtensionsPlugin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,509 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleRule;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet;
+import org.eclipse.wst.html.core.internal.htmlcss.LinkElementAdapter;
+import org.eclipse.wst.html.core.internal.htmlcss.URLModelProvider;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.common.text.ext.util.RegionHolder;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
+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;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+import org.w3c.dom.css.CSSStyleSheet;
+
+/**
+ * @author Jeremy
+ */
+public class CSSClassHyperlink extends AbstractHyperlink {
+
+ public static final String[] STYLE_TAGS = new String[] { "style",
"link" }; //$NON-NLS-1$//$NON-NLS-2$
+ public static final String LINK_TAG = "link"; //$NON-NLS-1$
+ public static final String HREF_ATTRIBUTE = "href"; //$NON-NLS-1$
+ public static final String COMPARE_CLASS_REGEX_PREFIX = "[\\.]?";
//$NON-NLS-1$
+ public static final String CONTEXT_PATH_EXPRESSION =
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}";
//$NON-NLS-1$
+
+ /**
+ *
+ */
+ protected void doHyperlink(IRegion region) {
+
+ IDOMModel model = (IDOMModel) getModelManager()
+ .getExistingModelForRead(getDocument());
+
+ // get name of looked for style
+ String styleName = getStyleName(region);
+
+ // get elements which copntans information about styles (style and link
+ // tags)
+ List<Node> styleElementList = getStyleContainerList(model);
+
+ // sort nodes by position in inverse order - from larger position to
+ // smaller
+ Collections.sort(styleElementList, new Comparator<Node>() {
+
+ public int compare(Node o1, Node o2) {
+ return ((IDOMNode) o2).getStartOffset()
+ - ((IDOMNode) o1).getStartOffset();
+ }
+
+ });
+
+ RegionHolder styleRegion = null;
+ // look for style in each Style element
+ for (Node styleContainer : styleElementList) {
+
+ styleRegion = findStyleRegion(styleContainer, styleName);
+
+ if (styleRegion != null) {
+ showRegion(styleRegion);
+ break;
+ }
+
+ }
+
+ model.releaseFromRead();
+ }
+
+ /**
+ *
+ * @param model
+ * @return
+ */
+ private List<Node> getStyleContainerList(IDOMModel model) {
+
+ // get model of current page
+ IDOMDocument document = model.getDocument();
+
+ List<Node> getStyleContainerList = new ArrayList<Node>();
+
+ // get all tags which contains style ( link, style)
+ for (String tagName : STYLE_TAGS) {
+ getStyleContainerList.addAll(getList(document
+ .getElementsByTagName(tagName)));
+ }
+
+ return getStyleContainerList;
+ }
+
+ /**
+ * move nodes from NodeList to List
+ *
+ * @param nodeList
+ * @return
+ */
+ List<Node> getList(NodeList nodeList) {
+
+ List<Node> newContainerList = new ArrayList<Node>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ newContainerList.add(nodeList.item(i));
+ }
+ return newContainerList;
+ }
+
+ /**
+ *
+ * @param stylesContainer
+ * @param styleName
+ * @return
+ */
+ public RegionHolder findStyleRegion(Node stylesContainer, String styleName) {
+
+ // get style sheet
+ CSSStyleSheet sheet = getSheet(stylesContainer);
+
+ if (sheet != null) {
+
+ CSSRuleList ruleList = sheet.getCssRules();
+
+ // for each cssRule
+ for (int i = 0; i < ruleList.getLength(); i++) {
+
+ CSSRule cssRule = ruleList.item(i);
+
+ // if cssRule describe looked for style
+ if (isRuleMatch(cssRule, styleName)) {
+
+ return new RegionHolder(getFile((ICSSNode) cssRule),
+ getRegion(cssRule));
+
+ }
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param stylesContainer
+ * @return
+ */
+ private CSSStyleSheet getSheet(final Node stylesContainer) {
+
+ INodeNotifier notifier = (INodeNotifier) stylesContainer;
+
+ IStyleSheetAdapter adapter = (IStyleSheetAdapter) notifier
+ .getAdapterFor(IStyleSheetAdapter.class);
+
+ if (LINK_TAG.equalsIgnoreCase(stylesContainer.getNodeName())
+ && !(adapter instanceof ExtendedLinkElementAdapter)) {
+
+ notifier.removeAdapter(adapter);
+ adapter = new ExtendedLinkElementAdapter(
+ (Element) stylesContainer);
+ notifier.addAdapter(adapter);
+
+ }
+
+ CSSStyleSheet sheet = null;
+
+ if (adapter != null) {
+ sheet = (CSSStyleSheet) adapter.getSheet();
+
+ }
+
+ return sheet;
+
+ }
+
+ protected String processURL(String href) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ *
+ * @param cssRule
+ * @param styleName
+ * @return
+ */
+ private boolean isRuleMatch(CSSRule cssRule, String styleName) {
+
+ // get selector text
+ String selectorText = ((ICSSStyleRule) cssRule).getSelectorText();
+
+ if (selectorText != null) {
+
+ // split selector text by whitespace
+ String[] styles = selectorText.trim().split(" "); //$NON-NLS-1$
+ int searchIndex = Arrays.binarySearch(styles, styleName,
+ new Comparator<String>() {
+
+ public int compare(String o1, String o2) {
+ Matcher matcher = Pattern.compile(
+ COMPARE_CLASS_REGEX_PREFIX + o2)
+ .matcher(o1);
+ return matcher.matches() ? 0 : 1;
+ }
+
+ });
+ if (searchIndex >= 0)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ private IFile getFile(ICSSNode node) {
+
+ ICSSDocument sheet = node.getOwnerDocument();
+
+ return AbstractHyperlink.getFile(sheet.getModel());
+ }
+
+ /**
+ *
+ * @param cssRule
+ * @return
+ */
+ protected Region getRegion(CSSRule cssRule) {
+
+ int offset = ((IndexedRegion) cssRule).getStartOffset();
+
+ // if css rule is contained in style tag so it is require to take into
+ // account offset of this tag
+ ICSSStyleSheet document = (ICSSStyleSheet) ((ICSSStyleRule) cssRule)
+ .getOwnerDocument();
+
+ ICSSModel model = document.getModel();
+
+ // get style tag
+ Node node = model.getOwnerDOMNode();
+
+ // increase offset
+ if (node instanceof IDOMElement)
+ offset += ((IDOMElement) node).getStartEndOffset();
+
+ return new Region(offset, 0);
+
+ }
+
+ /**
+ *
+ * @param styleRegion
+ */
+ private void showRegion(RegionHolder styleRegion) {
+
+ IWorkbenchPage workbenchPage = ExtensionsPlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart part = null;
+ if (styleRegion.file != null) {
+ try {
+ part = IDE.openEditor(workbenchPage, styleRegion.file, true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ if (part == null) {
+ openFileFailed();
+ return;
+ }
+ }
+ StructuredSelectionHelper.setSelectionAndReveal(part,
+ styleRegion.region);
+ }
+
+ /**
+ *
+ * @param region
+ * @return
+ */
+ private String getStyleName(IRegion region) {
+ try {
+ return getDocument().get(region.getOffset(), region.getLength());
+ } catch (BadLocationException e) {
+ return null;
+ }
+ }
+
+ IRegion fLastRegion = null;
+
+ /**
+ * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ fLastRegion = getRegion(offset);
+ return fLastRegion;
+ }
+
+ /**
+ * TODO research method
+ *
+ * @param offset
+ * @return
+ */
+ protected IRegion getRegion(int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null)
+ return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Attr))
+ return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if (start > offset)
+ return null;
+
+ String attrText = getDocument().get(start, end - start);
+
+ StringBuffer sb = new StringBuffer(attrText);
+ // find start of bean property
+ int bStart = offset - start;
+ while (bStart >= 0) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bStart))
+ && sb.charAt(bStart) != '_' && sb.charAt(bStart) !=
'-'
+ && sb.charAt(bStart) != '.') {
+ bStart++;
+ break;
+ }
+
+ if (bStart == 0)
+ break;
+ bStart--;
+ }
+ // find end of bean property
+ int bEnd = offset - start;
+ while (bEnd < sb.length()) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bEnd))
+ && sb.charAt(bEnd) != '_' && sb.charAt(bEnd) !=
'-'
+ && sb.charAt(bEnd) != '.')
+ break;
+ bEnd++;
+ }
+
+ final int propStart = bStart + start;
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset)
+ return null;
+ return new Region(propStart, propLength);
+ } catch (BadLocationException x) {
+ // ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String styleName = getStyleName(fLastRegion);
+ if (styleName == null)
+ return MessageFormat.format(Messages.OpenA, Messages.CSSStyle);
+
+ return MessageFormat.format(Messages.OpenCSSStyle, styleName);
+ }
+
+ @Override
+ protected String findAndReplaceElVariable(String fileName) {
+ if (fileName != null)
+ fileName = fileName
+ .replaceFirst(
+ "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
+ "");
+ return super.findAndReplaceElVariable(fileName);
+ }
+
+ public class ExtendedLinkElementAdapter extends LinkElementAdapter {
+
+ private Element element;
+
+ public ExtendedLinkElementAdapter(Element element) {
+ this.element = element;
+ }
+
+ @Override
+ public Element getElement() {
+ return element;
+ }
+
+ @Override
+ protected boolean isValidAttribute() {
+ String href = getElement().getAttribute(HREF_ATTRIBUTE);
+ if (href == null || href.length() == 0)
+ return false;
+ return true;
+ }
+
+ /**
+ */
+ public ICSSModel getModel() {
+ ICSSModel model = super.getModel();
+ if (model == null) {
+ model = retrieveModel();
+ setModel(model);
+ }
+ return model;
+ }
+
+ /**
+ */
+ private ICSSModel retrieveModel() {
+ if (!isValidAttribute()) {
+ return null;
+ }
+
+ // null,attr check is done in isValidAttribute()
+ Element element = getElement();
+ String href = findAndReplaceElVariable(element
+ .getAttribute(HREF_ATTRIBUTE));
+
+ IDOMModel baseModel = ((IDOMNode) element).getModel();
+ if (baseModel == null)
+ return null;
+ Object id = baseModel.getId();
+ if (!(id instanceof String))
+ return null;
+ // String base = (String)id;
+
+ // get ModelProvideAdapter
+ IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement())
+ .getAdapterFor(IModelProvideAdapter.class);
+
+ URLModelProvider provider = new URLModelProvider();
+ try {
+ IStructuredModel newModel = provider.getModelForRead(baseModel,
+ href);
+ if (newModel == null)
+ return null;
+ if (!(newModel instanceof ICSSModel)) {
+ newModel.releaseFromRead();
+ return null;
+ }
+
+ // notify adapter
+ if (adapter != null)
+ adapter.modelProvided(newModel);
+
+ return (ICSSModel) newModel;
+ } catch (UnsupportedEncodingException e) {
+ } catch (IOException e) {
+ }
+
+ return null;
+ }
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.jst.text.ext.hyperlink;
+
+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.IHyperlinkPartitionRecognizer;
+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.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSClassHyperlinkPartitioner extends
+ AbstractHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
+
+ public static final String CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.CSS_CLASS"; //$NON-NLS-1$
+
+ private static final String CSS_CLASS_TOKEN = "class/"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
+ * com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document,
+ IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null)
+ return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion
+ .getOffset());
+ if (n == null || !(n instanceof Attr))
+ return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = getPartitionType(axis);
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if (start < 0 || end < start)
+ return null;
+ int length = end - start;
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis,
+ contentType, type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private String getPartitionType(String axis) {
+ return CSS_CLASS_PARTITION;
+ }
+
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+
+ if (region.getAxis() != null
+ && region.getAxis().toLowerCase().endsWith(CSS_CLASS_TOKEN))
+ return true;
+ return false;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/FilterNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/FilterNameHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/FilterNameHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import org.jboss.tools.common.text.ext.hyperlink.JumpToHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+/**
+ * @author Jeremy
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class FilterNameHyperlink extends JumpToHyperlink {
+ protected String getDestinationAxis() {
+ return "/web-app/filter/filter-name/"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return Messages.BrowseToFilterNameDefinition;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/FilterNameHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+import org.jboss.tools.common.text.ext.hyperlink.RelativeLinkHyperlink;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+
+/**
+ * @author Jeremy
+ *
+ */
+public class JSPStylesheetRelLinkHyperlink extends RelativeLinkHyperlink {
+
+ private static final String HREF_ATTRNAME = "href"; //$NON-NLS-1$
+
+ protected IRegion getRegion (int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Text || n instanceof Attr)) return null;
+
+ String text = null;
+ int bStart = 0;
+ int bEnd = 0;
+
+ if (n instanceof Text) {
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if (start < 0 || start > offset) return null;
+
+ text = getDocument().get(start, end - start);
+ bStart = offset - start;
+ bEnd = offset - start;
+ } else if (n instanceof Attr) {
+ Attr attr = (Attr)n;
+ if (!HREF_ATTRNAME.equalsIgnoreCase(attr.getName())) return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if(start < 0) return null;
+
+ text = getDocument().get(start, end - start);
+ bStart = offset - start;
+ bEnd = offset - start;
+ }
+ StringBuffer sb = new StringBuffer(text);
+ //find start of bean property
+ while (bStart >= 0) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
+ sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/'
&&
+ sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-'
&&
+ sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_'
&&
+ sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?'
&&
+ sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=')
{
+ bStart++;
+ break;
+ }
+
+ if (bStart == 0) break;
+ bStart--;
+ }
+ // find end of bean property
+ while (bEnd >= 0 && bEnd < sb.length()) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
+ sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/'
&&
+ sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-'
&&
+ sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_'
&&
+ sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?'
&&
+ sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
+ break;
+ }
+ bEnd++;
+ }
+
+ final int propStart = bStart + Utils.getValueStart(n);
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+
+ return new Region(propStart,propLength);
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/JSPStylesheetRelLinkHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/RoleNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/RoleNameHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/RoleNameHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import org.jboss.tools.common.text.ext.hyperlink.JumpToHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+
+
+/**
+ * @author Jeremy
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class RoleNameHyperlink extends JumpToHyperlink {
+ protected String getDestinationAxis() {
+ return "/web-app/security-role/role-name/"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return Messages.BrowseToRoleNameDefinition;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/RoleNameHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ServletNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ServletNameHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ServletNameHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import org.jboss.tools.common.text.ext.hyperlink.JumpToHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+
+
+/**
+ * @author Jeremy
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class ServletNameHyperlink extends JumpToHyperlink {
+ protected String getDestinationAxis() {
+ return "/web-app/servlet/servlet-name/"; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return Messages.BrowseToServletNameDefinition;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/ServletNameHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TLDAttributeNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TLDAttributeNameHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TLDAttributeNameHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.text.IRegion;
+import org.jboss.tools.common.text.ext.hyperlink.JumpToHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+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.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Jeremy
+ *
+ */
+public class TLDAttributeNameHyperlink extends JumpToHyperlink {
+ protected String getDestinationAxis() {
+ return "/taglib/tag/attribute/name/"; //$NON-NLS-1$
+ }
+
+ protected NodeList getRootElementsToSearch (IRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+
+ Element tagElement = null;
+ while(n != null && tagElement == null) {
+ n = n.getParentNode();
+ if (n instanceof Element && validAxis(n, "/taglib/tag/")) {
//$NON-NLS-1$
+ tagElement = (Element)n;
+ }
+ }
+ if (tagElement == null)
+ return null;
+
+ return tagElement.getChildNodes();
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private boolean validAxis(Node n, String validAxisEnding) {
+ if (validAxisEnding == null || validAxisEnding.lastIndexOf('/') == -1) return
false;
+ StringTokenizer st = new StringTokenizer(validAxisEnding, "/");
//$NON-NLS-1$
+ List<String> tokens = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ tokens.add(st.nextToken());
+ }
+ if (tokens.size() == 0) return false;
+ Node currentElement = n;
+ for (int i = tokens.size() - 1; i >= 0; i--) {
+ if (currentElement == null || !(currentElement instanceof Element))
+ return false;
+ String token = (String)tokens.get(i);
+ if (!token.equals(currentElement.getNodeName()))
+ return false;
+ currentElement = currentElement.getParentNode();
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return Messages.BrowseToTLDAttributeNameDeclaration;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TLDAttributeNameHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.jst.text.ext.hyperlink;
+
+import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLClassHyperlinkPartitioner;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLTextHyperlinkPartitioner;
+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;
+import org.w3c.dom.Text;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class TaglibDefinitionFilesHyperlinkPartitioner extends
XMLTextHyperlinkPartitioner {
+
+ public static final String TAGLIB_XML_PARTITION =
"org.jboss.tools.common.text.ext.xml.TAGLIB_XML"; //$NON-NLS-1$
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion)
+ */
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ @Override
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ return (n instanceof Text);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ @Override
+ protected String getPartitionType(String axis) {
+ if(axis!=null && axis.contains("class")) { //$NON-NLS-1$
+ return XMLClassHyperlinkPartitioner.XML_CLASS_PARTITION;
+ }
+ return TAGLIB_XML_PARTITION;
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/TaglibDefinitionFilesHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.common.text.ext.hyperlink.ClassMethodHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+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;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Jeremy
+ *
+ */
+public class JSPBeanGetPropertyHyperlink extends ClassMethodHyperlink {
+ private static final String USEBEAN_TAGNAME = "jsp:useBean"; //$NON-NLS-1$
+ private static final String ID_ATTRNAME = "id"; //$NON-NLS-1$
+ private static final String NAME_ATTRNAME = "name"; //$NON-NLS-1$
+ private static final String CLASS_ATTRNAME = "class"; //$NON-NLS-1$
+ private static final String TYPE_ATTRNAME = "type"; //$NON-NLS-1$
+ protected static final String GET_METHOD_PREFIX = "get"; //$NON-NLS-1$
+ protected static final String SET_METHOD_PREFIX = "set"; //$NON-NLS-1$
+
+ protected String getMethodPrefix() {
+ return GET_METHOD_PREFIX;
+ }
+
+ private String getMethodName(String propertyName) {
+ String name = propertyName.trim();
+ // Capitalize first letter of the name
+ name = name.substring(0, 1).toUpperCase() + name.substring(1);
+ return getMethodPrefix() + name;
+ }
+
+ protected String getClassName(IRegion region) {
+ return null;
+ }
+ protected String getMethodName(IRegion region) {
+ return null;
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
+ */
+ protected void doHyperlink(IRegion region) {
+ try {
+ String beanID = getBeanId(region);
+ String propertyName = getPropertyName(region);
+
+ Element elementByID = findElementByIDBackward(beanID, region.getOffset(),
USEBEAN_TAGNAME);
+ String className = getAttributeValue(elementByID, CLASS_ATTRNAME);
+ String typeName = getAttributeValue(elementByID, TYPE_ATTRNAME);
+
+ IJavaElement beanMethod = null;
+ if (className != null && className.trim().length() > 0) {
+ beanMethod = searchForClassMethod(className, getMethodName(propertyName));
+ }
+ if (beanMethod == null && (typeName != null &&
typeName.trim().length() > 0)) {
+ beanMethod = searchForClassMethod(typeName, getMethodName(propertyName));
+ }
+
+ if (beanMethod != null) {
+ IEditorPart part = JavaUI.openInEditor(beanMethod);
+ if (part != null) {
+ JavaUI.revealInEditor(part, beanMethod);
+ }
+ else {
+ // could not open editor
+ openFileFailed();
+ }
+ } else {
+ openFileFailed();
+ }
+ } catch (CoreException x) {
+ openFileFailed();
+ }
+ }
+
+ private Element findElementByIDBackward (String id, int endOffset, String tagname) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, endOffset);
+
+ if (n == null) return null;
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+
+ Element element = null;
+ for (Node parent = n;parent != null && element == null; parent =
parent.getParentNode()) {
+ element = findElementByIDBackward(xmlDocument.getChildNodes(), id, endOffset,
tagname);
+ }
+ return element;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private Element findElementByIDBackward(NodeList list, String id, int endOffset, String
tagName) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
+ if(!(list.item(i) instanceof Element)) continue;
+ Element element = (Element)list.item(i);
+ int start = Utils.getValueStart(element);
+ if (start < 0 || start >= endOffset) continue;
+
+ String elementName = element.getNodeName();
+ if (tagName.equals(elementName)) {
+
+ Attr idAttr = element.getAttributeNode(ID_ATTRNAME);
+ if (idAttr != null) {
+ String val = Utils.trimQuotes(idAttr.getNodeValue());
+ if (id.equals(val)) {
+ return element;
+ }
+ }
+ }
+
+ if (element.hasChildNodes()) {
+ Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
+ if (child != null) return child;
+ }
+
+ }
+ } finally {
+ smw.dispose();
+ }
+ return null;
+ }
+
+ String getPropertyName(IRegion region) {
+ try {
+ return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ }
+ }
+
+ private String getBeanId(IRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+
+ if (n == null || !(n instanceof Attr)) return null;
+
+ Node node = ((Attr)n).getOwnerElement();
+
+ return getAttributeValue(node, NAME_ATTRNAME);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String propertyName = getPropertyName(fLastRegion);
+ if (propertyName == null)
+ return MessageFormat.format(Messages.OpenA, Messages.Getter);
+
+ return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Getter,
propertyName);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+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.IHyperlinkPartitionRecognizer;
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPBeanGetPropertyHyperlinkPartitioner extends AbstractHyperlinkPartitioner
implements IHyperlinkPartitionRecognizer {
+ public static final String JSP_BEAN_GET_PROPERTY_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_BEAN_GET_PROPERTY"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ if (n == null || !(n instanceof Attr)) return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if(start < 0) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_BEAN_GET_PROPERTY_PARTITION;
+ int length = end - start - (superRegion.getOffset() - start);
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof Attr)) return false;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start < 0 || start > region.getOffset() || end < region.getOffset())
+ return false;
+
+ return true;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanGetPropertyHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+
+/**
+ * @author Jeremy
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class JSPBeanSetPropertyHyperlink extends JSPBeanGetPropertyHyperlink {
+
+ protected String getMethodPrefix() {
+ return SET_METHOD_PREFIX;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String propertyName = getPropertyName(fLastRegion);
+ if (propertyName == null)
+ return MessageFormat.format(Messages.OpenA, Messages.Setter);
+
+ return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter,
propertyName);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+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.IHyperlinkPartitionRecognizer;
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPBeanSetPropertyHyperlinkPartitioner extends AbstractHyperlinkPartitioner
implements IHyperlinkPartitionRecognizer {
+ public static final String JSP_BEAN_SET_PROPERTY_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_BEAN_SET_PROPERTY"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ if (n == null || !(n instanceof Attr)) return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_BEAN_SET_PROPERTY_PARTITION;
+ int length = end - start - (superRegion.getOffset() - start);
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof Attr)) return false;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start < 0 || start > region.getOffset() || end < region.getOffset())
+ return false;
+
+ return true;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPBeanSetPropertyHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+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;
+
+/**
+ * * @deprecated see
org.jboss.tools.common.text.ext.hyperlink.CSSClassHyperlinkPartitioner
+ * @author Jeremy
+ */
+public class JSPCSSClassHyperlinkPartitioner extends AbstractHyperlinkPartitioner
/*implements IHyperlinkPartitionRecognizer */{
+ public static final String JSP_CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_CSS_CLASS"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+// if (!recognize(document, superRegion)) return null;
+ IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ if (r == null) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_CSS_CLASS_PARTITION;
+ int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Attr)) return null;
+
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start < 0 || start > offset) return null;
+
+ String attrText = document.get(start, end - start);
+ StringBuffer sb = new StringBuffer(attrText);
+
+ //find start and end of path property
+ int bStart = 0;
+ int bEnd = attrText.length() - 1;
+
+ while (bStart < bEnd &&
+ (sb.charAt(bStart) == '\'' || sb.charAt(bStart) == '\"' ||
+ Character.isWhitespace(sb.charAt(bStart)))) {
+ bStart++;
+ }
+ while (bEnd > bStart &&
+ (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
+ Character.isWhitespace(sb.charAt(bEnd)))) {
+ bEnd--;
+ }
+ bEnd++;
+
+ int propStart = bStart + start;
+ int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+
+ IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
+ return region;
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPCSSClassHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPClassHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPClassHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLClassHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPClassHyperlinkPartitioner extends XMLClassHyperlinkPartitioner {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPClassHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementAttributeValueHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementAttributeValueHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementAttributeValueHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import
org.jboss.tools.common.text.ext.hyperlink.xml.XMLElementAttributeValueHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPElementAttributeValueHyperlinkPartitioner extends
XMLElementAttributeValueHyperlinkPartitioner {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementAttributeValueHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLElementHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPElementHyperlinkPartitioner extends XMLElementHyperlinkPartitioner {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.FindObjectHelper;
+import org.jboss.tools.common.text.ext.ExtensionsPlugin;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.TaglibManagerWrapper;
+import org.jboss.tools.jst.web.tld.ITaglibMapping;
+import org.jboss.tools.jst.web.tld.IWebProject;
+import org.jboss.tools.jst.web.tld.WebProjectFactory;
+import org.w3c.dom.Document;
+
+/**
+ * @author Jeremy
+ */
+public class JSPElementNameHyperlink extends AbstractHyperlink {
+
+ /**
+ * @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
+ */
+ protected void doHyperlink(IRegion region) {
+ XModelObject object = getFilename(region);
+ if(object != null) {
+ FindObjectHelper.findModelObject(object, FindObjectHelper.IN_EDITOR_ONLY);
+ } else {
+ openFileFailed();
+ }
+ }
+
+ protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
+
+ /*
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
+ */
+ protected void openFileInEditor(String fileString) {
+
+ if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
+ fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
+
+ IEditorInput jarEditorInput = createEditorInput(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
+ } else {
+ super.openFileInEditor(fileString);
+ }
+ }
+
+ private XModelObject getFilename(IRegion region) {
+ XModel xModel = getXModel();
+ if (xModel == null) return null;
+
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ String nodePrefix = getTagPrefix(region);
+ if (nodePrefix == null)
+ return null;
+
+ TaglibManagerWrapper tmw = new TaglibManagerWrapper();
+ tmw.init(getDocument(), region.getOffset());
+ if(!tmw.exists()) return null;
+ String uri = tmw.getUri(nodePrefix);
+
+ if (uri == null) return null;
+
+ IWebProject wp = WebProjectFactory.instance.getWebProject(xModel);
+ if (wp == null) return null;
+
+ ITaglibMapping tm = wp.getTaglibMapping();
+ if (tm == null) return null;
+ tm.invalidate();
+ return tm.getTaglibObject(uri);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private String getTagPrefix(IRegion region) {
+ if (region == null)
+ return null;
+
+ String nodeName;
+ try {
+ nodeName = getDocument().get(region.getOffset(), region.getLength());
+ } catch (BadLocationException e) {
+ // Ignore
+ return null;
+ }
+ if (nodeName.indexOf(":") != -1) { //$NON-NLS-1$
+ String nodePrefix = nodeName.substring(0, nodeName.indexOf(":"));
//$NON-NLS-1$
+ if (nodePrefix != null && nodePrefix.length() > 0)
+ return nodePrefix;
+ }
+ return null;
+ }
+
+ IRegion fLastRegion = null;
+ /**
+ * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ fLastRegion = JSPElementNameHyperlinkPartitioner.getRegion(getDocument(), offset);
+ return fLastRegion;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String tagPrefix = getTagPrefix(fLastRegion);
+ if (tagPrefix == null)
+ return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
+
+ return MessageFormat.format(Messages.OpenTagLibraryForPrefix, tagPrefix);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.util.Map;
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+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.jboss.tools.common.text.ext.hyperlink.xml.XMLElementNameHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPElementNameHyperlinkPartitioner extends
XMLElementNameHyperlinkPartitioner {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if (!super.recognize(document, region)) return false;
+
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Element elem = (Element)n;
+
+ IHyperlinkRegion r = getRegion(document, region.getOffset());
+ if (r == null) return false;
+
+ String nodeName = elem.getNodeName();
+ if (nodeName.indexOf(":") == -1) return false; //$NON-NLS-1$
+ String nodePrefix = nodeName.substring(0, nodeName.indexOf(":"));
//$NON-NLS-1$
+ if (nodePrefix == null || nodePrefix.length() == 0) return false;
+
+ Map trackers = JSPRootHyperlinkPartitioner.getTrackersMap(document,
region.getOffset());
+ return (trackers != null && trackers.containsKey(nodePrefix));
+ } finally {
+ smw.dispose();
+ }
+ }
+
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPElementNameHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
+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;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+/**
+ * @author Jeremy
+ */
+public class JSPForBeanIdHyperlink extends AbstractHyperlink {
+ private static final String USEBEAN_TAGNAME = "jsp:useBean"; //$NON-NLS-1$
+ private static final String ID_ATTRNAME = "id"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
+ */
+ protected void doHyperlink(IRegion region) {
+ String forID = getForId(region);
+ IRegion elementByID = findElementByIDBackward(forID, region.getOffset(),
USEBEAN_TAGNAME);
+ if (elementByID != null) {
+ StructuredSelectionHelper.setSelectionAndRevealInActiveEditor(elementByID);
+ } else {
+ openFileFailed();
+ }
+ }
+
+ private IRegion findElementByIDBackward (String id, int endOffset, String tagname) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, endOffset);
+
+ if (n == null) return null;
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (n == null) return null;
+
+ Element element = null;
+ for (Node parent = n; parent != null && element == null; parent =
parent.getParentNode()) {
+ element = findElementByIDBackward(xmlDocument.getChildNodes(), id, endOffset,
tagname);
+ }
+
+ if (!(element instanceof IDOMElement)) return null;
+
+ final int offset = Utils.getValueStart(element);
+ final int length =
((IDOMElement)element).getStartStructuredDocumentRegion().getLength();
+ return new Region (offset, length);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private Element findElementByIDBackward(NodeList list, String id, int endOffset, String
tagName) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
+ if(!(list.item(i) instanceof Element)) continue;
+ Element element = (Element)list.item(i);
+ int start = Utils.getValueStart(element);
+ if (start < 0 || start >= endOffset) continue;
+
+ String elementName = element.getNodeName();
+ if (tagName.equals(elementName)) {
+
+ Attr idAttr = (Attr)element.getAttributeNode(ID_ATTRNAME);
+ if (idAttr != null) {
+ String val = Utils.trimQuotes(idAttr.getNodeValue());
+ if (id.equals(val)) {
+ return element;
+ }
+ }
+ }
+
+ if (element.hasChildNodes()) {
+ Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
tagName);
+ if (child != null) return child;
+ }
+ }
+ } finally {
+ smw.dispose();
+ }
+ return null;
+ }
+
+
+ String getForId(IRegion region) {
+ try {
+ return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ }
+ }
+
+ IRegion fLastRegion = null;
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ fLastRegion = getRegion(offset);
+ return fLastRegion;
+ }
+
+ private IRegion getRegion(int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
+
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start > offset || end < offset) return null;
+
+ String text = getDocument().get(start, end - start);
+ StringBuffer sb = new StringBuffer(text);
+
+ //find start and end of path property
+ int bStart = 0;
+ int bEnd = text.length() - 1;
+
+ while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
+ || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
+ bStart++;
+ }
+ while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
+ || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
+ bEnd--;
+ }
+ bEnd++;
+
+ final int propStart = bStart + start;
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+
+ return new Region (propStart,propLength);
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String forId = getForId(fLastRegion);
+ if (forId == null)
+ return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
+
+ return MessageFormat.format(Messages.BrowseForBeanId, forId);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPForBeanIdHyperlinkPartitioner extends AbstractHyperlinkPartitioner
/*implements IHyperlinkPartitionRecognizer */{
+ public static final String JSP_FOR_BEAN_ID_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_FOR_BEAN_ID"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+// if (!recognize(document, superRegion)) return null;
+ IHyperlinkRegion r = getRegion(document, superRegion.getOffset());
+ if (r == null) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_FOR_BEAN_ID_PARTITION;
+ int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Attr)) return null;
+
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start < 0 || start > offset) return null;
+
+ String attrText = document.get(start, end - start);
+ StringBuffer sb = new StringBuffer(attrText);
+
+ //find start and end of path property
+ int bStart = 0;
+ int bEnd = attrText.length() - 1;
+
+ while (bStart < bEnd &&
+ (sb.charAt(bStart) == '\'' || sb.charAt(bStart) == '\"' ||
+ Character.isWhitespace(sb.charAt(bStart)))) {
+ bStart++;
+ }
+ while (bEnd > bStart &&
+ (sb.charAt(bEnd) == '\'' || sb.charAt(bEnd) == '\"' ||
+ Character.isWhitespace(sb.charAt(bEnd)))) {
+ bEnd--;
+ }
+ bEnd++;
+
+ int propStart = bStart + start;
+ int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+
+ IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
+ return region;
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPForBeanIdHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLLinkHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPLinkHyperlinkPartitioner extends XMLLinkHyperlinkPartitioner {
+ public static final String JSP_LINK_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_LINK"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.text.ext.hyperlink.XMLLinkHyperlinkPartitioner#getPartitionType()
+ */
+ protected String getPartitionType() {
+ return JSP_LINK_PARTITION;
+ }
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ return true;
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPLinkHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLLinkHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPRelativeLinkHyperlinkPartitioner extends XMLLinkHyperlinkPartitioner {
+ public static final String JSP_RELATIVE_LINK_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_RELATIVE_LINK"; //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.common.text.ext.hyperlink.XMLLinkHyperlinkPartitioner#getPartitionType()
+ */
+ protected String getPartitionType() {
+ return JSP_RELATIVE_LINK_PARTITION;
+ }
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ return true;
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRelativeLinkHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+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.IHyperlinkPartitionRecognizer;
+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.jboss.tools.jst.web.tld.ITaglibMapping;
+import org.jboss.tools.jst.web.tld.WebProjectFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * @author Jeremy
+ */
+public class JSPRootHyperlinkPartitioner extends AbstractHyperlinkPartitioner implements
IHyperlinkPartitionRecognizer {
+ public static final String JSP_ROOT_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_ROOT"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ if (!recognize(document, superRegion)) return null;
+
+ String axis = computeAxis(document, superRegion.getOffset()) + "/";
//$NON-NLS-1$
+ String contentType = superRegion.getContentType();
+ String type = JSP_ROOT_PARTITION;
+ int length = superRegion.getLength();
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ }
+
+ public static String computeAxis(IDocument document, int offset) {
+ String axis = ""; //$NON-NLS-1$
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+ Map trackersMap = getTrackersMap(document, offset);
+
+ IFile file = smw.getFile();
+ XModel xModel = AbstractHyperlink.getXModel(file);
+ ITaglibMapping tm = xModel == null ? null :
WebProjectFactory.instance.getWebProject(xModel).getTaglibMapping();
+
+ if (n != null) {
+ if ((n instanceof Element || n instanceof Attr) &&
+ n.getNodeName() != null && n.getNodeName().length() > 0) {
+
+ String name = n.getNodeName();
+
+ // The node name extraction must be done by taking into account 'jsfc'
attribute value
+ if (n instanceof Element) {
+ Element e = (Element)n;
+ String jsfcAttrValue = e.getAttribute("jsfc"); //$NON-NLS-1$
+ if (jsfcAttrValue != null && jsfcAttrValue.trim().length() > 0) {
+ name = jsfcAttrValue;
+ }
+ }
+
+ String nodeName = extractName(name, trackersMap, tm);
+ axis = "/" + nodeName; //$NON-NLS-1$
+ }
+ Node parent = (n instanceof Attr)? ((Attr)n).getOwnerElement() : n.getParentNode();
+ while (parent instanceof Element) {
+ // Get the axis part depending on the type and name of node
+ String name = parent.getNodeName();
+
+ // The node name extraction must be done by taking into account 'jsfc'
attribute value
+ if (parent instanceof Element) {
+ Element e = (Element)parent;
+ String jsfcAttrValue = e.getAttribute("jsfc"); //$NON-NLS-1$
+ if (jsfcAttrValue != null && jsfcAttrValue.trim().length() > 0) {
+ name = jsfcAttrValue;
+ }
+ }
+
+ String nodeName = extractName(name, trackersMap, tm);
+ if (nodeName != null && nodeName.length() > 0)
+ axis = "/" + nodeName + axis; //$NON-NLS-1$
+ parent = parent.getParentNode();
+ }
+ }
+ } finally {
+ smw.dispose();
+ }
+
+ if (axis == null || axis.length() == 0) axis = ""; //$NON-NLS-1$
+ return axis;
+ }
+
+ public static String extractName (String name, Map trackersMap, ITaglibMapping tm) {
+ if (trackersMap == null || trackersMap.size() == 0) return name;
+ if (name == null) return null;
+ int column = name.indexOf(":"); //$NON-NLS-1$
+ if (column == -1) return name;
+ String prefix = name.substring(0, column);
+ if (prefix == null || prefix.trim().length() == 0) return name;
+
+ String uri = (String)trackersMap.get(prefix);
+ if (uri == null || uri.length() == 0) return name;
+
+ String resolvedUri = (tm == null ? uri : tm.resolveURI(uri));
+
+ return "[" + resolvedUri + "]" + name.substring(column);
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static Map getTrackersMap(IDocument document, int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+
+ List trackers = (manager == null? null : manager.getCMDocumentTrackers(offset));
+
+ Map<String,String> map = new HashMap<String,String>();
+ // Find F tracker
+// TaglibTracker fTT = null;
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ String prefix = tt.getPrefix();
+ String uri = tt.getURI();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+ map.put(prefix.trim(), uri.trim());
+ }
+ }
+ map = addAlternativeTrackersMap(map, document, offset);
+
+ return map;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ // DONE: alternative trackers map (for use along with xhtml documents)
+ public static Map<String,String>
addAlternativeTrackersMap(Map<String,String> map, IDocument document, int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ if (map == null) map = new HashMap<String,String>();
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+ while (n != null) {
+ if (!(n instanceof Element)) {
+ if (n instanceof Attr) {
+ n = ((Attr)n).getOwnerElement();
+ } else {
+ n = n.getParentNode();
+ }
+ continue;
+ }
+
+ NamedNodeMap attrs = n.getAttributes();
+ for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
+ Attr a = (Attr)attrs.item(j);
+ String name = a.getName();
+ if (name.startsWith("xmlns:")) { //$NON-NLS-1$
+ String uri = a.getValue();
+ String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
+ map.put(prefix.trim(), uri.trim());
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return map;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+
+ if (n == null) return false;
+
+ return true;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPRootHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+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.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+
+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.IHyperlinkPartitionRecognizer;
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPStylesheetRelLinkHyperlinkPartitioner extends
AbstractHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
+ public static final String JSP_STYLESHEET_REL_LINK_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_STYLESHEET_REL_LINK"; //$NON-NLS-1$
+
+ private static final String LINK_TAGNAME = "link"; //$NON-NLS-1$
+ private static final String REL_ATTRNAME = "rel"; //$NON-NLS-1$
+ private static final String VALID_REL_ATTRVALUE = "stylesheet"; //$NON-NLS-1$
+ private static final String HREF_ATTRNAME = "href"; //$NON-NLS-1$
+
+ private static final String IMPORT_DIRECTIVENAME = "@import"; //$NON-NLS-1$
+ private static final String URL_METHODSTART = "url("; //$NON-NLS-1$
+ private static final String URL_METHODEND = ")"; //$NON-NLS-1$
+ private static final String URL_METHODEND_2 = ";"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ if(superRegion == null) return null;
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+// if (!recognize(document, superRegion)) return null;
+ IRegion r = getRegion(document, superRegion.getOffset());
+ if (r == null) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_STYLESHEET_REL_LINK_PARTITION;
+ int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if(region == null) return false;
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+
+ Attr attr = null;
+ Node tag = null;
+ Text styleText = null;
+
+ if (n instanceof Attr) {
+ attr = (Attr)n;
+ tag = ((Attr)n).getOwnerElement();
+ } else if (n instanceof Element) {
+ tag = n;
+ } else if (n instanceof Text) {
+ styleText = (Text)n;
+ } else
+ return false;
+
+
+ if (attr != null || tag != null) {
+ // do recognize link tag
+ if (!LINK_TAGNAME.equalsIgnoreCase(tag.getNodeName()))
+ return false;
+
+ String linkRel = Utils.getAttributeValue(document, tag, REL_ATTRNAME);
+ if (!VALID_REL_ATTRVALUE.equalsIgnoreCase(linkRel))
+ return false;
+
+ return true;
+ }
+
+ if (styleText == null) return false;
+
+ // do recognize style text
+ int start = Utils.getValueStart(styleText);
+ int current = region.getOffset();
+
+ String text = styleText.getData();
+ if (text == null || text.length() == 0) return false;
+
+ text = text.toLowerCase();
+
+ int importStart = text.lastIndexOf(IMPORT_DIRECTIVENAME.toLowerCase(), current -
start);
+ if (importStart == -1)
+ return false;
+
+ int urlMethodStart = text.indexOf(URL_METHODSTART.toLowerCase(), importStart);
+ if (urlMethodStart == -1)
+ return false;
+
+ int urlMethodEnd = text.indexOf(URL_METHODEND.toLowerCase(), urlMethodStart);
+ if (urlMethodEnd == -1)
+ return false;
+
+ int urlMethodEnd2 = text.indexOf(URL_METHODEND_2.toLowerCase(), urlMethodEnd);
+ if (urlMethodEnd2 == -1)
+ return false;
+
+ if (current < start + urlMethodStart + URL_METHODSTART.length() ||
+ current >= start + urlMethodEnd)
+ return false;
+
+ return true;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+ protected IRegion getRegion (IDocument document, int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+
+ if (n == null || !(n instanceof Text || n instanceof Attr)) return null;
+
+ String text = null;
+ int bStart = 0;
+ int bEnd = 0;
+
+ if (n instanceof Text) {
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+
+ if (start < 0 || start > offset) return null;
+
+ text = document.get(start, end - start);
+ bStart = offset - start;
+ bEnd = offset - start;
+ } else if (n instanceof Attr) {
+ Attr attr = (Attr)n;
+ if (!HREF_ATTRNAME.equalsIgnoreCase(attr.getName())) return null;
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if(start < 0) return null;
+
+ text = document.get(start, end - start);
+ bStart = offset - start;
+ bEnd = offset - start;
+ }
+ StringBuffer sb = new StringBuffer(text);
+ //find start of bean property
+ while (bStart >= 0) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
+ sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/'
&&
+ sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-'
&&
+ sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_'
&&
+ sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?'
&&
+ sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=')
{
+ bStart++;
+ break;
+ }
+
+ if (bStart == 0) break;
+ bStart--;
+ }
+ // find end of bean property
+ while (bEnd >= 0 && bEnd < sb.length()) {
+ if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
+ sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/'
&&
+ sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-'
&&
+ sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_'
&&
+ sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?'
&&
+ sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
+ break;
+ }
+ bEnd++;
+ }
+
+ final int propStart = bStart + Utils.getValueStart(n);
+ final int propLength = bEnd - bStart;
+
+ if (propStart > offset || propStart + propLength < offset) return null;
+ return new Region(propStart,propLength);
+ } catch (BadLocationException x) {
+ //ignore
+ return null;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPStylesheetRelLinkHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPTagAttributeHyperlinkPartitioner extends
JSPElementAttributeValueHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
+ public static final String JSP_TAG_ATTRIBUTE_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_TAG_ATTRIBUTE"; //$NON-NLS-1$
+
+ private static final String JSP_ATTRIBUTE_TAGNAME = "jsp:attribute";
//$NON-NLS-1$
+ private static final String JSP_ELEMENT_TAGNAME = "jsp:element";
//$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (!(n instanceof Element)) return null;
+
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if(start < 0) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_TAG_ATTRIBUTE_PARTITION;
+ int length = end - start - (superRegion.getOffset() - start);
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if(region == null) return false;
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (!(n instanceof Element)) return false;
+ return (JSP_ATTRIBUTE_TAGNAME.equals(n.getNodeName()) &&
+ !JSP_ELEMENT_TAGNAME.equals(n.getParentNode().getNodeName()) &&
+ n.getNodeName().indexOf(':') != -1);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeValueHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeValueHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeValueHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import
org.jboss.tools.common.text.ext.hyperlink.xml.XMLTagAttributeValueHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public abstract class JSPTagAttributeValueHyperlinkPartitioner extends
XMLTagAttributeValueHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTagAttributeValueHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.FindObjectHelper;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.tld.ITaglibMapping;
+import org.jboss.tools.jst.web.tld.IWebProject;
+import org.jboss.tools.jst.web.tld.WebProjectFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * @author Jeremy
+ */
+public class JSPTaglibHyperlink extends AbstractHyperlink {
+
+ /**
+ * @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
+ */
+ protected void doHyperlink(IRegion region) {
+ XModelObject object = getFilename(region);
+ if(object != null)
+ FindObjectHelper.findModelObject(object, FindObjectHelper.IN_EDITOR_ONLY);
+ else {
+ openFileFailed();
+ }
+
+ }
+
+ protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
+ */
+ protected void openFileInEditor(String fileString) {
+ if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
+ fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
+ IEditorInput jarEditorInput = createEditorInput(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
+ } else {
+ super.openFileInEditor(fileString);
+ }
+ }
+
+ private XModelObject getFilename(IRegion region) {
+ IFile file = getFile();
+ XModel xModel = getXModel(file);
+ if (xModel == null) return null;
+
+ String uri = getTaglibUri(region);
+ if (uri == null) return null;
+
+ IWebProject wp = WebProjectFactory.instance.getWebProject(xModel);
+ if (wp == null) return null;
+
+ ITaglibMapping tm = wp.getTaglibMapping();
+ if (tm == null) return null;
+
+ return tm.getTaglibObject(uri);
+ }
+
+ private String getTaglibUri(IRegion region) {
+ IStructuredModel model = null;
+ try {
+ model = getModelManager().getExistingModelForRead(getDocument());
+ IDOMDocument xmlDocument = (model instanceof IDOMModel) ? ((IDOMModel)
model).getDocument() : null;
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (n instanceof IDOMAttr) n = ((IDOMAttr)n).getOwnerElement();
+ if (!(n instanceof IDOMElement)) return null;
+ if(!"jsp:directive.taglib".equals(n.getNodeName())) return null;
//$NON-NLS-1$
+
+ IDOMElement taglib = (IDOMElement)n;
+
+ String uri = taglib.getAttribute("uri"); //$NON-NLS-1$
+ if (uri == null || uri.trim().length() == 0) return null;
+
+ return uri;
+ } finally {
+ if (model != null) model.releaseFromRead();
+ }
+ }
+
+ IRegion fLastRegion = null;
+ /*
+ * (non-Javadoc)
+ *
+ * @seecom.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ fLastRegion = getRegion(offset);
+ return fLastRegion;
+ }
+
+ private IRegion getRegion(int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (!(n instanceof IDOMElement)) return null;
+ if (!"jsp:directive.taglib".equals(n.getNodeName())) return null;
//$NON-NLS-1$
+
+ IDOMElement taglib = (IDOMElement)n;
+
+ final int taglibLength = taglib.getEndOffset() - taglib.getStartOffset();
+ final int taglibOffset = taglib.getStartOffset();
+
+ return new Region(taglibOffset,taglibLength);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String uri = getTaglibUri(fLastRegion);
+ if (uri == null)
+ return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
+
+ return MessageFormat.format(Messages.OpenTagLibraryForUri, uri);
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
+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;
+
+/**
+ * @author Jeremy
+ */
+public class JSPTaglibHyperlinkPartitioner extends
JSPElementAttributeValueHyperlinkPartitioner implements IHyperlinkPartitionRecognizer {
+ public static final String JSP_TAGLIB_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_TAGLIB"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ if(document == null || superRegion == null) return null;
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (!(n instanceof Element)) return null;
+ if (!"jsp:directive.taglib".equals(n.getNodeName())) return null;
//$NON-NLS-1$
+
+ int start = Utils.getValueStart(n);
+ int end = Utils.getValueEnd(n);
+ if(start < 0) return null;
+
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_TAGLIB_PARTITION;
+ int length = end - start - (superRegion.getOffset() - start);
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if(document == null || region == null) return false;
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
+ try {
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
+ if (!(n instanceof Element)) return false;
+ return ("jsp:directive.taglib".equals(n.getNodeName())); //$NON-NLS-1$
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTaglibHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTextHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTextHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTextHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xml.XMLTextHyperlinkPartitioner;
+
+/**
+ * @author Jeremy
+ */
+public class JSPTextHyperlinkPartitioner extends XMLTextHyperlinkPartitioner {
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPTextHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.FindObjectHelper;
+import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.tld.ITaglibMapping;
+import org.jboss.tools.jst.web.tld.IWebProject;
+import org.jboss.tools.jst.web.tld.WebProjectFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Jeremy
+ */
+public class JSPXmlNsHyperlink extends AbstractHyperlink {
+
+ /**
+ * @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
+ */
+ protected void doHyperlink(IRegion region) {
+ XModelObject object = getFilename(region);
+ if(object != null) FindObjectHelper.findModelObject(object,
FindObjectHelper.IN_EDITOR_ONLY);
+ else {
+ openFileFailed();
+ }
+ }
+
+ protected final String JAR_FILE_PROTOCOL = "jar:file:/";//$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlink#openFileInEditor(java.lang.String)
+ */
+ protected void openFileInEditor(String fileString) {
+ if (fileString.startsWith(JAR_FILE_PROTOCOL)) {
+ fileString = fileString.substring(JAR_FILE_PROTOCOL.length());
+ IEditorInput jarEditorInput = createEditorInput(fileString);
+ IEditorPart part = openFileInEditor(jarEditorInput, fileString);
+ if (part == null) openFileFailed();
+ } else {
+ super.openFileInEditor(fileString);
+ }
+ }
+
+ private XModelObject getFilename(IRegion region) {
+ IFile file = getFile();
+ XModel xModel = getXModel(file);
+ if (xModel == null) return null;
+
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof IDOMAttr)) return null;
+ Attr xmlnsAttr = (Attr)n;
+ if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
+ Element rootElem = (Element)xmlnsAttr.getOwnerElement();
+ if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return null; //$NON-NLS-1$
//$NON-NLS-2$
+
+ String uri = xmlnsAttr.getValue();
+ if (uri == null || uri.trim().length() == 0) return null;
+
+ IWebProject wp = WebProjectFactory.instance.getWebProject(xModel);
+ if (wp == null) return null;
+
+ ITaglibMapping tm = wp.getTaglibMapping();
+ if (tm == null) return null;
+ return tm.getTaglibObject(uri);
+ } finally {
+ smw.dispose();
+ }
+ }
+
+ private String getUri(IRegion region) {
+ IFile file = getFile();
+ XModel xModel = getXModel(file);
+ if (xModel == null) return null;
+
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof IDOMAttr)) return null;
+ Attr xmlnsAttr = (Attr)n;
+ if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
+ Element rootElem = (Element)xmlnsAttr.getOwnerElement();
+ if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return null; //$NON-NLS-1$
//$NON-NLS-2$
+
+ String uri = xmlnsAttr.getValue();
+ if (uri == null || uri.trim().length() == 0) return null;
+
+ return uri;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+
+ IRegion fLastRegion = null;
+ /**
+ * @seecom.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
+ */
+ protected IRegion doGetHyperlinkRegion(int offset) {
+ fLastRegion = getRegion(offset);
+ return fLastRegion;
+ }
+
+ private IRegion getRegion(int offset) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(getDocument());
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
+ if (!(n instanceof IDOMAttr)) return null;
+ IDOMAttr xmlnsAttr = (IDOMAttr)n;
+ if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
+ Element rootElem = xmlnsAttr.getOwnerElement();
+ if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return null; //$NON-NLS-1$
//$NON-NLS-2$
+
+ final int taglibLength = xmlnsAttr.getValueRegionText().length();
+ final int taglibOffset = xmlnsAttr.getValueRegionStartOffset();
+
+ return new Region(taglibOffset,taglibLength);
+ } finally {
+ smw.dispose();
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String uri = getUri(fLastRegion);
+ if (uri == null)
+ return MessageFormat.format(Messages.NotFound, "URI"); //$NON-NLS-1$
+
+ return MessageFormat.format(Messages.Open, uri);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.hyperlink.jsp;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+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.IHyperlinkPartitionRecognizer;
+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.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Jeremy
+ */
+public class JSPXmlNsHyperlinkPartitioner extends AbstractHyperlinkPartitioner implements
IHyperlinkPartitionRecognizer {
+ public static final String JSP_XMLNS_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_XMLNS"; //$NON-NLS-1$
+
+ /**
+ * @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return null;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
+ if (!(n instanceof IDOMAttr)) return null;
+ IDOMAttr xmlnsAttr = (IDOMAttr)n;
+ if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return null; //$NON-NLS-1$
+ Element rootElem = xmlnsAttr.getOwnerElement();
+ if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return null; //$NON-NLS-1$
//$NON-NLS-2$
+ String xmlns = xmlnsAttr.getValueRegionText();
+ String axis = getAxis(document, superRegion);
+ String contentType = superRegion.getContentType();
+ String type = JSP_XMLNS_PARTITION;
+ int length = xmlns.length() - (superRegion.getOffset() -
xmlnsAttr.getValueRegionStartOffset());
+ int offset = superRegion.getOffset();
+
+ IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
+ return region;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+
+ /**
+ * @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
+ */
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ StructuredModelWrapper smw = new StructuredModelWrapper();
+ try {
+ smw.init(document);
+ Document xmlDocument = smw.getDocument();
+ if (xmlDocument == null) return false;
+
+ Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ if (!(n instanceof Attr)) return false;
+ Attr xmlnsAttr = (Attr)n;
+ if (xmlnsAttr.getName() == null ||
!xmlnsAttr.getName().startsWith("xmlns:")) return false; //$NON-NLS-1$
+ Element rootElem = xmlnsAttr.getOwnerElement();
+ if (!(rootElem.getNodeName().equals("jsp:root") ||
rootElem.getNodeName().equalsIgnoreCase("html"))) return false; //$NON-NLS-1$
//$NON-NLS-2$
+ return true;
+ } finally {
+ smw.dispose();
+ }
+ }
+
+
+ protected String getAxis(IDocument document, IHyperlinkRegion superRegion) {
+ if (superRegion.getAxis() == null || superRegion.getAxis().length() == 0) {
+ return JSPRootHyperlinkPartitioner.computeAxis(document, superRegion.getOffset()) +
"/"; //$NON-NLS-1$
+ }
+ return superRegion.getAxis();
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/jsp/JSPXmlNsHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/CSSTextScanner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/CSSTextScanner.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/CSSTextScanner.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.util;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.jboss.tools.common.text.ext.util.TextScanner;
+
+/**
+ * @author Jeremy
+ *
+ */
+public class CSSTextScanner extends TextScanner {
+ public static final String CSS_CLASS_NAME = "___css_class_name";
//$NON-NLS-1$
+ public static final String CSS_CLASS_NAME_SEPARATOR =
"___css_class_name_separator"; //$NON-NLS-1$
+ public static final String CSS_CLASS_BODY = "___css_class_body";
//$NON-NLS-1$
+ public static final String CSS_CLASS_COMMENT = "___css_class_comment";
//$NON-NLS-1$
+
+ private static final int STATE_START = 0;
+ private static final int STATE_NAME = 1;
+ private static final int STATE_NAME_SEPARATOR = 2;
+ private static final int STATE_BODY = 3;
+ private static final int STATE_COMMENT = 4;
+ private static final int STATE_END = 5;
+
+ private int state;
+ private int savedForCommentState;
+
+ /**
+ * @param stream
+ */
+ public CSSTextScanner(InputStream stream) {
+ super(stream);
+ this.state = STATE_START;
+ }
+ /**
+ * @param reader
+ */
+ public CSSTextScanner(Reader reader) {
+ super(reader);
+ this.state = STATE_START;
+ }
+
+ private void setState(int newState) {
+ if (this.state != STATE_COMMENT)
+ this.savedForCommentState = this.state;
+ this.state = newState;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.jsf.text.ext.util.TextScanner#nextToken()
+ */
+ public IToken nextToken() {
+ offset += length;
+ switch (state) {
+ case STATE_START:
+ case STATE_NAME_SEPARATOR:
+ return nextNameSeparatorToken();
+ case STATE_NAME:
+ return nextNameToken();
+ case STATE_BODY:
+ return nextBodyToken();
+ case STATE_COMMENT:
+ return nextCommentToken();
+ }
+ return nextEndToken();
+ }
+
+ private IToken nextNameToken() {
+ // Check first one char in the stream
+ int ch = read();
+ if (ch == ICharacterScanner.EOF) {
+ return getToken(CSS_CLASS_NAME);
+ }
+ if (!NMTOKEN_DETECTOR.isWordStart((char)ch)) {
+ // Emulate END of text
+ clearText();
+ return getToken(CSS_CLASS_NAME);
+ }
+
+ ch = read();
+ int readsCount = 0;
+ while (ch != ICharacterScanner.EOF) {
+ if (!NMTOKEN_DETECTOR.isWordPart((char)ch)) {
+ unread();
+ state = STATE_NAME_SEPARATOR;
+ return getToken(CSS_CLASS_NAME);
+ }
+ readsCount++;
+ ch = read();
+ }
+ return getToken(CSS_CLASS_NAME);
+ }
+
+ private IToken nextNameSeparatorToken() {
+ int count = skipWhitespaceToken();
+ if (count > 0) {
+ state = STATE_NAME_SEPARATOR;
+ return getToken(null);
+ }
+ int ch = read();
+ int readsCount = 0;
+ while (ch != ICharacterScanner.EOF) {
+ if (NMTOKEN_DETECTOR.isWordStart((char)ch)) {
+ unread();
+ state = STATE_NAME;
+ return (readsCount > 0 ? getToken(CSS_CLASS_NAME_SEPARATOR) : nextNameToken());
+ }
+ if (ch == '{') {
+ unread();
+ state = STATE_BODY;
+ return (readsCount > 0 ? getToken(CSS_CLASS_NAME_SEPARATOR) : nextBodyToken());
+ }
+ if (ch == '/') {
+ ch = read();
+ if (ch == ICharacterScanner.EOF) {
+ break;
+ }
+ if (ch == '*') {
+ // Comment openning
+ unread(); // Unread '*'-char
+ unread(); // Unread '/'-char
+ setState(STATE_COMMENT);
+ if (readsCount > 0) {
+ return getToken(CSS_CLASS_NAME_SEPARATOR);
+ } else {
+ return nextCommentToken();
+ }
+ }
+ // Broken file ??? Emulate END of text
+ clearText();
+ return getToken(CSS_CLASS_NAME_SEPARATOR);
+ }
+ readsCount++;
+ ch = read();
+ }
+ state = STATE_END;
+ return getToken(CSS_CLASS_NAME_SEPARATOR);
+ }
+
+ private IToken nextBodyToken() {
+ int level = 0;
+ int ch = read();
+ while (ch != ICharacterScanner.EOF) {
+ if (ch == '{') {
+ level++;
+ } else if (ch == '}') {
+ level--;
+ if (level <= 0) {
+ state = STATE_START;
+ return getToken(CSS_CLASS_BODY);
+ }
+ }
+ if (ch == '/') {
+ ch = read();
+ if (ch == ICharacterScanner.EOF) {
+ break;
+ }
+ if (ch == '*') {
+ // Comment openning
+ unread(); // Unread '*'-char
+ unread(); // Unread '/'-char
+ setState(STATE_COMMENT);
+ return getToken(CSS_CLASS_BODY);
+ }
+ // Broken file ??? Emulate END of text
+ clearText();
+ return getToken(CSS_CLASS_BODY);
+ }
+ ch = read();
+ }
+ state = STATE_END;
+ return getToken(CSS_CLASS_BODY);
+ }
+
+ private IToken nextCommentToken() {
+ int ch = read();
+ while (ch != ICharacterScanner.EOF) {
+ if (ch == '*') {
+ ch = read();
+ if (ch == ICharacterScanner.EOF) break;
+ if (ch == '/') {
+ // Comment closing
+ setState(savedForCommentState);
+ return getToken(CSS_CLASS_COMMENT);
+ }
+ unread(); // Unread last char
+ }
+ ch = read();
+ }
+ setState(savedForCommentState);
+ return getToken(CSS_CLASS_COMMENT);
+ }
+
+ private IToken nextEndToken () {
+ state = STATE_END;
+ // Emulate END of text
+ clearText();
+ return getToken(null);
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/CSSTextScanner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/TaglibManagerWrapper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/TaglibManagerWrapper.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/TaglibManagerWrapper.java 2009-09-25
15:01:55 UTC (rev 17747)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.text.ext.util;
+
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+
+public class TaglibManagerWrapper {
+ TLDCMDocumentManager manager;
+ List trackers;
+
+ public TaglibManagerWrapper() {}
+
+ public void init(IDocument document, int offset) {
+ manager = TaglibController.getTLDCMDocumentManager(document);
+ if(exists()) {
+ trackers = manager.getCMDocumentTrackers(offset);
+ }
+ }
+
+ public boolean exists() {
+ return manager != null;
+ }
+
+ public String getUri(String prefix) {
+ for (int i = 0; i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ if (prefix.equals(tt.getPrefix())) {
+ return tt.getURI();
+ }
+ }
+ return null;
+ }
+
+ public String getPrefix(String uri) {
+ for (int i = 0; i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ if (uri.equals(tt.getURI())) {
+ return tt.getPrefix();
+ }
+ }
+ return null;
+ }
+
+ public String getCorePrefix() {
+ return
getPrefix("http://java.sun.com/jsf/core"); //$NON-NLS-1$
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/util/TaglibManagerWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain