1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-05 16:15:25 +02:00

[194838] Xuan's patch to put common compare code in SystemRegistry.

This commit is contained in:
David McKnight 2007-07-09 13:17:34 +00:00
parent c2ea0b8e54
commit a5e0c80933
2 changed files with 85 additions and 38 deletions

View file

@ -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.SystemRefreshAction;
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 @@ public class SystemTableViewPart extends ViewPart
{
int eventType = event.getEventType();
Object remoteResource = event.getResource();
String inputAbsoluteNameWithSubSystemId = null;
Vector remoteResourceNames = null;
if (remoteResource instanceof Vector)
{
@ -1621,47 +1622,14 @@ public class SystemTableViewPart extends ViewPart
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)

View file

@ -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.Iterator;
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.IServiceSubSystemConfiguration;
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 @@ public class SystemRegistry implements ISystemRegistry
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)