Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgkessler2010-06-30 16:25:18 -0400
committergkessler2010-06-30 16:25:18 -0400
commit600570a00d5262b08fb660735f835390e5921ef6 (patch)
tree2bdd23419bf720f67a619f64fb35100da4206296
parenteb08389a909e69f909cbb7705f7c49e11f11296a (diff)
downloadwebtools.jsf-600570a00d5262b08fb660735f835390e5921ef6.tar.gz
webtools.jsf-600570a00d5262b08fb660735f835390e5921ef6.tar.xz
webtools.jsf-600570a00d5262b08fb660735f835390e5921ef6.zip
[315692] FaceletNamespaceMetaDataLocator should only be active for JSF2.0+ faceted projects
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/metadata/FaceletNamespaceMetaDataLocator.java44
1 files changed, 38 insertions, 6 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/metadata/FaceletNamespaceMetaDataLocator.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/metadata/FaceletNamespaceMetaDataLocator.java
index ca5861691..9ded96b41 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/metadata/FaceletNamespaceMetaDataLocator.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.facelet.core/src/org/eclipse/jst/jsf/facelet/core/internal/metadata/FaceletNamespaceMetaDataLocator.java
@@ -16,13 +16,21 @@ import org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider
import org.eclipse.jst.jsf.common.metadata.internal.IPathSensitiveMetaDataLocator;
import org.eclipse.jst.jsf.common.metadata.internal.MetaDataChangeNotificationEvent;
import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.Namespace;
+import org.eclipse.jst.jsf.core.IJSFCoreConstants;
+import org.eclipse.jst.jsf.core.JSFVersion;
import org.eclipse.jst.jsf.core.internal.CompositeTagRegistryFactory;
import org.eclipse.jst.jsf.core.internal.CompositeTagRegistryFactory.TagRegistryIdentifier;
+import org.eclipse.jst.jsf.core.jsfappconfig.JSFAppConfigUtils;
import org.eclipse.jst.jsf.core.metadata.internal.INamespaceModelProvider;
import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry.ITagRegistryListener;
import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry.TagRegistryChangeEvent;
import org.eclipse.jst.jsf.facelet.core.internal.FaceletCorePlugin;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent.Type;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent;
/**
@@ -30,7 +38,7 @@ import org.eclipse.jst.jsf.facelet.core.internal.FaceletCorePlugin;
*/
public class FaceletNamespaceMetaDataLocator
extends AbstractMetaDataLocator
- implements IPathSensitiveMetaDataLocator, ITagRegistryListener {
+ implements IPathSensitiveMetaDataLocator, ITagRegistryListener, IFacetedProjectListener {
//in the future if there is an explicit xhtml content type id, we will need to use that here
private static final IContentType XHTML_CONTENTTYPE =
@@ -52,12 +60,19 @@ public class FaceletNamespaceMetaDataLocator
}
public void startLocating() {
- final TagRegistryIdentifier tagRegId = new TagRegistryIdentifier(_project, XHTML_CONTENTTYPE);
- _reg = CompositeTagRegistryFactory.getInstance().getRegistry(tagRegId);
- if (_reg != null) {
- _reg.addListener(this);
+ if (_project != null && JSFAppConfigUtils.isValidJSFProject(_project)
+ && JSFVersion.valueOfProject(_project).compareTo(JSFVersion.V2_0) >=0 ) {
+
+ final TagRegistryIdentifier tagRegId = new TagRegistryIdentifier(_project, XHTML_CONTENTTYPE);
+ _reg = CompositeTagRegistryFactory.getInstance().getRegistry(tagRegId);
+ if (_reg != null) {
+ _reg.addListener(this);
+ }
}
-
+
+ //add faceted project listener that will check for JSF facet version
+ //being added and the facelet registry not being initialized
+ FacetedProjectFramework.addListener(this, Type.POST_INSTALL);
}
public void stopLocating() {
@@ -65,6 +80,7 @@ public class FaceletNamespaceMetaDataLocator
_reg.removeListener(this);
_reg = null;
}
+ FacetedProjectFramework.removeListener(this);
}
public void setProjectContext(final IProject project) {
@@ -108,6 +124,22 @@ public class FaceletNamespaceMetaDataLocator
});
}
+ public void handleEvent(final IFacetedProjectEvent event) {
+ if (event.getProject().getProject() == _project) {
+ final IProjectFacetActionEvent ev = (IProjectFacetActionEvent)event;
+ if (ev.getProjectFacet().getId()
+ .equals(IJSFCoreConstants.JSF_CORE_FACET_ID)) {
+ //if jsf facet has been added, it may be a 2.0 faceted project now
+ //call start locating again to add listener to facelet registry
+ //if not already doing so.
+ //only have to look at POST_INSTALL event since there is no version_changes option
+ //currently with the JSF Facet
+ if (ev.getType() == Type.POST_INSTALL && _reg == null) {
+ startLocating();
+ }
+ }
+ }
+ }
private class NamespaceSourceModel implements INamespaceModelProvider {
private Namespace ns;

Back to the top