[jbosstools-commits] JBoss Tools SVN: r36034 - in trunk/esb/plugins/org.jboss.tools.esb.core: resources/meta and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Oct 26 20:58:11 EDT 2011


Author: scabanovich
Date: 2011-10-26 20:58:11 -0400 (Wed, 26 Oct 2011)
New Revision: 36034

Added:
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDHandler.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDParticipant.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDProcessor.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDHandler.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDParticipant.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDProcessor.java
Modified:
   trunk/esb/plugins/org.jboss.tools.esb.core/plugin.xml
   trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta
   trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb12.meta
   trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb13.meta
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/ESBCoreMessages.java
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/messages.properties
   trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/ESBConstants.java
Log:
JBIDE-8571
https://issues.jboss.org/browse/JBIDE-8571
Refactor/Rename in ESB editor for channel id and for schedule id is implemented.

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/plugin.xml	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/plugin.xml	2011-10-27 00:58:11 UTC (rev 36034)
@@ -64,8 +64,10 @@
 		<xclass id="org.jboss.tools.esb.core.model.handlers.AddBPELInvokeHandler"
 			class="org.jboss.tools.esb.core.model.handlers.AddBPELInvokeHandler"/>
 
-		<xclass id="org.jboss.tools.esb.core.model.handlers.ESBDefaultVersionResolver"
-			class="org.jboss.tools.esb.core.model.handlers.ESBDefaultVersionResolver"/>
+		<xclass id="org.jboss.tools.esb.core.model.handlers.RenameChannelIDHandler"
+			class="org.jboss.tools.esb.core.model.handlers.RenameChannelIDHandler"/>
+		<xclass id="org.jboss.tools.esb.core.model.handlers.RenameScheduleIDHandler"
+			class="org.jboss.tools.esb.core.model.handlers.RenameScheduleIDHandler"/>
 			
 		<xclass id="org.jboss.tools.esb.core.model.ESBResourceTree"
 			class="org.jboss.tools.esb.core.model.ESBResourceTree"/>
@@ -112,4 +114,45 @@
       </catalogContribution>
    </extension>
 
+   <extension
+         point="org.eclipse.ltk.core.refactoring.renameParticipants">
+      <renameParticipant
+            class="org.jboss.tools.esb.core.model.handlers.RenameChannelIDParticipant"
+            id="org.jboss.tools.esb.core.model.handlers.RenameChannelIDParticipant"
+            name="esb-RenameChannelIDParticipant">
+         <enablement>
+            <with variable="affectedNatures">
+               <iterate operator="or">
+                  <equals value="org.eclipse.wst.common.project.facet.core.nature"/>
+               </iterate>
+            </with>
+            <with variable="element">
+                <or>
+                   <instanceof value="org.jboss.tools.esb.core.model.ESBCustomizedObjectImpl"/>
+                </or>
+            </with>
+         </enablement>
+      </renameParticipant>
+
+      <renameParticipant
+            class="org.jboss.tools.esb.core.model.handlers.RenameScheduleIDParticipant"
+            id="org.jboss.tools.esb.core.model.handlers.RenameScheduleIDParticipant"
+            name="esb-RenameScheduleIDParticipant">
+         <enablement>
+            <with variable="affectedNatures">
+               <iterate operator="or">
+                  <equals value="org.eclipse.wst.common.project.facet.core.nature"/>
+               </iterate>
+            </with>
+            <with variable="element">
+                <or>
+                   <instanceof value="org.jboss.tools.esb.core.model.ESBCustomizedObjectImpl"/>
+                </or>
+            </with>
+         </enablement>
+      </renameParticipant>
+
+   </extension>
+
+
 </plugin>

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb.meta	2011-10-27 00:58:11 UTC (rev 36034)
@@ -301,7 +301,11 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItem
+     HandlerClassName="org.jboss.tools.esb.core.model.handlers.RenameChannelIDHandler"
+     ICON="action.empty" displayName="Rename..." kind="action" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -398,7 +402,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBSimpleSchedule101" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -432,7 +438,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -637,7 +645,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -867,7 +877,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -992,7 +1004,9 @@
      </EntityData>
     </XActionItem>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -1160,7 +1174,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -1397,7 +1413,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -2145,7 +2163,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -2702,7 +2722,11 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItem
+     HandlerClassName="org.jboss.tools.esb.core.model.handlers.RenameScheduleIDHandler"
+     ICON="action.empty" displayName="Rename..." kind="action" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb12.meta
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb12.meta	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb12.meta	2011-10-27 00:58:11 UTC (rev 36034)
@@ -493,7 +493,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>
@@ -619,7 +621,9 @@
    <XActionItem kind="list" name="CreateActions">
     <XActionItemReference entity="ESBAction101" name="AddProperty" path="CreateActions/AddProperty"/>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb13.meta
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb13.meta	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/resources/meta/esb13.meta	2011-10-27 00:58:11 UTC (rev 36034)
@@ -120,7 +120,9 @@
      </EntityData>
     </XActionItem>
    </XActionItem>
-   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions"/>
+   <XActionItem ICON="action.empty" displayName="Create" kind="list" name="EditActions">
+    <XActionItemReference entity="ESBBus" name="Rename"/>
+   </XActionItem>
    <XActionItemReference entity="ESBProperty" name="CopyActions"/>
    <XActionItemReference entity="ESBProperty" name="DeleteActions"/>
    <XActionItemReference entity="ESBProperty" name="Properties"/>

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/ESBCoreMessages.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/ESBCoreMessages.java	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/ESBCoreMessages.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -16,6 +16,14 @@
 	private static final String BUNDLE_NAME = "org.jboss.tools.esb.core.messages"; //$NON-NLS-1$
 
 	public static String ESB_CORE_PLUGIN_NO_MESSAGE;
+	
+	public static String REFERENCES;
+	public static String CHANNEL_ID_REFACTORING;
+	public static String CHANNEL_ID;
+	public static String CHANNEL_ID_REF;
+	public static String SCHEDULE_ID;
+	public static String SCHEDULE_ID_REF;
+
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, ESBCoreMessages.class);
 	}

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/messages.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/messages.properties	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/messages.properties	2011-10-27 00:58:11 UTC (rev 36034)
@@ -1 +1,9 @@
 ESB_CORE_PLUGIN_NO_MESSAGE=No message
+
+REFERENCES = References
+CHANNEL_ID_REFACTORING=Channel ID Refactoring
+CHANNEL_ID=Channel ID
+CHANNEL_ID_REF=Channel ID Ref
+
+SCHEDULE_ID=Schedule ID
+SCHEDULE_ID_REF=Schedule ID Ref

Modified: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/ESBConstants.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/ESBConstants.java	2011-10-27 00:56:17 UTC (rev 36033)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/ESBConstants.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -178,6 +178,8 @@
 	public String ATTR_PROPERTY_VALUE_PRESENTATION = "value presentation"; //$NON-NLS-1$
 	public String ATTR_BUS_ID = "id"; //$NON-NLS-1$
 	public String ATTR_BUS_ID_REF = "channel id ref"; //$NON-NLS-1$
+	public String ATTR_SCHEDULE_ID = "schedule id"; //$NON-NLS-1$
+	public String ATTR_SCHEDULE_ID_REF = "schedule id ref"; //$NON-NLS-1$
 
 	public String XML_ATTR_PROTECTED_METHODS = "protected-methods"; //$NON-NLS-1$
 }

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDHandler.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDHandler.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDHandler.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import java.util.*;
+
+import org.jboss.tools.common.meta.action.impl.*;
+import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.refactoring.RenameProcessorRunner;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameChannelIDHandler extends AbstractHandler {
+
+	public boolean isEnabled(XModelObject object) {
+		return (object != null && object.isObjectEditable());
+	}
+
+	public void executeHandler(XModelObject object, Properties p) throws XModelException {
+		if(!isEnabled(object)) return;
+		RenameChannelIDProcessor processor = new RenameChannelIDProcessor();
+		processor.setModelObject(object);
+		String name = object.getAttributeValue(ESBConstants.ATTR_BUS_ID);
+		RenameProcessorRunner.run(processor, name);
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDParticipant.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDParticipant.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDParticipant.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.ltk.core.refactoring.*;
+import org.eclipse.ltk.core.refactoring.participants.*;
+import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.refactoring.RenameModelObjectChange;
+import org.jboss.tools.common.model.refactoring.RenameProcessorRunner;
+import org.jboss.tools.esb.core.ESBCoreMessages;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameChannelIDParticipant extends RenameParticipant implements ISharableParticipant {
+	public static final String PARTICIPANT_NAME="esb-RenameChannelIDParticipant"; //$NON-NLS-1$
+	private XModelObject object;
+
+	public RenameChannelIDParticipant() {}
+
+	protected boolean initialize(Object element) {
+		if(element instanceof XModelObject) {
+			object = (XModelObject)element;
+			if(object.getModelEntity().getAttribute(ESBConstants.ATTR_BUS_ID) == null) {
+				object = null;
+			}
+		}
+		return object != null;
+	}
+
+	public void addElement(Object element, RefactoringArguments arguments) {
+	}
+
+	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()) {
+			if(!updateReferences() && object == null) {
+				return null;
+			}
+			String newName = getArguments().getNewName();
+			XModelObject f = FileSystemsHelper.getFile(object);
+			if(f != null) {
+				RenameModelObjectChange c1 = RenameModelObjectChange.createChange(f, newName);
+				if(c1 != null) {
+					c1.addEdits(new XModelObject[]{object}, ESBConstants.ATTR_BUS_ID, ESBCoreMessages.CHANNEL_ID);
+				
+					if(updateReferences()) {
+						String oldName = object.getAttributeValue(ESBConstants.ATTR_BUS_ID);
+						XModelObject[] rs = getRefs(oldName);
+						if(rs.length > 0) {
+							c1.addEdits(rs, ESBConstants.ATTR_BUS_ID_REF, ESBCoreMessages.CHANNEL_ID_REF);
+						}
+					}
+				}
+				
+				return c1;
+			}
+		}
+		return null;
+	}
+	
+	protected boolean updateReferences() {
+		return RenameProcessorRunner.updateReferences(getProcessor());
+	}
+
+	private XModelObject[] getRefs(String oldName) {
+		List<XModelObject> list = new ArrayList<XModelObject>();
+		collectRefs(list, FileSystemsHelper.getFile(object), oldName);
+		return list.toArray(new XModelObject[list.size()]);
+	}
+
+	private void collectRefs(List<XModelObject> list, XModelObject o, String oldName) {
+		if(oldName.equals(o.getAttributeValue(ESBConstants.ATTR_BUS_ID_REF))) {
+			list.add(o);
+		}
+		XModelObject[] cs = o.getChildren();
+		for (XModelObject c: cs) {
+			collectRefs(list, c, oldName);
+		}
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDParticipant.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDProcessor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDProcessor.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDProcessor.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.common.model.refactoring.ModelRenameProcessor;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameChannelIDProcessor extends ModelRenameProcessor {
+	public static final String IDENTIFIER = "org.jboss.tools.esb.core.renameChannelIDProcessor"; //$NON-NLS-1$
+
+	public String[] getAffectedProjectNatures() throws CoreException {
+		return new String[]{"org.eclipse.wst.common.project.facet.core.nature"};
+	}
+
+	@Override
+	protected String getPropertyName() {
+		return ESBConstants.ATTR_BUS_ID;
+	}
+
+	@Override
+	public String getIdentifier() {
+		return IDENTIFIER;
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameChannelIDProcessor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDHandler.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDHandler.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDHandler.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import java.util.*;
+
+import org.jboss.tools.common.meta.action.impl.*;
+import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.refactoring.RenameProcessorRunner;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameScheduleIDHandler extends AbstractHandler {
+
+	public boolean isEnabled(XModelObject object) {
+		return (object != null && object.isObjectEditable());
+	}
+
+	public void executeHandler(XModelObject object, Properties p) throws XModelException {
+		if(!isEnabled(object)) return;
+		RenameScheduleIDProcessor processor = new RenameScheduleIDProcessor();
+		processor.setModelObject(object);
+		String name = object.getAttributeValue(ESBConstants.ATTR_SCHEDULE_ID);
+		RenameProcessorRunner.run(processor, name);
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDParticipant.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDParticipant.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDParticipant.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.ltk.core.refactoring.*;
+import org.eclipse.ltk.core.refactoring.participants.*;
+import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.refactoring.RenameModelObjectChange;
+import org.jboss.tools.common.model.refactoring.RenameProcessorRunner;
+import org.jboss.tools.esb.core.ESBCoreMessages;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameScheduleIDParticipant extends RenameParticipant implements ISharableParticipant {
+	public static final String PARTICIPANT_NAME="esb-RenameScheduleIDParticipant"; //$NON-NLS-1$
+	private XModelObject object;
+
+	public RenameScheduleIDParticipant() {}
+
+	protected boolean initialize(Object element) {
+		if(element instanceof XModelObject) {
+			object = (XModelObject)element;
+			if(object.getModelEntity().getAttribute(ESBConstants.ATTR_SCHEDULE_ID) == null) {
+				object = null;
+			}
+		}
+		return object != null;
+	}
+
+	public void addElement(Object element, RefactoringArguments arguments) {
+	}
+
+	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()) {
+			if(!updateReferences() && object == null) {
+				return null;
+			}
+			String newName = getArguments().getNewName();
+			XModelObject f = FileSystemsHelper.getFile(object);
+			if(f != null) {
+				RenameModelObjectChange c1 = RenameModelObjectChange.createChange(f, newName);
+				if(c1 != null) {
+					c1.addEdits(new XModelObject[]{object}, ESBConstants.ATTR_SCHEDULE_ID, ESBCoreMessages.SCHEDULE_ID);
+				
+					if(updateReferences()) {
+						String oldName = object.getAttributeValue(ESBConstants.ATTR_SCHEDULE_ID);
+						XModelObject[] rs = getRefs(oldName);
+						if(rs.length > 0) {
+							c1.addEdits(rs, ESBConstants.ATTR_SCHEDULE_ID_REF, ESBCoreMessages.SCHEDULE_ID_REF);
+						}
+					}
+				}
+				
+				return c1;
+			}
+		}
+		return null;
+	}
+	
+	protected boolean updateReferences() {
+		return RenameProcessorRunner.updateReferences(getProcessor());
+	}
+
+	private XModelObject[] getRefs(String oldName) {
+		List<XModelObject> list = new ArrayList<XModelObject>();
+		collectRefs(list, FileSystemsHelper.getFile(object), oldName);
+		return list.toArray(new XModelObject[list.size()]);
+	}
+
+	private void collectRefs(List<XModelObject> list, XModelObject o, String oldName) {
+		if(oldName.equals(o.getAttributeValue(ESBConstants.ATTR_SCHEDULE_ID_REF))) {
+			list.add(o);
+		}
+		XModelObject[] cs = o.getChildren();
+		for (XModelObject c: cs) {
+			collectRefs(list, c, oldName);
+		}
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDParticipant.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDProcessor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDProcessor.java	                        (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDProcessor.java	2011-10-27 00:58:11 UTC (rev 36034)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ *     Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.esb.core.model.handlers;
+
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.common.model.refactoring.ModelRenameProcessor;
+import org.jboss.tools.esb.core.model.ESBConstants;
+
+/**
+ * 
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class RenameScheduleIDProcessor extends ModelRenameProcessor {
+	public static final String IDENTIFIER = "org.jboss.tools.esb.core.renameScheduleIDProcessor"; //$NON-NLS-1$
+
+	public String[] getAffectedProjectNatures() throws CoreException {
+		return new String[]{"org.eclipse.wst.common.project.facet.core.nature"};
+	}
+
+	@Override
+	protected String getPropertyName() {
+		return ESBConstants.ATTR_SCHEDULE_ID;
+	}
+
+	@Override
+	public String getIdentifier() {
+		return IDENTIFIER;
+	}
+
+}


Property changes on: trunk/esb/plugins/org.jboss.tools.esb.core/src/org/jboss/tools/esb/core/model/handlers/RenameScheduleIDProcessor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list