Author: scabanovich
Date: 2009-09-16 09:10:17 -0400 (Wed, 16 Sep 2009)
New Revision: 17612
Added:
trunk/common/plugins/org.jboss.tools.common.model/schema/modelnatures.exsd
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNatureExtension.java
Removed:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpPaletteHandler.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/plugin.xml
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/FilePathEncoderFactory.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4893
Modified: trunk/common/plugins/org.jboss.tools.common.model/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/plugin.xml 2009-09-16 12:21:18 UTC
(rev 17611)
+++ trunk/common/plugins/org.jboss.tools.common.model/plugin.xml 2009-09-16 13:10:17 UTC
(rev 17612)
@@ -11,6 +11,7 @@
<extension-point id="resourceMapping" name="resourceMapping"
schema="schema/resourceMapping.exsd"/>
<extension-point id="classes" name="Model Classes"
schema="schema/classes.exsd"/>
<extension-point id="preferences" name="preferences"
schema="schema/preferences.exsd"/>
+ <extension-point id="modelnatures" name="Model Natures"
schema="schema/modelnatures.exsd"/>
<extension point="org.eclipse.wst.xml.core.catalogContributions">
<catalogContribution id="default">
Added: trunk/common/plugins/org.jboss.tools.common.model/schema/modelnatures.exsd
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/schema/modelnatures.exsd
(rev 0)
+++ trunk/common/plugins/org.jboss.tools.common.model/schema/modelnatures.exsd 2009-09-16
13:10:17 UTC (rev 17612)
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.model"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.jboss.tools.common.model"
id="modelnatures" name="Model Natures"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="modelnature"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="modelnature">
+ <complexType>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="displayName" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="pathEncoder" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="watcherContributor" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model/schema/modelnatures.exsd
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpPaletteHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpPaletteHandler.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpPaletteHandler.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.meta.help;
-
-import java.util.*;
-import org.jboss.tools.common.model.*;
-
-public class HelpPaletteHandler extends HelpHandler {
-
- public HelpPaletteHandler() {}
-
- public void executeHandler(XModelObject object, Properties prop) throws
XModelException {
- if(!isEnabled(object)) return;
- XModelObject tab = getTabObject(object);
- String key = (tab == null) ? null : tab.getModelEntity().getName() +
"_" + tab.getPathPart().replace(' ', '_'); //$NON-NLS-1$
- if(key == null || !HelpUtil.hasHelp(key)) {
- super.executeHandler(object, prop);
- } else {
- HelpUtil.callHelp(object.getModel(), key);
- }
- }
-
- private XModelObject getTabObject(XModelObject object) {
- XModelObject tab = object;
- while(tab != null &&
!tab.getModelEntity().getName().startsWith("SharablePageTab")) //$NON-NLS-1$
- tab = tab.getParent();
- return tab;
- }
-
-}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/help/HelpUtil.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -39,16 +39,6 @@
return path != null && path.length() > 0;
}
- public static void callHelp(XModel model, String key) throws XModelException {
- String u = (key == null) ? null : keys.getProperty(key);
- if(u == null) return;
- //if(u.endsWith("noHelpYet.html")) ModelPlugin.log("Help for key
" + key + " is not available.");
- XModelObject editor = model.getByPath("%Options%/External Programs/Internet
Browser"); //$NON-NLS-1$
- if(editor == null) throw new XModelException("External Program 'Internet
Browser' is not set in Options.");
- String f = "" + model.getProperties().getProperty(XModelConstants.HOME)
+ "/doc/help" + u; //$NON-NLS-1$
- OpenWithExternalHandler.start("Help", f, editor); //$NON-NLS-1$
- }
-
public static boolean isHelpPluginInstalled() {
for (int i = 0; i < PLUGINS.length; i++)
if(Platform.getBundle(PLUGINS[i]) != null) return true;
@@ -76,22 +66,6 @@
return p;
}
- public static void help(XModel model, String key) {
- ServiceDialog d = model.getService();
- if(!hasHelp(key)) {
- d.showDialog(ModelMessages.WARNING,
- MessageFormat.format("Help for key {0} is not available.", key),
- new String[]{"Close"}, null, ServiceDialog.WARNING);
- } else {
- try {
- HelpUtil.callHelp(model, key);
- } catch (XModelException e) {
- d.showDialog(ModelMessages.WARNING, e.getMessage(),
- new String[]{"Close"}, null, ServiceDialog.WARNING);
- }
- }
- }
-
public static void helpEclipse(XModel model, String key) {
ServiceDialog d = model.getService();
if(!isHelpPluginInstalled()) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsTreeConstraint.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -19,7 +19,7 @@
public void update(XModel model) {}
- String excludeExtensions = ".project.struts.classpath."; //$NON-NLS-1$
+ String excludeExtensions = ".project.classpath."; //$NON-NLS-1$
public boolean accepts(XModelObject object) {
String entity = object.getModelEntity().getName();
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -27,6 +27,7 @@
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.project.ModelNatureExtension;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
@@ -37,16 +38,24 @@
String nature = getNature(object);
if(nature == null) return false;
XActionImpl i = (XActionImpl)action;
- String n = (nature.indexOf("struts") > 0) ? "Struts" :
//$NON-NLS-1$ //$NON-NLS-2$
- (nature.indexOf("jsf") > 0) ? "JSF" :
"Model"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- i.setDisplayName(MessageFormat.format("Remove {0} Capabilities", n));
+ i.setDisplayName(MessageFormat.format("Remove {0} Capabilities", nature));
return true;
}
private String getNature(XModelObject object) {
IProject p = EclipseResourceUtil.getProject(object);
- IModelNature n = EclipseResourceUtil.getModelNature(p);
- return n == null ? null : n.getID();
+ ModelNatureExtension[] es = ModelNatureExtension.getInstances();
+ for (ModelNatureExtension ext: es) {
+ String name = ext.getName();
+ if(p != null && p.isAccessible()) try {
+ if(p.hasNature(name)) {
+ return ext.getDisplayName();
+ }
+ } catch (CoreException e) {
+
+ }
+ }
+ return null;
}
public void executeHandler(XModelObject object, Properties p) throws XModelException {
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ClassPathUpdate.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -39,7 +39,7 @@
String entity = model.getRoot().getModelEntity().getName();
if("RootDummy".equals(entity)) { //$NON-NLS-1$
String pn = (project == null) ? "?" : project.getName(); //$NON-NLS-1$
- throw new IllegalArgumentException("Struts Project " + pn + " is
corrupted."); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException("Project " + pn + " is
corrupted."); //$NON-NLS-1$ //$NON-NLS-2$
}
this.model = model;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -201,11 +201,13 @@
public static boolean checkModelNature(IProject project) {
if(project == null || !project.isOpen()) return false;
String nature = null;
+ ModelNatureExtension[] es = ModelNatureExtension.getInstances();
try {
- if(project.hasNature("org.jboss.tools.jsf.jsfnature")) { //$NON-NLS-1$
- nature = "org.jboss.tools.jsf.jsfnature"; //$NON-NLS-1$
- } else if(project.hasNature("org.jboss.tools.struts.strutsnature")) {
//$NON-NLS-1$
- nature = "org.jboss.tools.struts.strutsnature"; //$NON-NLS-1$
+ for (ModelNatureExtension ext: es) {
+ if(project.hasNature(ext.getName())) {
+ nature = ext.getName();
+ break;
+ }
}
} catch (CoreException e) {
ModelPlugin.getPluginLog().logError(e);
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNatureExtension.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNatureExtension.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNatureExtension.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -0,0 +1,74 @@
+package org.jboss.tools.common.model.project;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.util.ModelFeatureFactory;
+import org.jboss.tools.jst.web.tld.IFilePathEncoder;
+
+public class ModelNatureExtension {
+ public static String EXTENSION_POINT =
"org.jboss.tools.common.model.modelnatures"; //$NON-NLS-1$
+
+ String name;
+ String displayName;
+ String pathEncoder;
+ String watcherContributor;
+ IFilePathEncoder pathEncoderInstance;
+
+ public ModelNatureExtension() {}
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public IFilePathEncoder getPathEncoder () {
+ if(pathEncoderInstance != null) {
+ return pathEncoderInstance;
+ }
+ if(pathEncoder == null) {
+ return null;
+ }
+ if(pathEncoder.length() == 0) {
+ pathEncoder = null;
+ return null;
+ }
+ try {
+ pathEncoderInstance =
(IFilePathEncoder)ModelFeatureFactory.getInstance().createFeatureInstance(pathEncoder);
+ } catch (ClassCastException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ } finally {
+ pathEncoder = null;
+ }
+ return pathEncoderInstance;
+ }
+
+ public String getWatcherContributor() {
+ return watcherContributor;
+ }
+
+ static ModelNatureExtension[] INSTANCES;
+
+ public static ModelNatureExtension[] getInstances() {
+ if(INSTANCES != null) return INSTANCES;
+ List<ModelNatureExtension> list = new ArrayList<ModelNatureExtension>();
+ IExtensionPoint point =
Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT);
+ IConfigurationElement[] es = point.getConfigurationElements();
+ for (IConfigurationElement e: es) {
+ ModelNatureExtension n = new ModelNatureExtension();
+ n.name = e.getAttribute("name"); //$NON-NLS-1$
+ n.displayName = e.getAttribute("displayName"); //$NON-NLS-1$
+ n.pathEncoder = e.getAttribute("pathEncoder"); //$NON-NLS-1$
+ n.watcherContributor = e.getAttribute("watcherContributor"); //$NON-NLS-1$
+ list.add(n);
+ }
+ return INSTANCES = list.toArray(new ModelNatureExtension[0]);
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNatureExtension.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/Watcher.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -21,11 +21,6 @@
import org.jboss.tools.common.model.util.ModelFeatureFactory;
public class Watcher implements XModelTreeListener {
- static String[][] CONTRIBUTORS = new String[][]{
- {"org.jboss.tools.struts.webprj.model.helpers.sync.SyncProjectContext",
"org.jboss.tools.struts.strutsnature"}, //$NON-NLS-1$ //$NON-NLS-2$
- {"org.jboss.tools.jsf.web.JSFWatcherContributor",
"org.jboss.tools.jsf.jsfnature"} //$NON-NLS-1$ //$NON-NLS-2$
- };
-
public static Watcher getInstance(XModel model) {
Watcher instance = (Watcher)model.getManager("Watcher"); //$NON-NLS-1$
if(instance == null) {
@@ -59,13 +54,15 @@
void updateContributors() {
if(model == null) return;
- for (int i = 0; i < CONTRIBUTORS.length; i++) {
- String nature = CONTRIBUTORS[i][1];
+ ModelNatureExtension[] es = ModelNatureExtension.getInstances();
+ for (int i = 0; i < es.length; i++) {
+ String nature = es[i].getName();
if(EclipseResourceUtil.hasNature(model, nature)) {
if(contributors.containsKey(nature)) {
continue;
} else {
- Object watcher =
ModelFeatureFactory.getInstance().createFeatureInstance(CONTRIBUTORS[i][0]);
+ String contributorName = es[i].getWatcherContributor();
+ Object watcher =
ModelFeatureFactory.getInstance().createFeatureInstance(contributorName);
if(watcher instanceof IWatcherContributor) {
IWatcherContributor c = (IWatcherContributor)watcher;
c.init(model);
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -20,7 +20,6 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.ui.PreferenceConstants;
@@ -41,6 +40,7 @@
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.project.ModelNature;
+import org.jboss.tools.common.model.project.ModelNatureExtension;
public class EclipseResourceUtil {
@@ -185,14 +185,11 @@
private static String[] MODEL_NATURES = new String[0];
static {
- List<String> natures = new ArrayList<String>();
- if(Platform.getBundle("org.jboss.tools.struts") != null) { //$NON-NLS-1$
- natures.add("org.jboss.tools.struts.strutsnature"); //$NON-NLS-1$
+ ModelNatureExtension[] es = ModelNatureExtension.getInstances();
+ MODEL_NATURES = new String[es.length];
+ for (int i = 0; i < es.length; i++) {
+ MODEL_NATURES[i] = es[i].getName();
}
- if(Platform.getBundle("org.jboss.tools.jsf") != null) { //$NON-NLS-1$
- natures.add("org.jboss.tools.jsf.jsfnature"); //$NON-NLS-1$
- }
- MODEL_NATURES = natures.toArray(new String[0]);
}
public static String[] getModelNatureNames() {
@@ -275,7 +272,7 @@
static Map<IProject,XModel> models = new HashMap<IProject,XModel>();
/**
- * If project has no struts nature, the method creates new instance of model
+ * If project has no model nature, the method creates new instance of model
* populates it with a filesystems corresponding to the project root
* and links, and returns model object for the resource.
* The model created is not complete project, so it has property
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/FilePathEncoderFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/FilePathEncoderFactory.java 2009-09-16
12:21:18 UTC (rev 17611)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/jst/web/tld/FilePathEncoderFactory.java 2009-09-16
13:10:17 UTC (rev 17612)
@@ -12,26 +12,22 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.model.util.ModelFeatureFactory;
+import org.jboss.tools.common.model.project.ModelNatureExtension;
public class FilePathEncoderFactory {
- static IFilePathEncoder jsfEncoder = null;
- static {
- try {
- jsfEncoder =
(IFilePathEncoder)ModelFeatureFactory.getInstance().createFeatureInstance("org.jboss.tools.jsf.model.helpers.pages.FilePathEncoder");
//$NON-NLS-1$
- } catch (ClassCastException e) {
- ModelPlugin.getPluginLog().logError(e);
- }
- }
-
public static IFilePathEncoder getEncoder(IProject project) {
if(project == null || !project.isOpen()) return null;
- try {
- if(project.hasNature("org.jboss.tools.jsf.jsfnature")) return jsfEncoder;
//$NON-NLS-1$
- } catch (CoreException e) {
- //ignore - all checks are done above
+ ModelNatureExtension[] es = ModelNatureExtension.getInstances();
+ for (int i = 0; i < es.length; i++) {
+ try {
+ if(project.hasNature(es[i].getName())) {
+ IFilePathEncoder encoder = es[i].getPathEncoder();
+ if(encoder != null) return encoder;
+ }
+ } catch (CoreException e) {
+ //ignore - all checks are done above
+ }
}
return null;
}