1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-29 19:23:38 +02:00

[193394] Kevin's patch update for grandparents and beyond

This commit is contained in:
David McKnight 2007-07-23 19:20:55 +00:00
parent 4792c8bb08
commit 04ed333f43

View file

@ -20,6 +20,7 @@
* 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
* Kevin Doyle (IBM) - [193394] After Deleting the folder shown in Table get an error
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -28,7 +29,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@ -66,6 +66,7 @@ import org.eclipse.rse.core.model.ISystemContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
import org.eclipse.rse.internal.ui.SystemPropertyResources;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
@ -1266,7 +1267,10 @@ public class SystemTableViewPart extends ViewPart
selectionService.removeSelectionListener(this);
_viewer.removeSelectionChangedListener(this);
RSECorePlugin.getTheSystemRegistry().removeSystemResourceChangeListener(this);
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
registry.removeSystemRemoteChangeListener(this);
registry.removeSystemResourceChangeListener(this);
if (_viewer != null)
{
_viewer.dispose();
@ -1549,13 +1553,10 @@ public class SystemTableViewPart extends ViewPart
case ISystemResourceChangeEvents.EVENT_DELETE:
case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
{
if (child instanceof ISystemFilterReference)
{
if (child == input)
{
removeFromHistory(input);
}
Object[] multi = event.getMultiSource();
for (int i = 0; i < multi.length; i++) {
// Update the history to remove all references to object
removeFromHistory(multi[i]);
}
}
break;
@ -1567,11 +1568,12 @@ public class SystemTableViewPart extends ViewPart
protected void removeFromHistory(Object c)
{
// if the object is in history, remove it since it's been deleted
// and remove all objects whose parent is the deleted object
for (int i = 0; i < _browseHistory.size(); i++)
{
HistoryItem hist = (HistoryItem)_browseHistory.get(i);
Object historyObj = hist.getObject();
if (historyObj == c || historyObj.equals(c))
if (historyObj == c || historyObj.equals(c) || isParentOf(c,historyObj))
{
_browseHistory.remove(hist);
if (_browsePosition >= i)
@ -1582,7 +1584,17 @@ public class SystemTableViewPart extends ViewPart
_browsePosition = 0;
}
}
if (hist == _currentItem)
// Since we are removing an item the size decreased by one so i
// needs to decrease by one or we will skip elements in _browseHistory
i--;
}
}
Object currentObject = _currentItem.getObject();
// Update the input of the viewer to the closest item in the history
// that still exists if the current viewer item has been deleted.
if (c == currentObject || c.equals(currentObject) || isParentOf(c,currentObject))
{
if (_browseHistory.size() > 0)
{
@ -1592,14 +1604,30 @@ public class SystemTableViewPart extends ViewPart
else
{
_currentItem = null;
setInput((IAdaptable)null, null, false);
setInput(RSECorePlugin.getTheSystemRegistry(), null, true);
}
}
}
protected boolean isParentOf(Object parent, Object child) {
if (parent instanceof IAdaptable && child instanceof IAdaptable) {
ISystemDragDropAdapter adapterParent = (ISystemDragDropAdapter) ((IAdaptable)parent).getAdapter(ISystemDragDropAdapter.class);
ISystemDragDropAdapter adapterChild = (ISystemDragDropAdapter) ((IAdaptable)child).getAdapter(ISystemDragDropAdapter.class);
// Check that both parent and child are from the same SubSystem
if (adapterParent != null && adapterChild != null &&
adapterParent.getSubSystem(parent) == adapterChild.getSubSystem(child)) {
String parentAbsoluteName = adapterParent.getAbsoluteName(parent);
String childAbsoluteName = adapterChild.getAbsoluteName(child);
// Check if the child's absolute name starts with the parents absolute name
// if it does then parent is the parent of child.
if(childAbsoluteName != null && childAbsoluteName.startsWith(parentAbsoluteName)) {
return true;
}
}
}
return false;
}
}
}
}
}
/**
* This is the method in your class that will be called when a remote resource