### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.ui Index: model/org/eclipse/rse/ui/internal/model/SystemRegistry.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/internal/model/SystemRegistry.java,v retrieving revision 1.27 diff -u -r1.27 SystemRegistry.java --- model/org/eclipse/rse/ui/internal/model/SystemRegistry.java 27 Jun 2007 12:46:09 -0000 1.27 +++ model/org/eclipse/rse/ui/internal/model/SystemRegistry.java 8 Jul 2007 05:58:55 -0000 @@ -31,6 +31,7 @@ * Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core + * Xuan Chen (IBM) - [194838] Move the code for comparing two objects by absolute name to a common location ********************************************************************************/ package org.eclipse.rse.ui.internal.model; @@ -40,6 +41,7 @@ import java.util.List; import java.util.Vector; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -79,6 +81,7 @@ import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; +import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter; import org.eclipse.rse.internal.core.filters.SystemFilterStartHere; import org.eclipse.rse.internal.core.model.SystemHostPool; import org.eclipse.rse.internal.core.model.SystemModelChangeEvent; @@ -1027,6 +1030,82 @@ dataStream.append(factoryId); return dataStream.toString(); } + + /** + * Check if two objects refers to the same system object by comparing it absoluteName with its subsystem id. + * + * @param firstObject the first object to compare + * @param firstObjectFullName the full name of the firstObject. If null, get the full name from the firstObject + * @param secondObject the second object to compare + * @param secondObjectFullName the full name of the secondObject. If null, get the full name from the secondObject + */ + public boolean isSameObjectByAbsoluteName(Object firstObject, String firstObjectFullName, Object secondObject, String secondObjectFullName) + { + if (firstObject == secondObject) + { + return true; + } + String firstObjectAbsoluteNameWithSubSystemId = null; + + //Simply doing comparason of if two object is equal is not enough + //If two different objects, but if their absoluate path (with subsystem id) + //are the same, they refer to the same remote object. + + if(firstObject instanceof IAdaptable) + { + ISystemDragDropAdapter adapter = null; + + adapter = (ISystemDragDropAdapter)((IAdaptable)firstObject).getAdapter(ISystemDragDropAdapter.class); + + if (adapter != null ) { + // first need to check subsystems + ISubSystem subSystem = adapter.getSubSystem(firstObject); + String subSystemId = getAbsoluteNameForSubSystem(subSystem); + if (firstObjectFullName != null) + { + firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + firstObjectFullName; //$NON-NLS-1$ + } + else + { + String absolutePath = adapter.getAbsoluteName(firstObject); + firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$ + } + + } + } + + + String secondObjectAbsoluteNameWithSubSystemId = null; + if(secondObject instanceof IAdaptable) + { + ISystemDragDropAdapter adapter = null; + + adapter = (ISystemDragDropAdapter)((IAdaptable)secondObject).getAdapter(ISystemDragDropAdapter.class); + + if (adapter != null ) { + // first need to check subsystems + ISubSystem subSystem = adapter.getSubSystem(secondObject); + String subSystemId = getAbsoluteNameForSubSystem(subSystem); + if (secondObjectFullName != null) + { + secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + secondObjectFullName; //$NON-NLS-1$ + } + else + { + String absolutePath = adapter.getAbsoluteName(secondObject); + secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$ + } + + } + } + + if (firstObjectAbsoluteNameWithSubSystemId != null && firstObjectAbsoluteNameWithSubSystemId.equals(secondObjectAbsoluteNameWithSubSystemId)) + { + return true; + } + + return false; + } /* * (non-Javadoc) Index: UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java,v retrieving revision 1.17 diff -u -r1.17 SystemTableViewPart.java --- UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java 28 Jun 2007 19:41:37 -0000 1.17 +++ UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java 8 Jul 2007 05:58:54 -0000 @@ -19,6 +19,7 @@ * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections * Xuan Chen (IBM) - [192716] Refresh Error in Table View after Renaming folder shown in table + * Xuan Chen (IBM) - [194838] Move the code for comparing two objects by absolute name to a common location ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -80,6 +81,7 @@ import org.eclipse.rse.ui.actions.SystemTablePrintAction; import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.dialogs.SystemSelectAnythingDialog; +import org.eclipse.rse.ui.internal.model.SystemRegistry; import org.eclipse.rse.ui.messages.ISystemMessageLine; import org.eclipse.rse.ui.model.ISystemShellProvider; import org.eclipse.rse.ui.view.IRSEViewPart; @@ -1608,7 +1610,6 @@ { int eventType = event.getEventType(); Object remoteResource = event.getResource(); - String inputAbsoluteNameWithSubSystemId = null; Vector remoteResourceNames = null; if (remoteResource instanceof Vector) { @@ -1621,47 +1622,14 @@ Object input = _viewer.getInput(); - //Simply doing comparason of if two object is equal is not enough - //If two different objects, but if their absoluate path (with subsystem id) - //are the same, they refer to the same remote object. - - if(input instanceof IAdaptable) - { - ISystemViewElementAdapter adapter = - (ISystemViewElementAdapter) - ((IAdaptable)input).getAdapter(ISystemViewElementAdapter.class); - - if (adapter != null ) { - // first need to check subsystems - ISubSystem subSystem = adapter.getSubSystem(input); - String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem); - String absolutePath = adapter.getAbsoluteName(input); - inputAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath; //$NON-NLS-1$ - - } - } - - String remoteResourceAbsoluteNameWithSubSystemId = null; - if(child instanceof IAdaptable) - { - ISystemViewElementAdapter adapter = - (ISystemViewElementAdapter) - ((IAdaptable)child).getAdapter(ISystemViewElementAdapter.class); - - if (adapter != null ) { - // first need to check subsystems - ISubSystem subSystem = adapter.getSubSystem(child); - String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem); - remoteResourceAbsoluteNameWithSubSystemId = subSystemId + ":" + event.getOldName(); //$NON-NLS-1$ - - } - } + ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); boolean referToSameObject = false; - if (inputAbsoluteNameWithSubSystemId != null && inputAbsoluteNameWithSubSystemId.equals(remoteResourceAbsoluteNameWithSubSystemId)) + if (registry instanceof SystemRegistry) { - referToSameObject = true; + referToSameObject = ((SystemRegistry)registry).isSameObjectByAbsoluteName(input, null, child, event.getOldName()); } + if (input == child || child instanceof Vector || referToSameObject) { switch (eventType)