[jbosstools-commits] JBoss Tools SVN: r9203 - in trunk/struts/plugins/org.jboss.tools.struts: resources/meta and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jul 22 10:36:30 EDT 2008


Author: scabanovich
Date: 2008-07-22 10:36:30 -0400 (Tue, 22 Jul 2008)
New Revision: 9203

Added:
   trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigParticipant.java
   trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigWebAppChange.java
Modified:
   trunk/struts/plugins/org.jboss.tools.struts/plugin.xml
   trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts11.meta
   trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts12.meta
   trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/RenameStrutsConfigHandler.java
Log:
 	 JBIDE-2487

Modified: trunk/struts/plugins/org.jboss.tools.struts/plugin.xml
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/plugin.xml	2008-07-22 13:44:55 UTC (rev 9202)
+++ trunk/struts/plugins/org.jboss.tools.struts/plugin.xml	2008-07-22 14:36:30 UTC (rev 9203)
@@ -90,6 +90,25 @@
          </enablement>
       </renameParticipant>
 
+      <renameParticipant
+            class="org.jboss.tools.struts.model.handlers.refactoring.StrutsRenameStrutsConfigParticipant"
+            id="org.jboss.tools.struts.model.handlers.refactoring.JSFRenameStrutsConfigParticipant"
+            name="jsf-RenameStrutsConfigParticipant">
+         <enablement>
+            <with variable="affectedNatures">
+               <iterate operator="or">
+                  <equals value="org.jboss.tools.struts.strutsnature"/>
+               </iterate>
+            </with>
+            <with variable="element">
+                <or>
+                   <instanceof value="org.eclipse.core.resources.IFile"/>
+                </or>
+            </with>
+         </enablement>
+      </renameParticipant>
+
+
    </extension>
 
    <extension point="org.jboss.tools.common.model.classes">

Modified: trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts11.meta
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts11.meta	2008-07-22 13:44:55 UTC (rev 9202)
+++ trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts11.meta	2008-07-22 14:36:30 UTC (rev 9203)
@@ -360,7 +360,7 @@
     </XActionItem>
    </XActionItem>
    <XActionItem kind="list" name="EditActions">
-    <XActionItem
+    <XActionItem HIDE="always"
      HandlerClassName="org.jboss.tools.struts.model.handlers.RenameStrutsConfigHandler"
      ICON="action.empty" PROPERTIES="validator.edit=true"
      WizardClassName="%Default%" displayName="Rename..." kind="action" name="Rename">
@@ -368,6 +368,9 @@
       <AttributeData AttributeName="name"/>
      </EntityData>
     </XActionItem>
+    <XActionItem
+     HandlerClassName="org.jboss.tools.common.model.filesystems.impl.handlers.RenameEclipseFileHandler"
+     ICON="action.empty" displayName="Rename..." kind="action" name="RenameEclipse"/>
    </XActionItem>
    <XActionItem kind="list" name="SaveActions">
     <XActionItem HIDE="always" HandlerClassName="%SaveFile%"

Modified: trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts12.meta
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts12.meta	2008-07-22 13:44:55 UTC (rev 9202)
+++ trunk/struts/plugins/org.jboss.tools.struts/resources/meta/struts12.meta	2008-07-22 14:36:30 UTC (rev 9203)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE XModelEntityGroup PUBLIC "-//Red Hat, Inc.//DTD Meta 1.0//EN" "meta.dtd">
+<!DOCTYPE XModelEntityGroup PUBLIC "-//Red Hat, Inc.//DTD Meta 1.0//EN"
+                                   "meta.dtd">
 <XModelEntityGroup>
  <VERSION DEPENDS="Model:1.0" MODULE="Struts Editor" VERSION="1.0"/>
  <MAPPINGS/>
@@ -21,19 +22,11 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="action" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="attribute" xmlname="attribute">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
+   <XModelAttribute name="attribute" xmlname="attribute"/>
    <XModelAttribute name="className" xmlname="className">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute name="forward" xmlname="forward">
@@ -58,20 +51,10 @@
     <Constraint loader="ListString"/>
     <Editor name="StrutsActionNameEditor"/>
    </XModelAttribute>
-   <XModelAttribute name="parameter" xmlname="parameter">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute PROPERTIES="id=true;save=always" name="path" xmlname="path">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="prefix" xmlname="prefix">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="parameter" xmlname="parameter"/>
+   <XModelAttribute PROPERTIES="id=true;save=always" name="path" xmlname="path"/>
+   <XModelAttribute name="prefix" xmlname="prefix"/>
    <XModelAttribute name="roles" xmlname="roles">
-    <Constraint/>
     <Editor name="WebRoleChoiceList"/>
    </XModelAttribute>
    <XModelAttribute name="scope" xmlname="scope">
@@ -82,12 +65,8 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute name="suffix" xmlname="suffix">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="suffix" xmlname="suffix"/>
    <XModelAttribute PROPERTIES="linkAction=OpenSource" name="type" xmlname="type">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute default="false" name="unknown" xmlname="unknown">
@@ -107,30 +86,16 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="display-name" xmlname="display-name.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text"/>
+   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text"/>
+   <XModelAttribute name="display-name" xmlname="display-name.#text"/>
    <XModelAttribute name="description" xmlname="description.#text">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
-   <XModelAttribute name="_shape" visibility="false">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="_shape" visibility="false"/>
   </XModelAttributes>
   <XActionItem kind="list">
    <XActionItem
@@ -260,24 +225,15 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="action-mappings" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute default="action-mappings" loader="ElementType"
     name="name" visibility="false">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="type" xmlname="type">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
+   <XModelAttribute name="type" xmlname="type"/>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
   </XModelAttributes>
@@ -346,47 +302,25 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="struts-config 1.2" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute default="struts-config" name="name" xmlname="NAME">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute default="struts-config" name="name" xmlname="NAME"/>
    <XModelAttribute default="xml" name="extension" xmlname="EXTENSION">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="display-name" xmlname="display-name.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="description" xmlname="description.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="display-name" xmlname="display-name.#text"/>
+   <XModelAttribute name="description" xmlname="description.#text"/>
+   <XModelAttribute name="id" xmlname="id"/>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
    <XModelAttribute loader="ElementType" name="_lateload" visibility="false">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute
     default="-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
-    name="publicId" visibility="false">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="systemId" visibility="false">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+    name="publicId" visibility="false"/>
+   <XModelAttribute name="systemId" visibility="false"/>
    <XModelAttribute default="no" name="isIncorrect" visibility="false">
     <Constraint loader="List">
      <value name="yes"/>
@@ -394,10 +328,7 @@
     </Constraint>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="incorrectBody" visibility="false">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="incorrectBody" visibility="false"/>
    <XModelAttribute default="UTF-8" name="encoding">
     <Constraint loader="ListString">
      <value name="ISO-8859-1"/>
@@ -425,7 +356,7 @@
     </XActionItem>
    </XActionItem>
    <XActionItem kind="list" name="EditActions">
-    <XActionItem
+    <XActionItem HIDE="always"
      HandlerClassName="org.jboss.tools.struts.model.handlers.RenameStrutsConfigHandler"
      ICON="action.empty" PROPERTIES="validator.edit=true"
      WizardClassName="%Default%" displayName="Rename..." kind="action" name="Rename">
@@ -433,6 +364,9 @@
       <AttributeData AttributeName="name"/>
      </EntityData>
     </XActionItem>
+    <XActionItem
+     HandlerClassName="org.jboss.tools.common.model.filesystems.impl.handlers.RenameEclipseFileHandler"
+     ICON="action.empty" displayName="Rename..." kind="action" name="RenameEclipse"/>
    </XActionItem>
    <XActionItem kind="list" name="SaveActions">
     <XActionItem HIDE="always" HandlerClassName="%SaveFile%"
@@ -558,18 +492,13 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="controller" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute default="controller" loader="ElementType"
     name="name" visibility="false">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
    <XModelAttribute name="bufferSize" xmlname="bufferSize">
     <Constraint loader="Int">
      <value name="minimum=0"/>
@@ -578,17 +507,10 @@
     <Editor name="Int"/>
    </XModelAttribute>
    <XModelAttribute name="className" xmlname="className">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
-   <XModelAttribute name="contentType" xmlname="contentType">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="forwardPattern" xmlname="forwardPattern">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="contentType" xmlname="contentType"/>
+   <XModelAttribute name="forwardPattern" xmlname="forwardPattern"/>
    <XModelAttribute name="inputForward" xmlname="inputForward">
     <Constraint loader="List">
      <value/>
@@ -611,14 +533,11 @@
    </XModelAttribute>
    <XModelAttribute name="maxFileSize" xmlname="maxFileSize">
     <Constraint loader="FileSize"/>
-    <Editor/>
    </XModelAttribute>
    <XModelAttribute name="memFileSize" xmlname="memFileSize">
     <Constraint loader="FileSize"/>
-    <Editor/>
    </XModelAttribute>
    <XModelAttribute name="multipartClass" xmlname="multipartClass">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute name="nocache" xmlname="nocache">
@@ -631,20 +550,12 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute name="pagePattern" xmlname="pagePattern">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="pagePattern" xmlname="pagePattern"/>
    <XModelAttribute name="processorClass" xmlname="processorClass">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
-   <XModelAttribute name="tempDir" xmlname="tempDir">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="tempDir" xmlname="tempDir"/>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
   </XModelAttributes>
@@ -705,15 +616,10 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="form-bean" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
    <XModelAttribute name="className" xmlname="className">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute name="dynamic" visibility="false" xmlname="dynamic">
@@ -726,33 +632,18 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute PROPERTIES="save=always" name="name" xmlname="name">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute PROPERTIES="save=always" name="name" xmlname="name"/>
    <XModelAttribute PROPERTIES="linkAction=OpenSource;save=always"
     name="type" xmlname="type">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
-   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="display-name" xmlname="display-name.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text"/>
+   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text"/>
+   <XModelAttribute name="display-name" xmlname="display-name.#text"/>
    <XModelAttribute name="description" xmlname="description.#text">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
   </XModelAttributes>
@@ -831,24 +722,17 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="form-beans" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute default="form-beans" loader="ElementType"
     name="name" visibility="false">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
    <XModelAttribute name="type" xmlname="type">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
   </XModelAttributes>
@@ -893,15 +777,10 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="forward" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
    <XModelAttribute PROPERTIES="linkAction=OpenSource" name="className" xmlname="className">
-    <Constraint/>
     <Editor name="AccessibleJava"/>
    </XModelAttribute>
    <XModelAttribute loader="ContextRelative" name="contextRelative" xmlname="contextRelative">
@@ -914,14 +793,8 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute name="module" xmlname="module">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute PROPERTIES="save=always" name="name" xmlname="name">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="module" xmlname="module"/>
+   <XModelAttribute PROPERTIES="save=always" name="name" xmlname="name"/>
    <XModelAttribute PROPERTIES="linkAction=JumpByPath;save=always"
     name="path" xmlname="path">
     <Constraint loader="Properties">
@@ -939,30 +812,16 @@
     </Constraint>
     <Editor name="List"/>
    </XModelAttribute>
-   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="display-name" xmlname="display-name.#text">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="small-icon" xmlname="icon.small-icon.#text"/>
+   <XModelAttribute name="large-icon" xmlname="icon.large-icon.#text"/>
+   <XModelAttribute name="display-name" xmlname="display-name.#text"/>
    <XModelAttribute name="description" xmlname="description.#text">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
-   <XModelAttribute name="_shape" visibility="false">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="_shape" visibility="false"/>
   </XModelAttributes>
   <XActionItem kind="list">
    <XActionItem
@@ -1051,24 +910,15 @@
   </XEntityRenderer>
   <XModelAttributes>
    <XModelAttribute default="global-forwards" loader="ElementType" name="element type">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
    <XModelAttribute default="global-forwards" loader="ElementType"
     name="name" visibility="false">
-    <Constraint/>
     <Editor name="Uneditable"/>
    </XModelAttribute>
-   <XModelAttribute name="id" xmlname="id">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
-   <XModelAttribute name="type" xmlname="type">
-    <Constraint/>
-    <Editor/>
-   </XModelAttribute>
+   <XModelAttribute name="id" xmlname="id"/>
+   <XModelAttribute name="type" xmlname="type"/>
    <XModelAttribute TRIM="no" name="comment" xmlname="#comment">
-    <Constraint/>
     <Editor name="Note"/>
    </XModelAttribute>
   </XModelAttributes>

Modified: trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/RenameStrutsConfigHandler.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/RenameStrutsConfigHandler.java	2008-07-22 13:44:55 UTC (rev 9202)
+++ trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/RenameStrutsConfigHandler.java	2008-07-22 14:36:30 UTC (rev 9203)
@@ -55,7 +55,7 @@
 		}
 	}
 	
-	private void renameConfigInWebXML(XModel model, String module, String oldURI, String newURI) throws XModelException {
+	public static void renameConfigInWebXML(XModel model, String module, String oldURI, String newURI) throws XModelException {
 		XModelObject webxml = WebAppHelper.getWebApp(model);
 		if(webxml == null) return;
 		XModelObject servlet = StrutsWebHelper.findServlet(webxml);

Added: trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigParticipant.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigParticipant.java	                        (rev 0)
+++ trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigParticipant.java	2008-07-22 14:36:30 UTC (rev 9203)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.struts.model.handlers.refactoring;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.*;
+import org.eclipse.ltk.core.refactoring.participants.*;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.jst.web.project.WebModuleConstants;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.struts.webprj.model.helpers.WebModulesHelper;
+
+public class StrutsRenameStrutsConfigParticipant extends RenameParticipant {
+	public static final String PARTICIPANT_NAME="jsf-RenameStrutsConfigParticipant";
+	XModelObject object;
+	WebModulesHelper wh;
+	String module;
+	XModelObject m;
+	String path;
+	XModelObject cg;
+	String oldURI;
+	
+
+	protected boolean initialize(Object element) {
+		if(!(element instanceof IFile)) return false;
+		IFile f = (IFile)element;
+		object = EclipseResourceUtil.getObjectByResource(f);
+		if(object == null) return false;
+		String entity = object.getModelEntity().getName();
+		if(!entity.startsWith("StrutsConfig")) return false;
+		
+		wh = WebModulesHelper.getInstance(object.getModel());
+		module = "" + wh.getModuleForConfig(object);
+		m = object.getModel().getByPath("Web/" + module.replace('/', '#'));
+		path = XModelObjectLoaderUtil.getResourcePath(object);
+		cg = null;
+		XModelObject[] cgs = m.getChildren();
+		for (int i = 0; i < cgs.length; i++) {
+			if(path.equals(cgs[i].getAttributeValue(WebModuleConstants.ATTR_MODEL_PATH))) cg = cgs[i]; 
+		}
+		if(m != null && !path.equals(m.getAttributeValue(WebModuleConstants.ATTR_MODEL_PATH))) m = null;
+		oldURI = WebProject.getInstance(object.getModel()).getPathInWebRoot(object);
+		if(oldURI == null) oldURI = "/WEB-INF" + XModelObjectLoaderUtil.getResourcePath(object);
+
+		return true;
+	}
+
+	public String getName() {
+		return PARTICIPANT_NAME;
+	}
+
+	public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context) throws OperationCanceledException {
+		return null;
+	}
+
+	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+		if (!pm.isCanceled()) {
+			String newName = getArguments().getNewName();
+			if(newName == null || newName.trim().length() == 0) return null;
+			String oldName = FileAnyImpl.toFileName(object);
+			StrutsRenameStrutsConfigWebAppChange change = new StrutsRenameStrutsConfigWebAppChange(this, object, oldName, newName);
+			return change;
+		}
+		return null;
+	}
+
+}

Added: trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigWebAppChange.java
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigWebAppChange.java	                        (rev 0)
+++ trunk/struts/plugins/org.jboss.tools.struts/src/org/jboss/tools/struts/model/handlers/refactoring/StrutsRenameStrutsConfigWebAppChange.java	2008-07-22 14:36:30 UTC (rev 9203)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.struts.model.handlers.refactoring;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.jst.web.project.WebModuleConstants;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.struts.model.handlers.RenameStrutsConfigHandler;
+
+public class StrutsRenameStrutsConfigWebAppChange extends Change {
+	XModelObject folder;
+	XModelObject object;
+	String oldName;
+	String newName;
+	StrutsRenameStrutsConfigParticipant participant;
+	
+	public StrutsRenameStrutsConfigWebAppChange(StrutsRenameStrutsConfigParticipant participant, XModelObject object, String oldName, String newName) {
+		this.participant = participant;
+		this.object = object;
+		folder = object.getParent();
+		this.newName = newName;
+		this.oldName = oldName;
+	}
+
+	public String getName() {
+		return "web.xml";
+	}
+
+	public void initializeValidationData(IProgressMonitor pm) {}
+
+	public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+		return null;
+	}
+
+	public Change perform(IProgressMonitor pm) throws CoreException {
+//		String path = WebProject.getInstance(folder.getModel()).getPathInWebRoot(folder);
+//		if(path == null) path = "" + XModelObjectLoaderUtil.getResourcePath(folder);
+//		if(!path.startsWith("/")) path += "/";
+//		path += newName;
+		if(folder instanceof FolderImpl) ((FolderImpl)folder).update();
+		folder.getModel().update();
+
+		String resourcePath = XModelObjectLoaderUtil.getResourcePath(object);
+		String newURI = WebProject.getInstance(object.getModel()).getPathInWebRoot(object);
+		if(newURI == null) newURI = "/WEB-INF" + resourcePath;
+		boolean meq = (participant.m != null && participant.m.getAttributeValue("URI").equals(participant.oldURI));
+		boolean ceq = (participant.cg != null && participant.cg.getAttributeValue("URI").equals(participant.oldURI));
+		boolean replaceInWebXML = meq || ceq;
+		if(participant.m != null) participant.m.getModel().changeObjectAttribute(participant.m, WebModuleConstants.ATTR_MODEL_PATH, resourcePath);
+		if(participant.cg != null) participant.cg.getModel().changeObjectAttribute(participant.cg, WebModuleConstants.ATTR_MODEL_PATH, resourcePath);
+		XActionInvoker.invoke("SaveActions.Save", object, null); //prop?
+		object.getModel().update();
+		if(replaceInWebXML) {
+			if(meq) participant.m.getModel().changeObjectAttribute(participant.m, WebModuleConstants.ATTR_URI, newURI);
+			if(ceq) participant.cg.getModel().changeObjectAttribute(participant.cg, WebModuleConstants.ATTR_URI, newURI);
+			RenameStrutsConfigHandler.renameConfigInWebXML(object.getModel(), participant.module, participant.oldURI, newURI);
+		}
+
+		return null;
+	}
+
+	public Object getModifiedElement() {
+		return null;
+	}
+
+}




More information about the jbosstools-commits mailing list