View | Details | Raw Unified | Return to bug 194838 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/rse/ui/internal/model/SystemRegistry.java (+79 lines)
Lines 31-36 Link Here
31
 * Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core
31
 * Martin Oberhuber (Wind River) - [189123] Move renameSubSystemProfile() from UI to Core
32
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
32
 * Martin Oberhuber (Wind River) - [175680] Deprecate obsolete ISystemRegistry methods
33
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
33
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
34
 * Xuan Chen        (IBM)        - [194838] Move the code for comparing two objects by absolute name to a common location
34
 ********************************************************************************/
35
 ********************************************************************************/
35
36
36
package org.eclipse.rse.ui.internal.model;
37
package org.eclipse.rse.ui.internal.model;
Lines 40-45 Link Here
40
import java.util.List;
41
import java.util.List;
41
import java.util.Vector;
42
import java.util.Vector;
42
43
44
import org.eclipse.core.runtime.IAdaptable;
43
import org.eclipse.core.runtime.IProgressMonitor;
45
import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.core.runtime.Platform;
46
import org.eclipse.core.runtime.Platform;
45
import org.eclipse.core.runtime.jobs.ISchedulingRule;
47
import org.eclipse.core.runtime.jobs.ISchedulingRule;
Lines 79-84 Link Here
79
import org.eclipse.rse.core.subsystems.ISubSystem;
81
import org.eclipse.rse.core.subsystems.ISubSystem;
80
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
82
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
81
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
83
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
84
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
82
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
85
import org.eclipse.rse.internal.core.filters.SystemFilterStartHere;
83
import org.eclipse.rse.internal.core.model.SystemHostPool;
86
import org.eclipse.rse.internal.core.model.SystemHostPool;
84
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
87
import org.eclipse.rse.internal.core.model.SystemModelChangeEvent;
Lines 1027-1032 Link Here
1027
		dataStream.append(factoryId);
1030
		dataStream.append(factoryId);
1028
		return dataStream.toString();
1031
		return dataStream.toString();
1029
	}
1032
	}
1033
	
1034
	/**
1035
	 * Check if two objects refers to the same system object by comparing it absoluteName with its subsystem id.
1036
	 * 
1037
	 * @param firstObject the first object to compare
1038
	 * @param firstObjectFullName the full name of the firstObject.  If null, get the full name from the firstObject
1039
	 * @param secondObject the second object to compare
1040
	 * @param secondObjectFullName the full name of the secondObject. If null, get the full name from the secondObject
1041
	 */
1042
	public boolean isSameObjectByAbsoluteName(Object firstObject, String firstObjectFullName, Object secondObject, String secondObjectFullName)
1043
	{
1044
		if (firstObject == secondObject)
1045
		{
1046
			return true;
1047
		}
1048
		String firstObjectAbsoluteNameWithSubSystemId = null;
1049
		
1050
		//Simply doing comparason of if two object is equal is not enough
1051
		//If two different objects, but if their absoluate path (with subsystem id)
1052
		//are the same, they refer to the same remote object.
1053
		
1054
		if(firstObject instanceof IAdaptable) 
1055
		{
1056
			ISystemDragDropAdapter adapter = null;
1057
	    	
1058
			adapter = (ISystemDragDropAdapter)((IAdaptable)firstObject).getAdapter(ISystemDragDropAdapter.class);
1059
      	
1060
      	  	if (adapter != null ) {
1061
      		  // first need to check subsystems
1062
      		  ISubSystem subSystem = adapter.getSubSystem(firstObject);
1063
      		  String subSystemId = getAbsoluteNameForSubSystem(subSystem);
1064
      		  if (firstObjectFullName != null)
1065
      		  {
1066
      			firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + firstObjectFullName; //$NON-NLS-1$
1067
      		  }
1068
      		  else
1069
      		  {
1070
      			  String absolutePath = adapter.getAbsoluteName(firstObject);
1071
      			  firstObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath;  //$NON-NLS-1$
1072
      		  }
1073
      			 
1074
	      }
1075
        }
1076
		
1077
		
1078
		String secondObjectAbsoluteNameWithSubSystemId = null;
1079
		if(secondObject instanceof IAdaptable) 
1080
		{
1081
			ISystemDragDropAdapter adapter = null;
1082
	    	
1083
			adapter = (ISystemDragDropAdapter)((IAdaptable)secondObject).getAdapter(ISystemDragDropAdapter.class);
1084
      	
1085
      	  	if (adapter != null ) {
1086
      		  // first need to check subsystems
1087
      		  ISubSystem subSystem = adapter.getSubSystem(secondObject);
1088
      		  String subSystemId = getAbsoluteNameForSubSystem(subSystem);
1089
      		  if (secondObjectFullName != null)
1090
    		  {
1091
    			secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + secondObjectFullName; //$NON-NLS-1$
1092
    		  }
1093
    		  else
1094
    		  {
1095
    			  String absolutePath = adapter.getAbsoluteName(secondObject);
1096
    			  secondObjectAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath;  //$NON-NLS-1$
1097
    		  }
1098
      			 
1099
	      }
1100
        }
1101
		
1102
		if (firstObjectAbsoluteNameWithSubSystemId != null && firstObjectAbsoluteNameWithSubSystemId.equals(secondObjectAbsoluteNameWithSubSystemId))
1103
		{
1104
			return true;
1105
		}
1106
		
1107
		return false;
1108
	}
1030
1109
1031
	 /*
1110
	 /*
1032
	  * (non-Javadoc)
1111
	  * (non-Javadoc)
(-)UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java (-38 / +6 lines)
Lines 19-24 Link Here
19
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
19
 * Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
20
 * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections
20
 * David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections
21
 * Xuan Chen        (IBM)        - [192716] Refresh Error in Table View after Renaming folder shown in table
21
 * Xuan Chen        (IBM)        - [192716] Refresh Error in Table View after Renaming folder shown in table
22
 * Xuan Chen        (IBM)        - [194838] Move the code for comparing two objects by absolute name to a common location
22
 ********************************************************************************/
23
 ********************************************************************************/
23
24
24
package org.eclipse.rse.internal.ui.view;
25
package org.eclipse.rse.internal.ui.view;
Lines 80-85 Link Here
80
import org.eclipse.rse.ui.actions.SystemTablePrintAction;
81
import org.eclipse.rse.ui.actions.SystemTablePrintAction;
81
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
82
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
82
import org.eclipse.rse.ui.dialogs.SystemSelectAnythingDialog;
83
import org.eclipse.rse.ui.dialogs.SystemSelectAnythingDialog;
84
import org.eclipse.rse.ui.internal.model.SystemRegistry;
83
import org.eclipse.rse.ui.messages.ISystemMessageLine;
85
import org.eclipse.rse.ui.messages.ISystemMessageLine;
84
import org.eclipse.rse.ui.model.ISystemShellProvider;
86
import org.eclipse.rse.ui.model.ISystemShellProvider;
85
import org.eclipse.rse.ui.view.IRSEViewPart;
87
import org.eclipse.rse.ui.view.IRSEViewPart;
Lines 1608-1614 Link Here
1608
	{
1610
	{
1609
		int eventType = event.getEventType();
1611
		int eventType = event.getEventType();
1610
		Object remoteResource = event.getResource();
1612
		Object remoteResource = event.getResource();
1611
		String inputAbsoluteNameWithSubSystemId = null;
1612
		Vector remoteResourceNames = null;
1613
		Vector remoteResourceNames = null;
1613
		if (remoteResource instanceof Vector)
1614
		if (remoteResource instanceof Vector)
1614
		{
1615
		{
Lines 1621-1667 Link Here
1621
		
1622
		
1622
		Object input = _viewer.getInput();
1623
		Object input = _viewer.getInput();
1623
		
1624
		
1624
		//Simply doing comparason of if two object is equal is not enough
1625
		ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
1625
		//If two different objects, but if their absoluate path (with subsystem id)
1626
		//are the same, they refer to the same remote object.
1627
		
1628
		if(input instanceof IAdaptable) 
1629
		{
1630
      	  	ISystemViewElementAdapter adapter =
1631
      		  (ISystemViewElementAdapter)
1632
      		  ((IAdaptable)input).getAdapter(ISystemViewElementAdapter.class);
1633
      	
1634
      	  	if (adapter != null ) {
1635
      		  // first need to check subsystems
1636
      		  ISubSystem subSystem = adapter.getSubSystem(input);
1637
      		  String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem);
1638
      		  String absolutePath = adapter.getAbsoluteName(input);
1639
      		  inputAbsoluteNameWithSubSystemId = subSystemId + ":" + absolutePath;  //$NON-NLS-1$
1640
      			 
1641
	      }
1642
        }
1643
		
1644
		String remoteResourceAbsoluteNameWithSubSystemId = null;
1645
		if(child instanceof IAdaptable) 
1646
		{
1647
      	  	ISystemViewElementAdapter adapter =
1648
      		  (ISystemViewElementAdapter)
1649
      		  ((IAdaptable)child).getAdapter(ISystemViewElementAdapter.class);
1650
      	
1651
      	  	if (adapter != null ) {
1652
      		  // first need to check subsystems
1653
      		  ISubSystem subSystem = adapter.getSubSystem(child);
1654
      		  String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem);
1655
      		remoteResourceAbsoluteNameWithSubSystemId = subSystemId + ":" + event.getOldName();  //$NON-NLS-1$
1656
      			 
1657
	      }
1658
        }
1659
		
1626
		
1660
		boolean referToSameObject = false;
1627
		boolean referToSameObject = false;
1661
		if (inputAbsoluteNameWithSubSystemId != null && inputAbsoluteNameWithSubSystemId.equals(remoteResourceAbsoluteNameWithSubSystemId))
1628
		if (registry instanceof SystemRegistry)
1662
		{
1629
		{
1663
			referToSameObject = true;
1630
			referToSameObject = ((SystemRegistry)registry).isSameObjectByAbsoluteName(input, null, child, event.getOldName());
1664
		}
1631
		}
1632
		
1665
		if (input == child || child instanceof Vector || referToSameObject)
1633
		if (input == child || child instanceof Vector || referToSameObject)
1666
		{ 
1634
		{ 
1667
			switch (eventType)
1635
			switch (eventType)

Return to bug 194838