summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbateman2013-04-24 19:25:32 (EDT)
committercbateman2013-04-24 19:25:32 (EDT)
commit82a0eeec84ef63a086b17ef33ff2284b5cbb99e9 (patch)
treeabde00b1d86e0f59c5abfafbb8eb056a59403702
parent9a17e8747d604fa586206148658d0508159ea54b (diff)
downloadwebtools.jsf-82a0eeec84ef63a086b17ef33ff2284b5cbb99e9.zip
webtools.jsf-82a0eeec84ef63a086b17ef33ff2284b5cbb99e9.tar.gz
webtools.jsf-82a0eeec84ef63a086b17ef33ff2284b5cbb99e9.tar.bz2
PMC approved patch for 406476.v201304241631
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IStructuredDocumentContextResolverFactory2.java15
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IXMLNodeContextResolver.java43
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/DOMBasedXMLNodeContextResolver.java101
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/StructuredDocumentContextResolverFactory.java78
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resolver/ViewBasedTaglibResolverFactory.java16
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java78
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java94
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeature2.java22
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java22
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/CSSClassType.java11
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java16
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java24
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/PathType.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/RelativePathType.java12
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ResourceBundleType.java11
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java70
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/attributevalues/TemplateWebPathType.java50
17 files changed, 536 insertions, 145 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IStructuredDocumentContextResolverFactory2.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IStructuredDocumentContextResolverFactory2.java
index 4244d33..a349ea5 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IStructuredDocumentContextResolverFactory2.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IStructuredDocumentContextResolverFactory2.java
@@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.jst.jsf.context.resolver.structureddocument.internal;
+import org.eclipse.jst.jsf.context.IModelContext;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
/**
@@ -39,10 +41,23 @@ public interface IStructuredDocumentContextResolverFactory2 extends
ITaglibContextResolver getTaglibContextResolverFromDelegates(IStructuredDocumentContext context);
/**
+ * @param context
+ * @return a more generic way of resolving workspace context through IModelContext. Allows for more flexible
+ * resolution through non-SSE models.
+ */
+ IWorkspaceContextResolver getWorkspaceContextResolver2(IModelContext context);
+
+ /**
* @param <T> resolver type
* @param context
* @param clazz
* @return resolver of type T
*/
<T> T getResolver(IStructuredDocumentContext context, Class<T> clazz);
+
+ /**
+ * @param context
+ * @return a resolver for xml nodes in a model context
+ */
+ IXMLNodeContextResolver getXMLNodeContextResolver(IModelContext context);
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IXMLNodeContextResolver.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IXMLNodeContextResolver.java
new file mode 100644
index 0000000..4e4ed7f
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/IXMLNodeContextResolver.java
@@ -0,0 +1,43 @@
+package org.eclipse.jst.jsf.context.resolver.structureddocument.internal;
+
+import org.eclipse.jst.jsf.context.IModelContext;
+
+
+/**
+ * A resolver that, like IDOMContextResolver, allows walking a DOM-like structure, but in this case we don't
+ * necessarily need a DOM.
+ *
+ */
+public interface IXMLNodeContextResolver
+{
+ /**
+ * @return the resolver for the parent node.
+ */
+ IXMLNodeContextResolver getParentNodeResolver();
+
+ /**
+ * @return true if this resolver's context is on an attribute
+ */
+ boolean isAttribute();
+
+ /**
+ * @return the value of the context if it is an attribute (attribute value) or null otherwise
+ */
+ String getValue();
+
+ /**
+ * @return the local name of the context if it is an attribute or element
+ */
+ String getLocalName();
+
+ /**
+ * @return the namespace of the element or null if the context is not on a uri
+ */
+ String getNamespaceURI();
+
+ /**
+ * Set the model context on the resolver. This is optional and depends on the resolver factory.
+ * @param context
+ */
+ void setContext(IModelContext context);
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/DOMBasedXMLNodeContextResolver.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/DOMBasedXMLNodeContextResolver.java
new file mode 100644
index 0000000..0e305dd
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/DOMBasedXMLNodeContextResolver.java
@@ -0,0 +1,101 @@
+package org.eclipse.jst.jsf.context.resolver.structureddocument.internal.impl;
+
+import org.eclipse.jst.jsf.context.IModelContext;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IXMLNodeContextResolver;
+import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
+import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory2;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * A default resolver based on the dom context resolver.
+ *
+ */
+public class DOMBasedXMLNodeContextResolver implements IXMLNodeContextResolver
+{
+ private IDOMContextResolver delegate;
+
+ /**
+ * @param delegate
+ */
+ public DOMBasedXMLNodeContextResolver(final IDOMContextResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public IXMLNodeContextResolver getParentNodeResolver()
+ {
+ Node node = this.delegate.getNode();
+ Element parentNode = null;
+ if (node instanceof Attr)
+ {
+ parentNode = ((Attr)node).getOwnerElement();
+ }
+ else if (node instanceof Element)
+ {
+ parentNode = (Element) ((Element)node).getParentNode();
+ }
+
+ if (parentNode != null)
+ {
+ IStructuredDocumentContext context = IStructuredDocumentContextFactory2.INSTANCE.getContext(parentNode);
+ if (context != null)
+ {
+ IDOMContextResolver domContextResolver = IStructuredDocumentContextResolverFactory2.INSTANCE.getDOMContextResolver(context);
+ if (domContextResolver != null)
+ {
+ return new DOMBasedXMLNodeContextResolver(domContextResolver);
+ }
+ }
+
+ }
+ return null;
+ }
+
+ public boolean isAttribute()
+ {
+ return this.delegate.getNode() instanceof Attr;
+ }
+
+ public String getValue()
+ {
+ Node node = this.delegate.getNode();
+ if (node instanceof Attr)
+ {
+ return ((Attr)node).getValue();
+ }
+ return null;
+ }
+
+ public String getLocalName()
+ {
+ Node node = this.delegate.getNode();
+ if (node instanceof Attr)
+ {
+ return ((Attr)node).getLocalName();
+ }
+ else if (node instanceof Element)
+ {
+ return ((Element)node).getLocalName();
+ }
+ return null;
+ }
+
+ public String getNamespaceURI()
+ {
+ Node node = this.delegate.getNode();
+ if (node != null)
+ {
+ return node.getNamespaceURI();
+ }
+ return null;
+ }
+
+ public void setContext(IModelContext context)
+ {
+ // ignore since this resolver is just delegating to a dom context.
+ }
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/StructuredDocumentContextResolverFactory.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/StructuredDocumentContextResolverFactory.java
index b05e6e6..9f05397 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/StructuredDocumentContextResolverFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/context/resolver/structureddocument/internal/impl/StructuredDocumentContextResolverFactory.java
@@ -17,6 +17,7 @@ import java.util.Iterator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jst.jsf.context.AbstractDelegatingFactory;
+import org.eclipse.jst.jsf.context.IModelContext;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IMetadataContextResolver;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
@@ -24,6 +25,7 @@ import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextRes
import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IXMLNodeContextResolver;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
@@ -177,6 +179,39 @@ IStructuredDocumentContextResolverFactory, IStructuredDocumentContextResolverFac
return resolver;
}
+
+ public IWorkspaceContextResolver getWorkspaceContextResolver2(IModelContext context)
+ {
+ IWorkspaceContextResolver resolver = delegateGetWorkspaceContextResolver2(context);
+
+ if (resolver != null)
+ {
+ return resolver;
+ }
+
+ if (context instanceof IStructuredDocumentContext)
+ {
+ return getWorkspaceContextResolver((IStructuredDocumentContext) context);
+ }
+
+ return null;
+ }
+
+ private IWorkspaceContextResolver delegateGetWorkspaceContextResolver2(IModelContext context)
+ {
+ Iterator<IAdaptable> it = getDelegatesIterator();
+ while (it.hasNext())
+ {
+ IAdaptable adapter = it.next();
+ final IStructuredDocumentContextResolverFactory2 delegateFactory = (IStructuredDocumentContextResolverFactory2) (adapter)
+ .getAdapter(IStructuredDocumentContextResolverFactory2.class);
+ final IWorkspaceContextResolver contextResolver = delegateFactory.getWorkspaceContextResolver2(context);
+
+ if (contextResolver != null) { return contextResolver; }
+ }
+
+ return null;
+ }
private IWorkspaceContextResolver internalGetWorkspaceContextResolver(
final IStructuredDocumentContext context)
@@ -342,4 +377,47 @@ IStructuredDocumentContextResolverFactory, IStructuredDocumentContextResolverFac
return null;
}
}
+
+ public IXMLNodeContextResolver getXMLNodeContextResolver(IModelContext context)
+ {
+ IXMLNodeContextResolver delegateGetXMLNodeResolver = delegateGetXMLNodeResolver(context);
+ if (delegateGetXMLNodeResolver != null)
+ {
+ return delegateGetXMLNodeResolver;
+ }
+
+ if (context instanceof IStructuredDocumentContext)
+ {
+ IDOMContextResolver domContextResolver = getDOMContextResolver((IStructuredDocumentContext) context);
+ return new DOMBasedXMLNodeContextResolver(domContextResolver);
+ }
+
+ return null;
+ }
+
+ private IXMLNodeContextResolver delegateGetXMLNodeResolver(
+ final IModelContext context)
+ {
+ Iterator<IAdaptable> it = getDelegatesIterator();
+ while (it.hasNext())
+ {
+ IAdaptable adapter = it.next();
+
+ final IStructuredDocumentContextResolverFactory delegateFactory = (IStructuredDocumentContextResolverFactory) adapter
+ .getAdapter(IStructuredDocumentContextResolverFactory.class);
+
+ if (delegateFactory instanceof IStructuredDocumentContextResolverFactory2)
+ {
+ final IXMLNodeContextResolver contextResolver = ((IStructuredDocumentContextResolverFactory2)delegateFactory)
+ .getXMLNodeContextResolver(context);
+
+ if (contextResolver != null)
+ {
+ return contextResolver;
+ }
+ }
+ }
+
+ return null;
+ }
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resolver/ViewBasedTaglibResolverFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resolver/ViewBasedTaglibResolverFactory.java
index bf75439..f51b0c0 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resolver/ViewBasedTaglibResolverFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/internal/resolver/ViewBasedTaglibResolverFactory.java
@@ -22,6 +22,7 @@ import org.eclipse.jst.jsf.context.resolver.structureddocument.ITaglibContextRes
import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IXMLNodeContextResolver;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.designtime.DTAppManagerUtil;
import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter;
@@ -248,4 +249,19 @@ IStructuredDocumentContextResolverFactory2, IAdaptable
return null;
}
+ public IWorkspaceContextResolver getWorkspaceContextResolver2(IModelContext context)
+ {
+ if (context instanceof IStructuredDocumentContext)
+ {
+ return getWorkspaceContextResolver((IStructuredDocumentContext) context);
+ }
+ return null;
+ }
+
+ public IXMLNodeContextResolver getXMLNodeContextResolver(IModelContext context)
+ {
+ // no xml node context resolver
+ return null;
+ }
+
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java
index b2f9848..7485d66 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/AbstractMetaDataEnabledFeature.java
@@ -28,18 +28,20 @@ import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper;
import org.eclipse.jst.jsf.common.metadata.query.internal.IMetaDataQuery;
import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryContextFactory;
import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
+import org.eclipse.jst.jsf.context.IModelContext;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues;
+import org.eclipse.jst.jsf.metadataprocessors.internal.IMetaDataEnabledFeature2;
/**
* Simple abstract class that implementers of {@link IMetaDataEnabledFeature} can subclass in the <b>TagLibDomain</b> of metadata
* <p><b>Provisional API - subject to change</b></p>*
*/
-public abstract class AbstractMetaDataEnabledFeature implements IMetaDataEnabledFeature{
+public abstract class AbstractMetaDataEnabledFeature implements IMetaDataEnabledFeature, IMetaDataEnabledFeature2{
private MetaDataContext mdContext;
- private IStructuredDocumentContext sdContext;
+ private IModelContext sdContext;
private IProject _project;
private IFile _file;
@@ -69,24 +71,55 @@ public abstract class AbstractMetaDataEnabledFeature implements IMetaDataEnabled
* @see org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature#getStructuredDocumentContext()
*/
public IStructuredDocumentContext getStructuredDocumentContext() {
- return sdContext;
+ if (sdContext instanceof IStructuredDocumentContext)
+ {
+ return (IStructuredDocumentContext) sdContext;
+ }
+ return null;
}
- private IProject getProject(){
- if (_project == null){
- _project = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(sdContext).getProject();
- }
- return _project;
+ /**
+ * @return the model context
+ */
+ public IModelContext getModelContext() {
+ return this.sdContext;
}
-
- private IFile getFile(){
- if (_file == null){
- IResource res = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(sdContext).getResource();
- if (res instanceof IFile)
- _file = (IFile)res;
- }
- return _file;
+
+ /**
+ * @param modelContext
+ */
+ public void setModelContext(IModelContext modelContext)
+ {
+ this.sdContext = modelContext;
}
+
+ /**
+ * @return the project
+ */
+ protected IProject getProject2()
+ {
+ if (_project == null)
+ {
+ _project = IStructuredDocumentContextResolverFactory2.INSTANCE.getWorkspaceContextResolver2(sdContext)
+ .getProject();
+ }
+ return _project;
+ }
+
+ /**
+ * @return the file
+ */
+ protected IFile getFile2()
+ {
+ if (_file == null)
+ {
+ IResource res = IStructuredDocumentContextResolverFactory2.INSTANCE.getWorkspaceContextResolver2(sdContext)
+ .getResource();
+ if (res instanceof IFile) _file = (IFile) res;
+ }
+ return _file;
+ }
+
//common metadata accessors
/**
* Return the single expected String value for a given property.
@@ -143,11 +176,18 @@ public abstract class AbstractMetaDataEnabledFeature implements IMetaDataEnabled
}
private IMetaDataDomainContext getMetaDataDomainContext() {
- final IFile file = getFile();
+ final IFile file = getFile2();
if (file != null)
+ {
return MetaDataQueryContextFactory.getInstance().createTaglibDomainModelContext(file);
+ }
- return MetaDataQueryContextFactory.getInstance().createTaglibDomainModelContext(getProject());
+ IProject project = getProject2();
+ if (project != null)
+ {
+ return MetaDataQueryContextFactory.getInstance().createTaglibDomainModelContext(project);
+ }
+ return null;
}
/**
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java
index 48e3a5a..b5e7227 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/MetaDataEnabledProcessingFactory.java
@@ -27,10 +27,12 @@ import org.eclipse.jst.jsf.common.metadata.internal.TraitValueHelper;
import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryContextFactory;
import org.eclipse.jst.jsf.common.metadata.query.internal.MetaDataQueryFactory;
import org.eclipse.jst.jsf.common.metadata.query.internal.taglib.ITaglibDomainMetaDataQuery;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
+import org.eclipse.jst.jsf.context.IModelContext;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
import org.eclipse.jst.jsf.metadataprocessors.internal.AttributeValueRuntimeTypeFactory;
+import org.eclipse.jst.jsf.metadataprocessors.internal.IMetaDataEnabledFeature2;
/**
* Singleton class that will produce <code>IMetaDataEnabledFeature</code>s
@@ -106,21 +108,49 @@ public final class MetaDataEnabledProcessingFactory {
}
- private IProject getProject(final IStructuredDocumentContext sdContext) {
+ /**
+ * @param featureType
+ * @param sdContext
+ * @param uri
+ * @param tagName
+ * @param attributeName
+ * @return the list of metadata enabled features
+ */
+ public List<IMetaDataEnabledFeature> getAttributeValueRuntimeTypeFeatureProcessors2(final Class featureType,
+ final IModelContext sdContext, final String uri, final String tagName,
+ final String attributeName)
+ {
+
+ String attrKey = tagName + "/" + attributeName; //$NON-NLS-1$
+
+ final IMetaDataDomainContext modelContext = getMetaDataDomainContext(sdContext);
+ final ITaglibDomainMetaDataQuery query = MetaDataQueryFactory.getInstance().createQuery(modelContext);
+
+ Entity attrEntity = query.getQueryHelper().getEntity(uri, attrKey);
+
+ if (attrEntity != null)
+ {
+ return getAttributeValueRuntimeTypeFeatureProcessors2(featureType, sdContext, attrEntity);
+ }
+ return Collections.EMPTY_LIST;
+
+ }
+
+ private IProject getProject(final IModelContext sdContext) {
IProject project = null;
if (sdContext != null) {
- final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(sdContext);
+ final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory2.INSTANCE
+ .getWorkspaceContextResolver2(sdContext);
project = resolver != null ? resolver.getProject() : null;
}
return project;
}
- private IFile getFile(final IStructuredDocumentContext sdContext) {
+ private IFile getFile(final IModelContext sdContext) {
IFile file = null;
if (sdContext != null) {
- final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(sdContext);
+ final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory2.INSTANCE
+ .getWorkspaceContextResolver2(sdContext);
final IResource res = resolver != null ? resolver.getResource() : null;
if (res instanceof IFile)
file = (IFile)res;
@@ -195,8 +225,56 @@ public final class MetaDataEnabledProcessingFactory {
return Collections.unmodifiableList(retList);
}
+ /**
+ * @param featureType
+ * @param sdContext
+ * @param attrEntity
+ * @return returns null - if the meta data was not found <br>
+ * returns empty list - if not a
+ * <code>IMetaDataEnabledFeature</code> processor or is not valid
+ * or does not support the specified feature
+ */
+ public List<IMetaDataEnabledFeature> getAttributeValueRuntimeTypeFeatureProcessors2(
+ final Class featureType, final IModelContext sdContext,
+ final Entity attrEntity) {
+
+ final IMetaDataDomainContext modelContext = getMetaDataDomainContext(sdContext);
+ final ITaglibDomainMetaDataQuery query = MetaDataQueryFactory.getInstance().createQuery(modelContext);
+
+ Trait trait = query.findTrait(attrEntity,
+ ATTRIBUTE_VALUE_RUNTIME_TYPE_PROP_NAME);
+
+ if (trait == null) {
+ return Collections.EMPTY_LIST;
+ }
+
+ List<IMetaDataEnabledFeature> retList = new ArrayList<IMetaDataEnabledFeature>(2);
+ String typeId = TraitValueHelper.getValueAsString(trait);
+
+ // get the implementing class for the type
+ ITypeDescriptor type = AttributeValueRuntimeTypeFactory.getInstance()
+ .getType(typeId);
+ if (type != null) {
+ MetaDataContext context = new MetaDataContext(attrEntity, trait);
+ // get all the feature adapters (IMetaDataEnabledFeature) for this
+ // type
+ List<IMetaDataEnabledFeature> featureAdapters = type.getFeatureAdapters(featureType);
+ for (int j = 0; j < featureAdapters.size(); j++) {
+ // set the context in the feature
+ featureAdapters.get(j).setMetaDataContext(context);
+ if (featureAdapters.get(j) instanceof IMetaDataEnabledFeature2)
+ {
+ ((IMetaDataEnabledFeature2)featureAdapters.get(j)).setModelContext(sdContext);
+ }
+ retList.add(featureAdapters.get(j));
+ }
+ }
+ // return list of IMetaDataEnabledFeatures for this type
+ return Collections.unmodifiableList(retList);
+ }
+
private IMetaDataDomainContext getMetaDataDomainContext(
- final IStructuredDocumentContext sdContext) {
+ final IModelContext sdContext) {
final IFile file = getFile(sdContext);
if (file != null)
return MetaDataQueryContextFactory.getInstance().createTaglibDomainModelContext(file);
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeature2.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeature2.java
new file mode 100644
index 0000000..ad84e1a
--- /dev/null
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/metadataprocessors/internal/IMetaDataEnabledFeature2.java
@@ -0,0 +1,22 @@
+package org.eclipse.jst.jsf.metadataprocessors.internal;
+
+import org.eclipse.jst.jsf.context.IModelContext;
+import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature;
+
+/**
+ * Add the ability to inject a more general model context than IStructuredDocumentContext.
+ *
+ */
+public interface IMetaDataEnabledFeature2 extends IMetaDataEnabledFeature
+{
+ /**
+ * @return the model context
+ */
+ IModelContext getModelContext();
+
+ /**
+ * @param modelContext
+ */
+ void setModelContext(IModelContext modelContext);
+
+}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java
index b773fca..5c37f0e 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ActionType.java
@@ -24,8 +24,6 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.core.JSFVersion;
import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils;
import org.eclipse.jst.jsf.core.jsfappconfig.internal.JSFAppConfigManagerFactory;
@@ -71,16 +69,15 @@ public class ActionType extends MethodBindingType implements IPossibleValues{
}
//any other value should be one of the possible values
//optimize
- IWorkspaceContextResolver wr = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext());
- if (wr == null)
+ IFile jsp = getFile2();
+ if (jsp == null)
return true;//shouldn't get here
//in case that this is not JSF faceted or missing configs, need to pass
- if (JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()) == null)
+ if (JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(jsp.getProject()) == null)
return true;
- IFile jsp = (IFile)wr.getResource();
- List<NavigationRuleType> rules = JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()).getNavigationRulesForPage(jsp);
+ List<NavigationRuleType> rules = JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(jsp.getProject()).getNavigationRulesForPage(jsp);
for (final NavigationRuleType rule : rules) {
for (Iterator cases=rule.getNavigationCase().iterator();cases.hasNext();) {
NavigationCaseType navCase = (NavigationCaseType)cases.next();
@@ -131,13 +128,14 @@ public class ActionType extends MethodBindingType implements IPossibleValues{
*/
public List getPossibleValues() {
final List<IPossibleValue> ret = new ArrayList<IPossibleValue>();
- if (getStructuredDocumentContext() == null)
+ IProject project = getProject2();
+ IFile file = getFile2();
+ if (getModelContext() == null || file == null || project == null)
return ret;
- final IWorkspaceContextResolver wr = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext());
- if (wr != null && JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()) != null) {//may not be JSF faceted project or know faces-config){
- IFile jsp = (IFile)wr.getResource();
- List<NavigationRuleType> rules = JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()).getNavigationRulesForPage(jsp);
+ if (JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(project) != null) {//may not be JSF faceted project or know faces-config){
+ IFile jsp = file;
+ List<NavigationRuleType> rules = JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(project).getNavigationRulesForPage(jsp);
for (final NavigationRuleType rule : rules) {
if (rule != null)
ret.addAll(createProposals(rule));
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/CSSClassType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/CSSClassType.java
index 90c2dd4..5cf452d 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/CSSClassType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/CSSClassType.java
@@ -40,10 +40,13 @@ public class CSSClassType extends AbstractRootTypeDescriptor implements
private List<IPossibleValue> _pvs;
public List<IPossibleValue> getPossibleValues() {
- if (_pvs == null){
- IDOMContextResolver resolver = StructuredDocumentContextResolverFactory.getInstance().getDOMContextResolver(getStructuredDocumentContext());
- _pvs = getCSSClasses(resolver.getDOMDocument());
- }
+ if (getStructuredDocumentContext() != null)
+ {
+ if (_pvs == null){
+ IDOMContextResolver resolver = StructuredDocumentContextResolverFactory.getInstance().getDOMContextResolver(getStructuredDocumentContext());
+ _pvs = getCSSClasses(resolver.getDOMDocument());
+ }
+ }
return _pvs;
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java
index b22f4d1..69d482b 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/FacesConfigIdentifierFeatures.java
@@ -25,8 +25,6 @@ import org.eclipse.jdt.core.Signature;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jst.jsf.common.internal.types.CompositeType;
import org.eclipse.jst.jsf.common.internal.types.IAssignable;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigManager;
import org.eclipse.jst.jsf.facesconfig.FacesConfigPlugin;
import org.eclipse.jst.jsf.facesconfig.emf.DescriptionType;
@@ -240,17 +238,15 @@ public abstract class FacesConfigIdentifierFeatures extends AbstractMetaDataEnab
}
private JSFAppConfigManager getJSFAppConfigMgr(){
- return JSFAppConfigManager.getInstance(getProject());
- }
-
- private IProject getProject() {
- IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext());
- if (resolver != null)
- return resolver.getProject();
-
+ IProject project = getProject2();
+ if (project != null)
+ {
+ return JSFAppConfigManager.getInstance(project);
+ }
return null;
}
+
/**
* @param jsfAppConfigManager
* @return list of identifier Strings for config-type
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java
index 912c818..a91adbc 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/JavaClassType.java
@@ -38,8 +38,6 @@ import org.eclipse.jdt.core.search.SearchMatch;
import org.eclipse.jdt.core.search.SearchParticipant;
import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.SearchRequestor;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue;
@@ -123,13 +121,6 @@ public class JavaClassType extends ObjectType implements IPossibleValues, IValid
}
}
- private IWorkspaceContextResolver getWorkspaceContextResolver(){
- if (getStructuredDocumentContext() == null)
- return null;
-
- return IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext());
- }
-
private List getTypes(){
IJavaProject jp = getJavaProject();
if (jp == null)
@@ -168,15 +159,12 @@ public class JavaClassType extends ObjectType implements IPossibleValues, IValid
return Collections.EMPTY_LIST;
}
- private IJavaProject getJavaProject() {
- IWorkspaceContextResolver resolver = getWorkspaceContextResolver();
- if (resolver != null){
- IProject proj = resolver.getProject();
- if (proj != null)
- return JavaCore.create(proj);
- }
- return null;
- }
+ private IJavaProject getJavaProject()
+ {
+ IProject proj = getProject2();
+ if (proj != null) { return JavaCore.create(proj); }
+ return null;
+ }
private List getInterfaces(IJavaProject jp) {
List ret = new ArrayList();
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/PathType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/PathType.java
index 5f4f311..f7eb1e7 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/PathType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/PathType.java
@@ -14,9 +14,6 @@ package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.metadataprocessors.AbstractRootTypeDescriptor;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage;
@@ -26,7 +23,6 @@ import org.eclipse.jst.jsf.metadataprocessors.features.IValidationMessage;
*/
public abstract class PathType extends AbstractRootTypeDescriptor {
- private IProject _project = null;
private final List<IValidationMessage> _validationMsgs = new ArrayList<IValidationMessage>(1);
/**
@@ -37,20 +33,6 @@ public abstract class PathType extends AbstractRootTypeDescriptor {
}
/**
- * @return IProject
- */
- protected IProject getProject() {
- if( _project == null )
- {
- final IWorkspaceContextResolver wkspaceResolver =
- IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver( getStructuredDocumentContext() );
- _project = wkspaceResolver.getProject();
- }
-
- return _project;
- }
-
- /**
* @return list of {@link IValidationMessage}
*/
public List<IValidationMessage> getValidationMessages() {
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/RelativePathType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/RelativePathType.java
index 82dd380..146c091 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/RelativePathType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/RelativePathType.java
@@ -37,11 +37,13 @@ public class RelativePathType extends PathType implements
return true;
} catch (MalformedURLException e) {
//is this a valid path relative to the
- IProject project = getProject();
- IFile file= project.getFile(new Path(value));
- if (! file.exists())
- getValidationMessages().add(new ValidationMessage( value+Messages.RelativePathType_0));
-
+ IProject project = getProject2();
+ if (project != null)
+ {
+ IFile file= project.getFile(new Path(value));
+ if (! file.exists())
+ getValidationMessages().add(new ValidationMessage( value+Messages.RelativePathType_0));
+ }
return getValidationMessages().size() == 0;
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ResourceBundleType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ResourceBundleType.java
index 65f2fc9..d03979b 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ResourceBundleType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/ResourceBundleType.java
@@ -37,11 +37,14 @@ public class ResourceBundleType extends PathType implements IValidValues
{
try
{
- IProject project = getProject();
- IStorage bundle = LoadBundleUtil.getLoadBundleResource( project , value );
- if( bundle != null )
+ IProject project = getProject2();
+ if (project != null)
{
- return true;
+ IStorage bundle = LoadBundleUtil.getLoadBundleResource( project , value );
+ if( bundle != null )
+ {
+ return true;
+ }
}
}
catch (CoreException e)
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
index d01be0c..eb8865c 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/taglibprocessing/attributevalues/WebPathType.java
@@ -14,17 +14,17 @@ package org.eclipse.jst.jsf.taglibprocessing.attributevalues;
import java.net.MalformedURLException;
import java.net.URL;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.metadataprocessors.IMetaDataEnabledFeature;
import org.eclipse.jst.jsf.metadataprocessors.features.IValidValues;
import org.eclipse.jst.jsf.metadataprocessors.features.ValidationMessage;
import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
/**
* Path relative to web root
@@ -56,12 +56,16 @@ public class WebPathType extends PathType implements
}
private void validateFileRelativeToWebRoot(String value) {
- IVirtualContainer webRoot = getWebRoot();
+ IContainer webRoot = getWebRoot();
+ if (webRoot == null)
+ {
+ return;
+ }
if (! webRoot.exists()){
getValidationMessages().add(new ValidationMessage( Messages.WebPathType_1));
}
else {
- IVirtualFile file = webRoot.getFile(new Path(value));
+ IFile file = webRoot.getFile(new Path(value));
if (!file.exists()) {
//was this a valid file path string, or bogus url?
getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
@@ -71,29 +75,47 @@ public class WebPathType extends PathType implements
}
- private IVirtualContainer getWebRoot()
+ /**
+ * @return the web root
+ */
+ protected IContainer getWebRoot()
{
- IVirtualContainer webRoot =
- ComponentCore.createComponent(getProject()).getRootFolder();
-
- return webRoot;
+ IProject project = getProject2();
+ if (project != null)
+ {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null)
+ {
+ return component.getRootFolder().getUnderlyingFolder();
+ }
+ }
+ return null;
}
//Bug 325490 - [JSF2.0] False warning from facelet validator when working with facelet pages in a sub-folder
private void validateFileRelativeToCurrentFile(String value) {
- IPath webContentPath = ComponentCore.createComponent(getProject()).getRootFolder().getUnderlyingFolder().getFullPath();
- final IWorkspaceContextResolver wkspaceResolver =
- IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver( getStructuredDocumentContext() );
- IResource resource = wkspaceResolver.getResource();
- IPath filePath = resource.getFullPath();
- if (filePath.matchingFirstSegments(webContentPath) == webContentPath.segmentCount()) {
- filePath = filePath.removeFirstSegments(webContentPath.segmentCount());
- filePath = filePath.removeLastSegments(1);
- filePath = filePath.append(value);
- IVirtualFile file = getWebRoot().getFile(filePath);
- if (!file.exists()){
- getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
- }
+ IProject project = getProject2();
+ if (project != null)
+ {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if (component != null)
+ {
+ IPath webContentPath = component.getRootFolder().getUnderlyingFolder().getFullPath();
+ IResource resource = getFile2();
+ if (resource != null)
+ {
+ IPath filePath = resource.getFullPath();
+ if (filePath.matchingFirstSegments(webContentPath) == webContentPath.segmentCount()) {
+ filePath = filePath.removeFirstSegments(webContentPath.segmentCount());
+ filePath = filePath.removeLastSegments(1);
+ filePath = filePath.append(value);
+ IFile file = getWebRoot().getFile(filePath);
+ if (!file.exists()){
+ getValidationMessages().add(new ValidationMessage(Messages.WebPathType_2));
+ }
+ }
+ }
+ }
}
}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/attributevalues/TemplateWebPathType.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/attributevalues/TemplateWebPathType.java
index ea81dbb..92f0f77 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/attributevalues/TemplateWebPathType.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/cm/attributevalues/TemplateWebPathType.java
@@ -15,22 +15,20 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IContainer;
+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.jst.jsf.common.internal.componentcore.AbstractCompCoreQueryFactory;
import org.eclipse.jst.jsf.common.internal.componentcore.AbstractVirtualComponentQuery;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
+import org.eclipse.jst.jsf.context.IModelContext;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IStructuredDocumentContextResolverFactory2;
+import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.IXMLNodeContextResolver;
import org.eclipse.jst.jsf.facelet.core.internal.FaceletCorePlugin;
import org.eclipse.jst.jsf.metadataprocessors.features.IPossibleValues;
import org.eclipse.jst.jsf.metadataprocessors.features.PossibleValue;
import org.eclipse.jst.jsf.taglibprocessing.attributevalues.WebPathType;
-import org.eclipse.wst.common.componentcore.resources.IVirtualContainer;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
/**
* Web-path attribute value type that adds possible values support
@@ -41,20 +39,22 @@ import org.w3c.dom.Node;
public class TemplateWebPathType extends WebPathType implements IPossibleValues {
public List getPossibleValues() {
- final IStructuredDocumentContext context = getStructuredDocumentContext();
- final IDOMContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getDOMContextResolver(context);
- if (resolver != null) {
- final Node node = resolver.getNode();
- if (node instanceof Attr) {
- return createPossibleValues((Attr) node);
+ final IModelContext context = getModelContext();
+ if (context != null)
+ {
+ final IXMLNodeContextResolver resolver = IStructuredDocumentContextResolverFactory2.INSTANCE
+ .getXMLNodeContextResolver(context);
+ if (resolver != null) {
+ if (resolver.isAttribute()) {
+ return createPossibleValues(resolver.getValue());
+ }
}
}
return Collections.EMPTY_LIST;
}
- private List createPossibleValues(final Attr node) {
- String currentPathString = node.getNodeValue();
+ private List createPossibleValues(final String attrValue) {
+ String currentPathString = attrValue;
final List possibleValues = new ArrayList();
@@ -65,15 +65,14 @@ public class TemplateWebPathType extends WebPathType implements IPossibleValues
final IPath currentPath = new Path(currentPathString);
- final IVirtualContainer webRoot = getWebRoot();
+ final IContainer webRoot = getWebRoot();
if (webRoot == null)
{
return possibleValues;
}
- final IResource deepestElement = findDeepestCommonElement(currentPath,
- (IContainer) webRoot.getUnderlyingResource());
+ final IResource deepestElement = findDeepestCommonElement(currentPath, webRoot);
if (deepestElement == null) {
// empty
@@ -138,13 +137,18 @@ public class TemplateWebPathType extends WebPathType implements IPossibleValues
return deepestElement;
}
- private IVirtualContainer getWebRoot()
+ @Override
+ protected IContainer getWebRoot()
{
- AbstractCompCoreQueryFactory compCoreQueryFactory = FaceletCorePlugin.getDefault().getCompCoreQueryFactory();
- AbstractVirtualComponentQuery virtualComponentQuery = compCoreQueryFactory.createVirtualComponentQuery(getProject());
- if (virtualComponentQuery != null)
+ IProject project = getProject2();
+ if (project != null)
{
- return virtualComponentQuery.getWebContentFolder(getProject());
+ AbstractCompCoreQueryFactory compCoreQueryFactory = FaceletCorePlugin.getDefault().getCompCoreQueryFactory();
+ AbstractVirtualComponentQuery virtualComponentQuery = compCoreQueryFactory.createVirtualComponentQuery(project);
+ if (virtualComponentQuery != null)
+ {
+ return virtualComponentQuery.getWebContentFolder(project).getUnderlyingFolder();
+ }
}
return null;
}