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

Collapse All | Expand All

(-)UI/org/eclipse/rse/internal/ui/view/SystemTableViewPart.java (-27 / +55 lines)
Lines 20-25 Link Here
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
 * Xuan Chen        (IBM)        - [194838] Move the code for comparing two objects by absolute name to a common location
23
 * Kevin Doyle (IBM) - [193394] After Deleting the folder shown in Table get an error
23
 ********************************************************************************/
24
 ********************************************************************************/
24
25
25
package org.eclipse.rse.internal.ui.view;
26
package org.eclipse.rse.internal.ui.view;
Lines 28-34 Link Here
28
import java.net.URL;
29
import java.net.URL;
29
import java.util.ArrayList;
30
import java.util.ArrayList;
30
import java.util.StringTokenizer;
31
import java.util.StringTokenizer;
31
import java.util.Vector;
32
32
33
import org.eclipse.core.runtime.IAdaptable;
33
import org.eclipse.core.runtime.IAdaptable;
34
import org.eclipse.core.runtime.IProgressMonitor;
34
import org.eclipse.core.runtime.IProgressMonitor;
Lines 66-71 Link Here
66
import org.eclipse.rse.core.model.ISystemProfile;
66
import org.eclipse.rse.core.model.ISystemProfile;
67
import org.eclipse.rse.core.model.ISystemRegistry;
67
import org.eclipse.rse.core.model.ISystemRegistry;
68
import org.eclipse.rse.core.subsystems.ISubSystem;
68
import org.eclipse.rse.core.subsystems.ISubSystem;
69
import org.eclipse.rse.core.subsystems.ISystemDragDropAdapter;
69
import org.eclipse.rse.internal.ui.SystemPropertyResources;
70
import org.eclipse.rse.internal.ui.SystemPropertyResources;
70
import org.eclipse.rse.internal.ui.SystemResources;
71
import org.eclipse.rse.internal.ui.SystemResources;
71
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
72
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
Lines 1266-1272 Link Here
1266
		selectionService.removeSelectionListener(this);
1267
		selectionService.removeSelectionListener(this);
1267
		_viewer.removeSelectionChangedListener(this);
1268
		_viewer.removeSelectionChangedListener(this);
1268
1269
1269
		RSECorePlugin.getTheSystemRegistry().removeSystemResourceChangeListener(this);
1270
		ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
1271
		registry.removeSystemRemoteChangeListener(this);
1272
		registry.removeSystemResourceChangeListener(this);
1273
	
1270
		if (_viewer != null)
1274
		if (_viewer != null)
1271
		{
1275
		{
1272
			_viewer.dispose();
1276
			_viewer.dispose();
Lines 1549-1562 Link Here
1549
	 case ISystemResourceChangeEvents.EVENT_DELETE:   	    	  
1553
	 case ISystemResourceChangeEvents.EVENT_DELETE:   	    	  
1550
  	  case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
1554
  	  case ISystemResourceChangeEvents.EVENT_DELETE_MANY:
1551
  	  	{
1555
  	  	{
1552
  	      if (child instanceof ISystemFilterReference)
1556
  	  		Object[] multi = event.getMultiSource();
1553
  	      {
1557
  	  		for (int i = 0; i < multi.length; i++) {
1554
  	          
1558
  	  			// Update the history to remove all references to object
1555
  	          if (child == input)
1559
  	  			removeFromHistory(multi[i]);
1556
  	          {
1560
  	  		}
1557
  	              removeFromHistory(input);
1558
	    	  }
1559
  	      }
1560
  	  	}
1561
  	  	}
1561
  	      break;  
1562
  	      break;  
1562
  	      default:
1563
  	      default:
Lines 1567-1577 Link Here
1567
	protected void removeFromHistory(Object c)
1568
	protected void removeFromHistory(Object c)
1568
	{
1569
	{
1569
	    // if the object is in history, remove it since it's been deleted
1570
	    // if the object is in history, remove it since it's been deleted
1571
		// and remove all objects whose parent is the deleted object
1570
	    for (int i = 0; i < _browseHistory.size(); i++)
1572
	    for (int i = 0; i < _browseHistory.size(); i++)
1571
	    {
1573
	    {
1572
	        HistoryItem hist = (HistoryItem)_browseHistory.get(i);
1574
	        HistoryItem hist = (HistoryItem)_browseHistory.get(i);
1573
	        Object historyObj = hist.getObject();
1575
	        Object historyObj = hist.getObject();
1574
	        if (historyObj == c || historyObj.equals(c))
1576
	        if (historyObj == c || historyObj.equals(c) || isParentOf(c,historyObj))
1575
	        {
1577
	        {
1576
	            _browseHistory.remove(hist);
1578
	            _browseHistory.remove(hist);
1577
	            if (_browsePosition >= i)
1579
	            if (_browsePosition >= i)
Lines 1582-1606 Link Here
1582
	                    _browsePosition = 0;
1584
	                    _browsePosition = 0;
1583
	                }
1585
	                }
1584
	            }
1586
	            }
1585
	            if (hist == _currentItem)
1587
	            // 	Since we are removing an item the size decreased by one so i
1586
	            {
1588
	            // needs to decrease by one or we will skip elements in _browseHistory
1587
	                if (_browseHistory.size() > 0)
1589
	            i--;
1588
	                {
1590
	        } 
1589
	                    _currentItem = (HistoryItem)_browseHistory.get(_browsePosition);
1590
	                    setInput(_currentItem.getObject(), null, false);
1591
	                }
1592
	                else
1593
	                {
1594
	                    _currentItem = null;
1595
	                    setInput((IAdaptable)null, null, false);
1596
	                }
1597
	                
1598
	               
1599
	            }
1600
	        }
1601
	    }
1591
	    }
1592
	    
1593
	    Object currentObject = _currentItem.getObject();
1594
	    
1595
	    // Update the input of the viewer to the closest item in the history
1596
	    // that still exists if the current viewer item has been deleted.
1597
	    if (c == currentObject || c.equals(currentObject) || isParentOf(c,currentObject))
1598
        {
1599
            if (_browseHistory.size() > 0)
1600
            {
1601
                _currentItem = (HistoryItem)_browseHistory.get(_browsePosition);
1602
                setInput(_currentItem.getObject(), null, false);
1603
            }
1604
            else
1605
            {
1606
                _currentItem = null;
1607
                setInput(RSECorePlugin.getTheSystemRegistry(), null, true);
1608
            }
1609
        }
1610
	}
1611
	
1612
	protected boolean isParentOf(Object parent, Object child) {
1613
		if (parent instanceof IAdaptable && child instanceof IAdaptable) {
1614
			ISystemDragDropAdapter adapterParent = (ISystemDragDropAdapter) ((IAdaptable)parent).getAdapter(ISystemDragDropAdapter.class);
1615
			ISystemDragDropAdapter adapterChild = (ISystemDragDropAdapter) ((IAdaptable)child).getAdapter(ISystemDragDropAdapter.class);
1616
			// Check that both parent and child are from the same SubSystem
1617
			if (adapterParent != null && adapterChild != null &&
1618
					adapterParent.getSubSystem(parent) == adapterChild.getSubSystem(child)) {
1619
				String parentAbsoluteName = adapterParent.getAbsoluteName(parent);  
1620
				String childAbsoluteName = adapterChild.getAbsoluteName(child); 
1621
				// Check if the child's absolute name starts with the parents absolute name
1622
				// if it does then parent is the parent of child.
1623
				if(childAbsoluteName != null && childAbsoluteName.startsWith(parentAbsoluteName)) {
1624
					return true;
1625
				}
1626
			}
1627
		}
1628
		return false;
1602
	}
1629
	}
1603
	
1630
	
1631
	
1604
	/**
1632
	/**
1605
	 * This is the method in your class that will be called when a remote resource
1633
	 * This is the method in your class that will be called when a remote resource
1606
	 *  changes. You will be called after the resource is changed.
1634
	 *  changes. You will be called after the resource is changed.

Return to bug 193394