Author: vrubezhny
Date: 2009-06-24 18:10:23 -0400 (Wed, 24 Jun 2009)
New Revision: 16195
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
Log:
JBIDE-4362: OpenOn doesn't work for #text nodes for feceleted pages.
Issue is fixed
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2009-06-24 21:24:26 UTC (rev
16194)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2009-06-24 22:10:23 UTC (rev
16195)
@@ -900,6 +900,10 @@
<contentType id="org.eclipse.jst.jsp.core.jspsource">
<partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
</contentType>
+ </hyperlinkPartitioner>
+ <hyperlinkPartitioner
+
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JsfJSPBundleHyperlinkPartitioner"
+
class="org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPBundleHyperlinkPartitioner">
<contentType id="org.eclipse.wst.html.core.htmlsource">
<partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
</contentType>
@@ -1115,6 +1119,10 @@
<contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
</contenttypeidentifier>
+ </hyperlink>
+ <hyperlink
+ class="org.jboss.tools.jsf.text.ext.hyperlink.JsfBundleHyperlink"
+ id="org.jboss.tools.common.text.ext.jsf.hyperlink.JsfBundleHyperlink">
<contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
</contenttypeidentifier>
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java 2009-06-24
22:10:23 UTC (rev 16195)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.text.ext.hyperlink;
+
+import org.eclipse.jface.text.IRegion;
+
+/**
+ *
+ * @author Jeremy
+ *
+ */
+public class JsfBundleHyperlink extends BundleHyperlink {
+
+ @Override
+ protected String[] getLoadBundleTagPrefixes(IRegion region) {
+ return JsfJSPBundleHyperlinkPartitioner.getLoadBundleTagPrefixes(getDocument(),
region);
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java 2009-06-24
22:10:23 UTC (rev 16195)
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.text.ext.hyperlink;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+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.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author Jeremy
+ *
+ */
+public class JsfJSPBundleHyperlinkPartitioner extends JSPBundleHyperlinkPartitioner {
+
+ private static final String JSF_CORE_URI = "http://java.sun.com/jsf/core";
+
+ protected String[] getLoadBundleTagPrefixes(IDocument document, int offset) {
+ return getLoadBundleTagPrefixes(document, new Region(offset, 0));
+ }
+
+ static String[] getLoadBundleTagPrefixes(IDocument document, IRegion region) {
+ Map<String, Set<String>> namespaces = getNameSpaces(document,
region.getOffset());
+
+ if (namespaces == null)
+ return null;
+
+ Set<String> prefixes = namespaces.get(JSF_CORE_URI);
+ if (prefixes == null)
+ return null;
+
+ return prefixes.toArray(new String[prefixes.size()]);
+ }
+
+ static Map<String, Set<String>> getNameSpaces(IDocument document, int
offset) {
+ IStructuredModel sModel = StructuredModelManager
+ .getModelManager()
+ .getExistingModelForRead(document);
+
+ try {
+ if (sModel == null)
+ return null;
+
+ Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ if (xmlDocument == null)
+ return null;
+
+ Map<String, Set<String>> namespaces = new
HashMap<String,Set<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:")) {
+ final String prefix = name.substring("xmlns:".length());
+ final String uri = a.getValue();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ Set<String> prefixes = namespaces.get(uri.trim());
+ if (prefixes == null) {
+ prefixes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ namespaces.put(uri.trim(), prefixes);
+ }
+ prefixes.add(prefix.trim());
+ }
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return namespaces;
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain