Author: scabanovich
Date: 2008-06-30 11:15:38 -0400 (Mon, 30 Jun 2008)
New Revision: 9022
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
Log:
JBIDE-1970
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2008-06-30 15:14:54 UTC (rev 9021)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2008-06-30 15:15:38 UTC (rev 9022)
@@ -1758,6 +1758,8 @@
class="org.jboss.tools.jsf.model.handlers.JSFProcessRegirectHandler"/>
<xclass id="org.jboss.tools.jsf.model.handlers.JSPAdopt"
class="org.jboss.tools.jsf.model.handlers.JSPAdopt"/>
+ <xclass
id="org.jboss.tools.jsf.model.handlers.RemoveJSFNatureContribution"
+ class="org.jboss.tools.jsf.model.handlers.RemoveJSFNatureContribution"/>
<xclass id="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
class="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"/>
<xclass id="org.jboss.tools.jsf.model.handlers.OpenPageHandler"
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java 2008-06-30
15:15:38 UTC (rev 9022)
@@ -0,0 +1,45 @@
+package org.jboss.tools.jsf.model.handlers;
+
+import org.jboss.tools.common.meta.action.SpecialWizard;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jsf.model.JSFConstants;
+import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
+
+public class RemoveJSFNatureContribution implements SpecialWizard {
+ XModel model = null;
+
+ public void setObject(Object object) {
+ if(object instanceof XModel) {
+ model = (XModel)object;
+ }
+ }
+
+ public int execute() {
+ if(model == null) return 1;
+ XModelObject webxml = WebAppHelper.getWebApp(model);
+ XModelObject servlet = WebAppHelper.findServlet(webxml,
+ JSFConstants.FACES_SERVLET_CLASS, "Faces Config");
+ String servletName = servlet == null ? null :
servlet.getAttributeValue("servlet-name");
+ XModelObject mapping = WebAppHelper.findServletMapping(webxml, servletName);
+
+ if(servlet != null) {
+ DefaultRemoveHandler.removeFromParent(servlet);
+ }
+ if(mapping != null) {
+ DefaultRemoveHandler.removeFromParent(mapping);
+ }
+ XModelObject folder = webxml.getChildByPath("Context Params");
+ XModelObject[] params = folder.getChildren();
+ for (int i = 0; i < params.length; i++) {
+ String name = params[i].getAttributeValue("param-name");
+ if(name != null && name.startsWith("javax.faces.")) {
+ DefaultRemoveHandler.removeFromParent(params[i]);
+ }
+ }
+
+ return 0;
+ }
+
+}
Show replies by date