Author: vrubezhny
Date: 2009-10-16 12:35:27 -0400 (Fri, 16 Oct 2009)
New Revision: 18136
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
Log:
JBIDE-816: Resource bundle completion don't work in template clients
JBIDE-3563: Code assist for "class" and "styleClass" attributes for
html and jsf tags.
The schema for included pages contexts is added (The schema is needed to create the
contexts for all the pages included into the source. It allows to get an information on
bundles declared in included pages as well as some other info that will be useful to
calculate proposals on CSS-classes)
The included pages context are created and the following information is collected within
the included contexts:
- namespaces declared within the included pages
- tag labraries used in the included pages
- resource bundles declared within the included pages
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-10-16 16:15:52
UTC (rev 18135)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.facelets/plugin.xml 2009-10-16 16:35:27
UTC (rev 18136)
@@ -108,4 +108,18 @@
</contentType>
</hyperlinkPartitioner>
</extension>
+
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include
uri="http://java.sun.com/jsf/facelets">
+ <tag name="composition">
+ <attribute name="template" />
+ </tag>
+ <tag name="decorate">
+ <attribute name="template" />
+ </tag>
+ <tag name="include">
+ <attribute name="page" />
+ </tag>
+ </include>
+ </extension>
</plugin>
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-10-16
16:15:52 UTC (rev 18135)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-10-16
16:35:27 UTC (rev 18136)
@@ -344,4 +344,11 @@
</hyperlink>
</extension>
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include
uri="http://richfaces.org/a4j">
+ <tag name="include">
+ <attribute name="viewId" />
+ </tag>
+ </include>
+ </extension>
</plugin>
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-16 16:15:52 UTC
(rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-10-16 16:35:27 UTC
(rev 18136)
@@ -48,6 +48,7 @@
org.eclipse.core.databinding,
org.eclipse.jface.databinding,
org.jboss.tools.jst.web.kb,
- org.eclipse.core.databinding.property;bundle-version="1.2.0"
+ org.eclipse.core.databinding.property;bundle-version="1.2.0",
+ org.eclipse.emf.ecore;bundle-version="2.5.0"
Bundle-Version: 2.0.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -23,6 +23,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
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.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
@@ -30,6 +31,7 @@
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.jboss.tools.jst.web.kb.internal.FaceletPageContextImpl;
@@ -75,9 +77,8 @@
context.setLibraries(getTagLibraries(context));
context.setResourceBundles(super.getResourceBundles(context));
-// IFaceletPageContext getParentContext();
-// Map<String, String> getParams();
-
+ PageContextFactory.createIncludedContexts(context);
+
return context;
}
@@ -141,7 +142,7 @@
start = domElement.getStartOffset();
length = (domElement.hasEndTag() ?
domElement.getEndStructuredDocumentRegion().getEnd() :
- domElement.getLength());
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -10,12 +10,21 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.eclipse.core.internal.resources.ICoreConstants;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -24,10 +33,14 @@
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.xml.core.internal.document.NodeContainer;
+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.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
@@ -44,11 +57,15 @@
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
@@ -72,6 +89,17 @@
protected ELContext createContextInstance() {
return new JspContextImpl();
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor#createContext()
+ */
+ @Override
+ protected IPageContext createContext() {
+ IPageContext context = super.createContext();
+ PageContextFactory.createIncludedContexts(context);
+ return context;
+ }
/**
* Collects the namespaces over the JSP-page and sets them up to the context specified.
@@ -81,46 +109,24 @@
protected void setNameSpaces(XmlContextImpl context) {
super.setNameSpaces(context);
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(getDocument());
- try {
- if (sModel == null)
- return;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ?
- ((IDOMModel) sModel).getDocument() :
- null;
-
- if (xmlDocument == null)
- return;
-
- TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(getDocument());
- List trackers = (manager == null? null : manager.getCMDocumentTrackers(getOffset()));
- for (int i = 0; trackers != null && i < trackers.size(); i++) {
- TaglibTracker tt = (TaglibTracker)trackers.get(i);
- final String prefix = tt.getPrefix();
- final String uri = tt.getURI();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- IRegion region = new Region(0, getDocument().getLength());
- INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
- context.addNameSpace(region, nameSpace);
- }
+ TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(getDocument());
+ List trackers = (manager == null? null : manager.getCMDocumentTrackers(getOffset()));
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ final String prefix = tt.getPrefix();
+ final String uri = tt.getURI();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ IRegion region = new Region(0, getDocument().getLength());
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
}
-
- return;
}
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
+ return;
+ }
-
/**
* Returns the resource bundles
*
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -11,13 +11,16 @@
package org.jboss.tools.jst.jsp.contentassist;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables.User;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
@@ -25,6 +28,7 @@
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
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.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
@@ -37,8 +41,11 @@
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
+import org.jboss.tools.jst.web.kb.include.IncludeContextDefinition;
import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -49,6 +56,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
*
@@ -81,10 +89,11 @@
setNameSpaces(context);
context.setLibraries(getTagLibraries(context));
context.setResourceBundles(getResourceBundles(context));
-
return context;
}
+
+
protected void setVars(ELContextImpl context, IFile file) {
// No vars can be set for this processor
}
@@ -505,7 +514,7 @@
start = domElement.getStartOffset();
length = (domElement.hasEndTag() ?
domElement.getEndStructuredDocumentRegion().getEnd() :
- domElement.getLength());
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-16 16:15:52
UTC (rev 18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/META-INF/MANIFEST.MF 2009-10-16 16:35:27
UTC (rev 18136)
@@ -12,6 +12,12 @@
org.jboss.tools.common.el.core,
org.eclipse.jface.text,
org.eclipse.wst.sse.core,
+ org.eclipse.wst.sse.ui,
+ org.eclipse.jst.jsp.core,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.common.modulecore,
+ org.jboss.tools.common.text.ext,
+ org.eclipse.emf.ecore,
org.eclipse.wst.xml.ui,
org.eclipse.jdt.ui,
org.eclipse.wst.validation,
@@ -23,6 +29,7 @@
Export-Package: org.jboss.tools.jst.web.kb,
org.jboss.tools.jst.web.kb.action,
org.jboss.tools.jst.web.kb.el,
+ org.jboss.tools.jst.web.kb.include,
org.jboss.tools.jst.web.kb.internal,
org.jboss.tools.jst.web.kb.internal.scanner,
org.jboss.tools.jst.web.kb.internal.taglib,
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-16 16:15:52 UTC (rev
18135)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/plugin.xml 2009-10-16 16:35:27 UTC (rev
18136)
@@ -2,8 +2,9 @@
<?eclipse version="3.0"?>
<plugin>
<extension-point id="tagLib" name="Kb Custom Tag Lib"
schema="schema/tagLib.exsd"/>
+ <extension-point id="KbIncludeContext" name="Kb Include Context
Buillder" schema="schema/include.exsd" />
<extension-point id="validator" name="KB Validator"
schema="schema/validator.exsd"/>
-
+
<extension
id="kbbuilder"
name="KB Builder"
@@ -69,7 +70,26 @@
<component-extension
location="taglibs/componentExtension.xml"/>
</extension>
+
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include uri="jsp">
+ <tag name="directive.include">
+ <attribute name="file" />
+ </tag>
+ <tag name="include">
+ <attribute name="page" />
+ </tag>
+ </include>
+ <contexttype id="JSP_PAGE_CONTEXT_TYPE">
+ <contenttype id="org.eclipse.jst.jsp.core.jspsource" />
+ </contexttype>
+
+ <contexttype id="FACELETS_PAGE_CONTEXT_TYPE">
+ <contenttype id="org.eclipse.wst.html.core.htmlsource" />
+ </contexttype>
+ </extension>
+
<extension id="kbproblemmarker" name="%KBProblemName"
point="org.eclipse.core.resources.markers">
<super type="org.eclipse.core.resources.problemmarker">
</super>
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
(rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd 2009-10-16 16:35:27
UTC (rev 18136)
@@ -0,0 +1,205 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.jst.web.kb"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.jst.web.kb"
id="KbIncludeContext" name="KbIncludeContext"/>
+ </appInfo>
+ <documentation>
+ The extension point allows the application to define URIs, tags and Attributes
that allow the part of code to be included into the page content.
+
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ <documentation>
+ Defines an extension point for the Include definitions.
+
+ This extension point is used to add information on which tags/tag attributes are
used to include a source into a JSP/XHTML page
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="include" minOccurs="0"
maxOccurs="unbounded"/>
+ <element ref="contexttype" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+ A unique ID for this extension point. It is recommended that the
plugin ID be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ A unique ID for this extension. It is recommended that the plugin ID
be used to prefix any extensions.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ A brief name to show to the user.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="include">
+ <annotation>
+ <documentation>
+ Defines a include item.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="tag" minOccurs="0"
maxOccurs="unbounded"/>
+ <element ref="attribute" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="uri" type="string"
use="required">
+ <annotation>
+ <documentation>
+ An URI for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="tag">
+ <annotation>
+ <documentation>
+ Defines a tag item. Contains information on tags that have the
'include-to-page-content' possibility.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="attribute" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="string"
use="required">
+ <annotation>
+ <documentation>
+ A Tag Name.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="attribute">
+ <annotation>
+ <documentation>
+ Defines an attribute item. Contains information on attributes that have the
'include-to-page-content' possibility.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="name" type="string"
use="required">
+ <annotation>
+ <documentation>
+ A Tag Attribute Name.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contexttype">
+ <annotation>
+ <documentation>
+ Defines a contexttype item.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="contenttype" minOccurs="0"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+ An ID for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="contenttype">
+ <annotation>
+ <documentation>
+ Defines a contenttype item. Contains information on contenttype that is
supported by a surrounding context type.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+ An ID for this element.
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ V3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <pre>
+ <extension-point id="KbInclude" name="Kb Include
Context Buillder" />
+
+ <extension
point="org.jboss.tools.jst.web.kb.KbInclude">
+ <include
uri="http://java.sun.com/jsf/core">
+ <tag name="jsp.include">
+ <attribute name="file" />
+ </tag>
+ </include>
+ </extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The baseline for API and extension point stability is RedHat Developer Studio
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The supplied implementation of the include context functionality requires the
WTP components.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ RedHat
+ </documentation>
+ </annotation>
+
+</schema>
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/schema/include.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -0,0 +1,25 @@
+package org.jboss.tools.jst.web.kb;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+
+public interface IIncludedContextSupport {
+ void addIncludedContext(IPageContext includedContext);
+ List<IPageContext> getIncludedContexts();
+
+ /**
+ * Returns Resource of the page
+ * @return
+ */
+ IFile getResource();
+
+ /**
+ * Returns map of name spaces which are set in particular offset.
+ * Key is URI of name space.
+ * @return
+ */
+ Map<String, List<INameSpace>> getNameSpaces(int offset);
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IIncludedContextSupport.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/IPageContext.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -23,7 +23,7 @@
* Page context
* @author Alexey Kazakov
*/
-public interface IPageContext extends ELContext {
+public interface IPageContext extends ELContext, IIncludedContextSupport {
/**
* Returns libraries which should be used in this context
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -10,24 +10,86 @@
******************************************************************************/
package org.jboss.tools.jst.web.kb;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.internal.resources.ICoreConstants;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+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.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.wst.common.componentcore.internal.ComponentResource;
+import org.eclipse.wst.common.componentcore.internal.StructureEdit;
+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.xml.core.internal.document.NodeContainer;
+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.el.core.GlobalELReferenceList;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.web.kb.include.IncludeContextBuilder;
+import org.jboss.tools.jst.web.kb.internal.FaceletPageContextImpl;
import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
+import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
+import org.jboss.tools.jst.web.kb.internal.XmlContextImpl;
+import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
+import org.jboss.tools.jst.web.kb.taglib.CustomTagLibManager;
+import org.jboss.tools.jst.web.kb.taglib.INameSpace;
+import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
+import org.jboss.tools.jst.web.kb.taglib.TagLibriryManager;
+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;
+import org.w3c.dom.NodeList;
+import org.eclipse.ui.part.FileEditorInput;
/**
* @author Alexey Kazakov
*/
public class PageContextFactory {
+ public static String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
+ public static String FACELETS_PAGE_CONTEXT_TYPE =
"FACELETS_PAGE_CONTEXT_TYPE";
+
/**
- * Creates a page context for given resource and offset.
- * @param file JSP or Facelet
- * @param offset
- * @return
+ * Creates a page context for the specified context type
+ * @
*/
- public static IPageContext createPageContext(IFile file, int offset) {
- // TODO
+ public static IPageContext createPageContext(IFile file, int offset, String contentType)
{
+ String contextType = IncludeContextBuilder.getInstance().getContextType(contentType);
+ if (JSP_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return createJSPContext(file, offset);
+ }
+ else if (FACELETS_PAGE_CONTEXT_TYPE.equals(contextType)) {
+ return createFaceletPageContext(file, offset);
+ }
return null;
}
@@ -37,37 +99,720 @@
* @param offset
* @return
*/
- public static IPageContext createJSPContext(IFile file, int offset) {
+ private static IPageContext createJSPContext(IFile file, int offset) {
JspContextImpl context = new JspContextImpl();
-// context.s
- // TODO
- return null;
+
+
+ IEditorInput input = new FileEditorInput(file);
+ try {
+ ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ context.setResource(file);
+ context.setDocument(getConnectedDocument(input));
+ context.setElResolvers(elResolvers);
+
+ setXMLNameSpaces(context, offset);
+ setJSPNameSpaces(context, offset);
+ context.setLibraries(getTagLibraries(context, offset));
+ context.setResourceBundles(getResourceBundles(context));
+ createIncludedContexts(context);
+ } finally {
+ releaseConnectedDocument(input);
+ context.setDocument(null);
+ }
+ return context;
}
/**
- * Creates a jsp context for given resource, document and offset.
- * @param file JSP
+ * Creates a facelet context for given resource and offset.
+ * @param file Facelet
* @param offset
- * @param document
* @return
*/
- public static IPageContext createJSPContext(IFile file, IDocument document, int offset)
{
- JspContextImpl context = new JspContextImpl();
- context.setDocument(document);
- context.setElResolvers(ELResolverFactoryManager.getInstance().getResolvers(file));
-// context.s
- // TODO
- return null;
+ private static IFaceletPageContext createFaceletPageContext(IFile file, int offset) {
+ FaceletPageContextImpl context = new FaceletPageContextImpl();
+
+ IEditorInput input = new FileEditorInput(file);
+ try {
+ ELResolver[] elResolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
+ context.setResource(file);
+ context.setDocument(getConnectedDocument(input));
+ context.setElResolvers(elResolvers);
+
+ setXMLNameSpaces(context, offset);
+ setFaceletsNameSpaces(context, offset);
+ context.setLibraries(getTagLibraries(context, offset));
+ context.setResourceBundles(getResourceBundles(context));
+
+ PageContextFactory.createIncludedContexts(context);
+ } finally {
+ releaseConnectedDocument(input);
+ context.setDocument(null);
+ }
+ return context;
+
}
+
+ /* Utility functions */
+
+ public static void createIncludedContexts(IPageContext context) {
+ if (!(context instanceof IIncludedContextSupport))
+ return;
+
+ IStructuredModel sModel = StructuredModelManager.getModelManager()
+ .getExistingModelForRead(context.getDocument());
+ try {
+ if (sModel == null)
+ return;
+
+ Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ if (xmlDocument == null)
+ return;
+
+ if (xmlDocument instanceof IDOMNode) {
+ createIncludedContextForNode((IDOMNode)xmlDocument,
(IIncludedContextSupport)context);
+ }
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ }
+
+ private static void createIncludedContextForNode(IDOMNode node, IIncludedContextSupport
context) {
+ String prefix = node.getPrefix() == null ? "" : node.getPrefix();
//$NON-NLS-1$
+ String tagName = node.getLocalName();
+ if (node instanceof IDOMElement) {
+ Map<String, List<INameSpace>> nsMap =
context.getNameSpaces(node.getStartOffset());
+ String[] uris = getUrisByPrefix(nsMap, prefix);
+
+ if (uris != null) {
+ for (String uri : uris) {
+ String[] includeAttributes = IncludeContextBuilder.getIncludeAttributes(uri,
tagName);
+ if (includeAttributes != null) {
+ for (String attr : includeAttributes) {
+ createIncludedContextFromAttribute((IDOMElement)node, attr, context);
+ }
+ }
+ }
+ }
+ }
+
+ NodeList children = node.getChildNodes();
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ if (children.item(i) instanceof IDOMElement) {
+ createIncludedContextForNode((IDOMElement)children.item(i), context);
+ }
+ }
+ }
+
+ private static void createIncludedContextFromAttribute(IDOMElement node, String
attribute, IIncludedContextSupport context) {
+ String fileName = node.getAttribute(attribute);
+ if (fileName == null || fileName.trim().length() == 0)
+ return;
+
+ IFile file = getFileFromProject(fileName, context.getResource());
+ if (file == null)
+ return;
+
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ?
+ ((IDOMModel) sModel).getDocument() : null;
+
+ if (xmlDocument == null)
+ return;
+
+ if (xmlDocument instanceof IDOMNode) {
+ String contentType = sModel.getContentTypeIdentifier();
+ IPageContext includedContext = PageContextFactory.createPageContext(file, ((IDOMNode)
xmlDocument).getEndOffset() - 1, contentType);
+ context.addIncludedContext(includedContext);
+ }
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
+ static Node findNodeForOffset(IDOMNode node, int offset) {
+ if(node == null) return null;
+ if (!node.contains(offset)) return null;
+
+ if (node.hasChildNodes()) {
+ // Try to find the node in children
+ NodeList children = node.getChildNodes();
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ IDOMNode child = (IDOMNode)children.item(i);
+ if (child.contains(offset)) {
+ return findNodeForOffset(child, offset);
+ }
+ }
+ }
+ // Not found in children or nave no children
+ if (node.hasAttributes()) {
+ // Try to find in the node attributes
+ NamedNodeMap attributes = node.getAttributes();
+
+ for (int i = 0; attributes != null && i < attributes.getLength(); i++) {
+ IDOMNode attr = (IDOMNode)attributes.item(i);
+ if (attr.contains(offset)) {
+ return attr;
+ }
+ }
+ }
+ // Return the node itself
+ return node;
+ }
+
+ static Node findNodeForOffset(Node node, int offset) {
+ return (node instanceof IDOMNode) ? findNodeForOffset((IDOMNode)node, offset) : null;
+ }
+
+ private static IDocument getConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ try {
+ provider.connect(input);
+ } catch (CoreException e) {
+ // Ignore. The provider probably will return null in this case
+ }
+ return provider.getDocument(input);
+ }
+
+ private static void releaseConnectedDocument(IEditorInput input) {
+ IDocumentProvider provider=
DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ provider.disconnect(input);
+ }
+
+
+ private static Document getDocument(IFile file) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(file);
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return null;
+
+ try {
+ return (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
/**
- * Creates a facelet context for given resource and offset.
- * @param file Facelet
- * @param offset
+ * Collects the namespaces over the XML-page and sets them up to the context specified.
+ *
+ * @param context
+ */
+ private static void setXMLNameSpaces(XmlContextImpl context, int offset) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
+ .getDocument()
+ : null;
+
+ if (xmlDocument == null)
+ return;
+
+ Node n = 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$
+ final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
+ final String uri = a.getValue();
+ if (prefix != null && prefix.trim().length() > 0
+ && uri != null && uri.trim().length() > 0) {
+
+ int start = ((IndexedRegion) n).getStartOffset();
+ int length = ((IndexedRegion) n).getLength();
+
+ IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement) n
+ : null);
+ if (domElement != null) {
+ start = domElement.getStartOffset();
+ length = (domElement.hasEndTag() ? domElement
+ .getEndStructuredDocumentRegion()
+ .getEnd() : ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
+ }
+
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(uri.trim(),
+ prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return;
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ }
+
+ /**
+ * Collects the namespaces over the JSP-page and sets them up to the context specified.
+ *
+ * @param context
+ */
+ private static void setJSPNameSpaces(JspContextImpl context, int offset) {
+ TLDCMDocumentManager manager =
TaglibController.getTLDCMDocumentManager(context.getDocument());
+ List trackers = (manager == null? null : manager.getCMDocumentTrackers(offset));
+ for (int i = 0; trackers != null && i < trackers.size(); i++) {
+ TaglibTracker tt = (TaglibTracker)trackers.get(i);
+ final String prefix = tt.getPrefix();
+ final String uri = tt.getURI();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ IRegion region = new Region(0, context.getDocument().getLength());
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * Collects the namespaces over the Facelets-page and sets them up to the context
specified.
+ *
+ * @param context
+ */
+ private static void setFaceletsNameSpaces(FaceletPageContextImpl context, int offset) {
+ IStructuredModel sModel = null;
+
+ try {
+ sModel = StructuredModelManager.getModelManager()
+ .getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // Ignore. The sModel will be set to null
+ } catch (CoreException e) {
+ // Ignore. The sModel will be set to null
+ }
+
+ if (sModel == null)
+ return;
+
+
+ try {
+ Document xmlDocument = (sModel instanceof IDOMModel) ?
+ ((IDOMModel) sModel).getDocument() : null;
+
+ if (xmlDocument == null)
+ return;
+
+ Node n = 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$
+ final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
+ final String uri = a.getValue();
+ if (prefix != null && prefix.trim().length() > 0 &&
+ uri != null && uri.trim().length() > 0) {
+
+ int start = ((IndexedRegion)n).getStartOffset();
+ int length = ((IndexedRegion)n).getLength();
+
+ IDOMElement domElement = (n instanceof IDOMElement ? (IDOMElement)n : null);
+ if (domElement != null) {
+ start = domElement.getStartOffset();
+ length = (domElement.hasEndTag() ?
+ domElement.getEndStructuredDocumentRegion().getEnd() :
+ ((IDOMNode) xmlDocument).getEndOffset() - 1 - start);
+
+ }
+
+ Region region = new Region(start, length);
+ INameSpace nameSpace = new NameSpace(uri.trim(), prefix.trim());
+ context.addNameSpace(region, nameSpace);
+ if (CustomTagLibManager.FACELETS_UI_TAG_LIB_URI.equals(uri)) {
+ nameSpace = new NameSpace(CustomTagLibManager.FACELETS_HTML_TAG_LIB_URI,
""); //$NON-NLS-1$
+ context.addNameSpace(region, nameSpace);
+ }
+ }
+ }
+ }
+
+ n = n.getParentNode();
+ }
+
+ return;
+ } finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+ }
+
+
+ private static final ITagLibrary[] EMPTY_LIBRARIES = new ITagLibrary[0];
+ private static final IResourceBundle[] EMPTY_RESOURCE_BUNDLES = new IResourceBundle[0];
+
+ /**
+ * Returns the Tag Libraries for the namespaces collected in the context.
+ * Important: The context must be created using createContext() method before using this
method.
+ *
+ * @param context The context object instance
* @return
*/
- public static IFaceletPageContext createFaceletPageContext(IFile file, int offset) {
- // TODO
+ public static ITagLibrary[] getTagLibraries(IPageContext context, int offset) {
+ Map<String, List<INameSpace>> nameSpaces = context.getNameSpaces(offset);
+ if (nameSpaces == null || nameSpaces.isEmpty())
+ return EMPTY_LIBRARIES;
+
+ IProject project = context.getResource() == null ? null :
context.getResource().getProject();
+ if (project == null)
+ return EMPTY_LIBRARIES;
+
+ List<ITagLibrary> tagLibraries = new ArrayList<ITagLibrary>();
+ for (List<INameSpace> nameSpace : nameSpaces.values()) {
+ for (INameSpace n : nameSpace) {
+ ITagLibrary[] libs = TagLibriryManager.getLibraries(project, n.getURI());
+ if (libs != null && libs.length > 0) {
+ for (ITagLibrary lib : libs) {
+ tagLibraries.add(lib);
+ }
+ }
+ }
+ }
+ return (tagLibraries.isEmpty() ? EMPTY_LIBRARIES :
+ (ITagLibrary[])tagLibraries.toArray(new ITagLibrary[tagLibraries.size()]));
+ }
+
+ /**
+ * Returns the resource bundles
+ *
+ * @return
+ */
+ private static IResourceBundle[] getResourceBundles(IPageContext context) {
+ List<IResourceBundle> list = new ArrayList<IResourceBundle>();
+ IStructuredModel sModel = null;
+
+ try {
+ sModel =
StructuredModelManager.getModelManager().getModelForRead(context.getResource());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (sModel == null)
+ return new IResourceBundle[0];
+ try {
+ Document dom = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() :
null;
+ if (dom != null) {
+ Element element = dom.getDocumentElement();
+ NodeList children = (NodeContainer)dom.getChildNodes();
+ if (element != null) {
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ IDOMNode xmlnode = (IDOMNode)children.item(i);
+ update((IDOMNode)xmlnode, context, list);
+ }
+ }
+ }
+ }
+ finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ return list.toArray(new IResourceBundle[list.size()]);
+ }
+
+ private static void update(IDOMNode element, IPageContext context,
List<IResourceBundle> list) {
+ if (element != null) {
+ registerBundleForNode(element, context, list);
+ for (Node child = element.getFirstChild(); child != null; child =
child.getNextSibling()) {
+ if (child instanceof IDOMNode) {
+ update((IDOMNode)child, context, list);
+ }
+ }
+ }
+ }
+ private static void registerBundleForNode(IDOMNode node, IPageContext context,
List<IResourceBundle> list) {
+ if (node == null) return;
+ String name = node.getNodeName();
+ if (name == null) return;
+ if (!name.endsWith("loadBundle")) return; //$NON-NLS-1$
+ if (name.indexOf(':') == -1) return;
+ String prefix = name.substring(0, name.indexOf(':'));
+
+ Map<String, List<INameSpace>> ns =
context.getNameSpaces(node.getStartOffset());
+ if (!containsPrefix(ns, prefix)) return;
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes == null) return;
+ String basename = (attributes.getNamedItem("basename") == null ? null :
attributes.getNamedItem("basename").getNodeValue()); //$NON-NLS-1$
//$NON-NLS-2$
+ String var = (attributes.getNamedItem("var") == null ? null :
attributes.getNamedItem("var").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
+ if (basename == null || basename.length() == 0 ||
+ var == null || var.length() == 0) return;
+
+ list.add(new ResourceBundle(basename, var));
+ }
+
+ private static boolean containsPrefix(Map<String, List<INameSpace>> ns,
String prefix) {
+ for (List<INameSpace> n: ns.values()) {
+ for (INameSpace nameSpace : n) {
+ if(prefix.equals(nameSpace.getPrefix())) return true;
+ }
+ }
+ return false;
+ }
+
+
+ /**
+ * Searches the namespace map and returns all the URIs for the specified prefix
+ *
+ * @param nsMap
+ * @param prefix
+ * @return
+ */
+ public static String[] getUrisByPrefix(Map<String, List<INameSpace>> nsMap,
String prefix) {
+ if(nsMap == null || nsMap.isEmpty())
+ return null;
+ Set<String> uris = new HashSet<String>();
+ for (List<INameSpace> nsList : nsMap.values()) {
+ for (INameSpace ns : nsList) {
+ if (prefix.equals(ns.getPrefix())) {
+ uris.add(ns.getURI());
+ }
+ }
+ }
+
+ return uris.isEmpty() ? new String[] {prefix} : (String[])uris.toArray(new
String[uris.size()]);
+ }
+
+ /**
+ * Searches the file with the name specified
+ *
+ * @param fileName
+ * @param documentFile
+ * @return
+ */
+ public static IFile getFileFromProject(String fileName, IFile documentFile) {
+ if(documentFile == null || !documentFile.isAccessible()) return null;
+
+ fileName = findAndReplaceElVariable(fileName);
+
+ IProject project = documentFile.getProject();
+ String name = Utils.trimFilePath(fileName);
+ IPath currentPath = documentFile.getLocation()
+ .removeLastSegments(1);
+ IResource member = null;
+ StructureEdit se = StructureEdit.getStructureEditForRead(project);
+ if (se == null) {
+ return null;
+ }
+ WorkbenchComponent[] modules = se.getWorkbenchModules();
+ for (int i = 0; i < modules.length; i++) {
+ if (name.startsWith("/")) { //$NON-NLS-1$
+ member = findFileByAbsolutePath(project, modules[i], name);
+ } else {
+ member = findFileByRelativePath(project, modules[i],
+ currentPath, name);
+ if (member == null && name.length() > 0) {
+ // in some cases path having no leading "/" is
+ // nevertheless absolute
+ member = findFileByAbsolutePath(project, modules[i],
+ "/" + name); //$NON-NLS-1$
+ }
+ }
+ if (member != null && (member instanceof IFile)) {
+ if (((IFile) member).exists())
+ return (IFile) member;
+ }
+ }
return null;
}
+
+ private static IFile findFileByRelativePath(IProject project,
+ WorkbenchComponent module, IPath basePath, String path) {
+
+ if (path == null || path.trim().length() == 0)
+ return null;
+
+ path = findAndReplaceElVariable(path);
+
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0); //$NON-NLS-1$
+ IPath projectPath = project.getLocation();
+ IFile member = null;
+
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
+
+ // Look in source environment
+ IPath webRootPath = projectPath.append(sourcePath);
+ IPath relativePath = Utils.getRelativePath(webRootPath,
+ basePath);
+ IPath filePath = relativePath.append(path);
+ member = project.getFolder(sourcePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
+ }
+
+ // Look in runtime environment
+ if (runtimePath.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH - 1)
{
+ webRootPath = projectPath.append(runtimePath);
+ relativePath = Utils.getRelativePath(webRootPath, basePath);
+ filePath = relativePath.append(path);
+ member = project.getFolder(runtimePath).getFile(filePath);
+ if (member.exists()) {
+ return member;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static IFile findFileByAbsolutePath(IProject project,
+ WorkbenchComponent module, String path) {
+ ComponentResource[] resources = module.findResourcesBySourcePath(
+ new Path("/"), 0); //$NON-NLS-1$
+
+ path = findAndReplaceElVariable(path);
+
+ IFile member = null;
+
+ for (int i = 0; resources != null && i < resources.length; i++) {
+ IPath runtimePath = resources[i].getRuntimePath();
+ IPath sourcePath = resources[i].getSourcePath();
+
+ // Look in source environment
+ member = project.getFolder(sourcePath).getFile(path);
+ if(member.exists()) {
+ return member;
+ }
+
+ // Look in runtime environment
+ if (runtimePath.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH - 1)
{
+ member = project.getFolder(runtimePath).getFile(path);
+ if (member.exists()) {
+ return member;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static final String DOLLAR_PREFIX = "${"; //$NON-NLS-1$
+
+ private static final String SUFFIX = "}"; //$NON-NLS-1$
+
+ private static final String SHARP_PREFIX = "#{"; //$NON-NLS-1$
+
+ // partly copied from org.jboss.tools.vpe.editor.util.ElService
+ public static String findAndReplaceElVariable(String fileName){
+ final IPath workspacePath = Platform.getLocation();
+
+ final ResourceReference[] gResources =
GlobalELReferenceList.getInstance().getAllResources(workspacePath);
+ String result = fileName;
+
+ ResourceReference[] sortedReferences = sortReferencesByScope(gResources);
+
+ for (ResourceReference rf : sortedReferences) {
+ final String dollarEl = DOLLAR_PREFIX + rf.getLocation() + SUFFIX;
+ final String sharpEl = SHARP_PREFIX + rf.getLocation() + SUFFIX;
+
+ if (fileName.contains(dollarEl)) {
+ result = result.replace(dollarEl, rf.getProperties());
+ }
+ if (fileName.contains(sharpEl)) {
+ result = result.replace(sharpEl, rf.getProperties());
+ }
+ }
+ return result;
+ }
+
+ // copied from org.jboss.tools.vpe.editor.util.ElService
+ private static ResourceReference[] sortReferencesByScope(ResourceReference[] references)
{
+ ResourceReference[] sortedReferences = references.clone();
+
+ Arrays.sort(sortedReferences, new Comparator<ResourceReference>() {
+ public int compare(ResourceReference r1, ResourceReference r2) {
+ return r1.getScope() - r2.getScope();
+ }
+ });
+
+ return sortedReferences;
+ }
}
\ No newline at end of file
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -0,0 +1,226 @@
+package org.jboss.tools.jst.web.kb.include;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.internal.registry.RegistryReader;
+
+import org.jboss.tools.jst.web.kb.WebKbPlugin;
+
+public class IncludeContextBuilder extends RegistryReader {
+ // extension point ID
+ public static final String PL_INCLUDE = "KbIncludeContext"; //$NON-NLS-1$
+
+ public static final String TAG_INCLUDE = "include"; //$NON-NLS-1$
+ public static final String TAG_TAG = "tag"; //$NON-NLS-1$
+ public static final String TAG_ATTRIBUTE = "attribute"; //$NON-NLS-1$
+ public static final String TAG_CONTEXTTYPE = "contexttype"; //$NON-NLS-1$
+ public static final String TAG_CONTENTTYPE = "contenttype"; //$NON-NLS-1$
+
+ public static final String ATT_ID = "id"; //$NON-NLS-1$
+ public static final String ATT_URI = "uri"; //$NON-NLS-1$
+ public static final String ATT_NAME = "name"; //$NON-NLS-1$
+
+ protected String fTargetContributionElement;
+
+ private static IncludeContextBuilder fInstance;
+
+ private List<IncludeContextDefinition> fIncludeContextDefs = null;
+ private IncludeContextDefinition fCurrentIncludeDefinition = null;
+
+ /**
+ * returns singleton instance of HyperlinkBuilder
+ *
+ * @return HyperlinkBuilder
+ */
+ public synchronized static IncludeContextBuilder getInstance() {
+ if (fInstance == null) {
+ fInstance = new IncludeContextBuilder();
+ }
+ return fInstance;
+ }
+
+ /**
+ * Returns the name of the part ID attribute that is expected
+ * in the target extension.
+ *
+ * @param element
+ * @return String
+ */
+ public static String getId(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_ID);
+ return value;
+ }
+
+ public static String getUri(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_URI);
+ return value;
+ }
+
+ public static String getName(IConfigurationElement element) {
+ String value = element.getAttribute(ATT_NAME);
+ return value;
+ }
+
+ /**
+ * Processes element which should be a configuration element specifying an
+ * open on object. Creates a new open on definition object and adds it to the
+ * list of open on definition objects
+ *
+ * @param element hyperlink configuration element
+ */
+ private void processIncludeElement(IConfigurationElement element) {
+ String theUri = getUri(element);
+// String theResolver = getIncludeResolver(element);
+
+ theUri = theUri == null ? "" : theUri; //$NON-NLS-1$
+
+ // start building new HyperlinkDefinition
+ fCurrentIncludeDefinition = new IncludeContextDefinition(theUri, element);
+
+ // create a new list of open on definitions if it hasnt been created yet
+ if (fIncludeContextDefs == null) {
+ fIncludeContextDefs = new ArrayList<IncludeContextDefinition>();
+ }
+ fIncludeContextDefs.add(fCurrentIncludeDefinition);
+ }
+
+ private void processTagElement(IConfigurationElement element) {
+ String theName = getName(element);
+
+ if (fCurrentIncludeDefinition != null && theName != null) {
+ fCurrentIncludeDefinition.addTag(theName, element);
+ }
+ }
+
+ private void processAttributeElement(IConfigurationElement element) {
+ String theName = getName(element);
+
+ if (fCurrentIncludeDefinition != null && theName != null) {
+ fCurrentIncludeDefinition.addTagAttribute(theName, element);
+ }
+ }
+
+ private void processContextTypeElement(IConfigurationElement element) {
+ String theId = getId(element);
+
+ if (fCurrentIncludeDefinition != null && theId != null) {
+ fCurrentIncludeDefinition.addContextType(theId, element);
+ }
+ }
+
+ private boolean processContentTypeElement(IConfigurationElement element) {
+ String theId = getId(element);
+
+ if (fCurrentIncludeDefinition != null && theId != null) {
+ return fCurrentIncludeDefinition.addContentType(theId, element);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see
com.ibm.sse.editor.internal.extension.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ protected boolean readElement(IConfigurationElement element) {
+ String tag = element.getName();
+
+ if (tag.equals(fTargetContributionElement)) {
+ processIncludeElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on
definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_TAG)) {
+ processTagElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on
definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_ATTRIBUTE)) {
+ processAttributeElement(element);
+ return true;
+ }
+ else if (tag.equals(TAG_CONTEXTTYPE)) {
+ processContextTypeElement(element);
+
+ // make sure processing of current open on tag resulted in a current open on
definition
+ // before continue reading the children
+ if (fCurrentIncludeDefinition != null) {
+ readElementChildren(element);
+ }
+ return true;
+ }
+ else if (tag.equals(TAG_CONTENTTYPE)) {
+ return processContentTypeElement(element);
+ }
+
+ return false;
+ }
+
+ private void initCache() {
+ if (fIncludeContextDefs == null) {
+ readContributions(TAG_INCLUDE, PL_INCLUDE);
+ }
+ }
+
+
+ protected void readContributions(String element, String extensionPoint) {
+ fTargetContributionElement = element;
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ readRegistry(registry, WebKbPlugin.PLUGIN_ID, extensionPoint);
+ }
+
+ /**
+ * Returns all the open on definition objects
+ * @return
+ */
+ public List<IncludeContextDefinition> getIncludeContextDefinitions() {
+ initCache();
+ return fIncludeContextDefs;
+ }
+
+ public static String[] getIncludeAttributes(String uri, String tag) {
+ if (uri == null)
+ return null;
+
+ List<IncludeContextDefinition> defs =
IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ if (defs == null)
+ return null;
+
+ for (IncludeContextDefinition def : defs) {
+ if (uri.equals(def.getUri())) {
+ return def.getTagAttributes(tag);
+ }
+ }
+
+ return null;
+ }
+
+ public static String getContextType(String contentType) {
+ if (contentType == null)
+ return null;
+
+ List<IncludeContextDefinition> defs =
IncludeContextBuilder.getInstance().getIncludeContextDefinitions();
+ if (defs == null)
+ return null;
+
+ for (IncludeContextDefinition def : defs) {
+ String contextType = def.getContextType(contentType);
+ if (contextType != null)
+ return contextType;
+ }
+
+ return null;
+ }
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextBuilder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -0,0 +1,141 @@
+package org.jboss.tools.jst.web.kb.include;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.ui.internal.EarlyStartupRunnable;
+
+public class IncludeContextDefinition {
+ private IConfigurationElement fElement;
+ private String fUri;
+ private Map<String, Set<String>> fTags; // Map<TagName,
Set<AttributeName>>
+ private Map<IConfigurationElement, String> fTagConfigurationElements;
+ private Map<String, Set<String>> fContexts; // Map<ContextType,
Set<ContentType>>
+ private Map<IConfigurationElement, String> fContextConfigurationElements;
+
+ public IncludeContextDefinition(IConfigurationElement element) {
+ this.fElement = element;
+ }
+
+ public IncludeContextDefinition(String uri, IConfigurationElement element) {
+ this.fUri = uri;
+ this.fElement = element;
+ }
+
+ public String getUri() {
+ return fUri;
+ }
+
+ public void setUri(String uri) {
+ this.fUri = uri;
+ }
+
+ public void addTag(String tagName, IConfigurationElement element) {
+ if (fTags == null) {
+ fTags = new HashMap<String, Set<String>>();
+ }
+ Set<String> tagSet = fTags.get(tagName);
+ if (tagSet == null) {
+ tagSet = new HashSet<String>();
+ fTags.put(tagName, tagSet);
+ }
+
+ if (fTagConfigurationElements == null) {
+ fTagConfigurationElements = new HashMap<IConfigurationElement, String>();
+ }
+
+ fTagConfigurationElements.put(element, tagName);
+ }
+
+ public void addTagAttribute(String attributeName, IConfigurationElement element) {
+ IConfigurationElement parentTagElement = null;
+ if (element.getParent() instanceof IConfigurationElement) {
+ IConfigurationElement parentElement = (IConfigurationElement)element.getParent();
+ if (IncludeContextBuilder.TAG_TAG.equals(parentElement.getName())) {
+ parentTagElement = parentElement;
+ }
+ }
+
+ String parentTagName = null;
+ if (parentTagElement != null) {
+ parentTagName = IncludeContextBuilder.getName(parentTagElement);
+ }
+ parentTagName = parentTagName == null ? "" : parentTagName; //$NON-NLS-1$
+
+ if (fTags.get(parentTagName) == null) {
+ addTag(parentTagName, parentTagElement);
+ }
+
+ fTags.get(parentTagName).add(attributeName);
+ }
+
+ public void addContextType(String id, IConfigurationElement element) {
+ if (fContexts == null) {
+ fContexts = new HashMap<String, Set<String>>();
+ }
+ Set<String> contextSet = fContexts.get(id);
+ if (contextSet == null) {
+ contextSet = new HashSet<String>();
+ fContexts.put(id, contextSet);
+ }
+
+ if (fContextConfigurationElements == null) {
+ fContextConfigurationElements = new HashMap<IConfigurationElement, String>();
+ }
+
+ fContextConfigurationElements.put(element, id);
+ }
+
+ public boolean addContentType(String id, IConfigurationElement element) {
+ IConfigurationElement parentContextElement = null;
+ if (element.getParent() instanceof IConfigurationElement) {
+ IConfigurationElement parentElement = (IConfigurationElement)element.getParent();
+ if (IncludeContextBuilder.TAG_CONTEXTTYPE.equals(parentElement.getName())) {
+ parentContextElement = parentElement;
+ }
+ }
+
+ String parentContextId = null;
+ if (parentContextElement != null) {
+ parentContextId = IncludeContextBuilder.getId(parentContextElement);
+ }
+
+ if (fContexts.get(parentContextId) == null)
+ return false;
+
+ fContexts.get(parentContextId).add(id);
+ return true;
+ }
+
+ private static final String[] EMPTY_CHILDREN = new String[0];
+
+
+ public String[] getTags() {
+ return fTags == null ? EMPTY_CHILDREN :
+ (String[])fTags.keySet().toArray(new String[fTags.size()]);
+ }
+
+ public String[] getTagAttributes(String tagName) {
+ Set<String> attrSet = fTags.get(tagName);
+
+ return attrSet == null ? EMPTY_CHILDREN :
+ (String[])attrSet.toArray(new String[attrSet.size()]);
+ }
+
+ public String getContextType(String contentType) {
+ if (fContexts == null)
+ return null;
+
+ for (String contextType : fContexts.keySet()) {
+ if (fContexts.get(contextType).contains(contentType))
+ return contextType;
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/include/IncludeContextDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -11,9 +11,14 @@
package org.jboss.tools.jst.web.kb.internal;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -22,10 +27,24 @@
* @author Alexey Kazakov
*/
public class JspContextImpl extends XmlContextImpl {
+ protected List<IPageContext> fIncludedContexts = null;
@Override
+ public void addIncludedContext(IPageContext includedContext) {
+ if (fIncludedContexts == null) {
+ fIncludedContexts = new ArrayList<IPageContext>();
+ }
+ fIncludedContexts.add(includedContext);
+ }
+
+ @Override
+ public List<IPageContext> getIncludedContexts() {
+ return fIncludedContexts;
+ }
+
+ @Override
public Map<String, List<INameSpace>> getNameSpaces(int offset) {
Map<String, List<INameSpace>> superNameSpaces =
super.getNameSpaces(offset);
@@ -36,5 +55,4 @@
return superNameSpaces;
}
-
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-10-16
16:15:52 UTC (rev 18135)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/XmlContextImpl.java 2009-10-16
16:35:27 UTC (rev 18136)
@@ -8,7 +8,9 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.part.IPage;
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
+import org.jboss.tools.jst.web.kb.IIncludedContextSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
@@ -37,7 +39,26 @@
* @see org.jboss.tools.jst.web.kb.IPageContext#getResourceBundles()
*/
public IResourceBundle[] getResourceBundles() {
- return bundles;
+ List<IResourceBundle> resourceBundles = new ArrayList<IResourceBundle>();
+ if (bundles != null) {
+ for (IResourceBundle bundle : bundles) {
+ resourceBundles.add(bundle);
+ }
+ }
+
+ List<IPageContext> includedContexts = getIncludedContexts();
+ if (includedContexts != null) {
+ for (IPageContext includedContext : includedContexts) {
+ IResourceBundle[] includedBundles = includedContext.getResourceBundles();
+ if (includedBundles != null) {
+ for (IResourceBundle includedBundle : includedBundles) {
+ resourceBundles.add(includedBundle);
+ }
+ }
+ }
+ }
+
+ return (IResourceBundle[])resourceBundles.toArray(new
IResourceBundle[resourceBundles.size()]);
}
/**
@@ -104,7 +125,7 @@
return result;
}
- private INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String
prefix) {
+ public INameSpace findNameSpaceByPrefix(Set<INameSpace> namespaces, String prefix)
{
if (namespaces != null && prefix != null) {
for (INameSpace ns : namespaces) {
if (prefix.equals(ns.getPrefix())) {
@@ -127,4 +148,15 @@
}
nameSpaces.get(region).put(nameSpace.getURI(), nameSpace);
}
+
+ public void addIncludedContext(IPageContext includedContext) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public List<IPageContext> getIncludedContexts() {
+ return null;
+ }
+
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-10-16 16:15:52 UTC
(rev 18135)
+++ trunk/seam/plugins/org.jboss.tools.seam.text.ext/plugin.xml 2009-10-16 16:35:27 UTC
(rev 18136)
@@ -398,5 +398,12 @@
</extension>
+ <extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
+ <include
uri="http://jboss.com/products/seam/taglib">
+ <tag name="decorate">
+ <attribute name="template" />
+ </tag>
+ </include>
+ </extension>
</plugin>