Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 204684 | Differences between
and this patch

Collapse All | Expand All

(-)UI/org/eclipse/rse/internal/ui/view/SystemView.java (-4 / +108 lines)
Lines 41-46 Link Here
41
 * Kevin Doyle (IBM) 			 - [196582] Deprecated getRemoteObjectIdentifier
41
 * Kevin Doyle (IBM) 			 - [196582] Deprecated getRemoteObjectIdentifier
42
 * Martin Oberhuber (Wind River) - [198650] Fix assertion when restoring workbench state
42
 * Martin Oberhuber (Wind River) - [198650] Fix assertion when restoring workbench state
43
 * Martin Oberhuber (Wind River) - [183176] Fix "widget is disposed" during Platform shutdown
43
 * Martin Oberhuber (Wind River) - [183176] Fix "widget is disposed" during Platform shutdown
44
 * David McKnight (IBM)          - [204684] CheckExistsJob used for determining if a remote object exists after a query of it's children
44
 ********************************************************************************/
45
 ********************************************************************************/
45
46
46
package org.eclipse.rse.internal.ui.view;
47
package org.eclipse.rse.internal.ui.view;
Lines 170-175 Link Here
170
import org.eclipse.swt.graphics.Cursor;
171
import org.eclipse.swt.graphics.Cursor;
171
import org.eclipse.swt.widgets.Composite;
172
import org.eclipse.swt.widgets.Composite;
172
import org.eclipse.swt.widgets.Control;
173
import org.eclipse.swt.widgets.Control;
174
import org.eclipse.swt.widgets.Display;
173
import org.eclipse.swt.widgets.Item;
175
import org.eclipse.swt.widgets.Item;
174
import org.eclipse.swt.widgets.Menu;
176
import org.eclipse.swt.widgets.Menu;
175
import org.eclipse.swt.widgets.Shell;
177
import org.eclipse.swt.widgets.Shell;
Lines 5738-5743 Link Here
5738
	}
5740
	}
5739
*/
5741
*/
5740
5742
5743
		/**
5744
		 * For bug 204684: 
5745
		 * 
5746
		 * Because we don't have an API for ISystemViewElementAdapter.exists()...
5747
		 * This class is used to determine whether an object exists and consequently whether to remove it from the view
5748
		 * after a query comes back with either no children or a SystemMessageObject.  We query the parent to determine
5749
		 * whether the remote object exists - in that case we just leave the message as is in the view.  In the case where
5750
		 * we detect that the object does not exist, we re-populate the parent node with the new children.
5751
		 */
5752
		public class CheckExistenceJob extends Job
5753
		{
5754
			
5755
			
5756
			private IAdaptable _remoteObject;
5757
			private TreeItem _parentItem;
5758
			private IContextObject _context;
5759
			public CheckExistenceJob(IAdaptable remoteObject, TreeItem parentItem, IContextObject context)
5760
			{
5761
				super("Check existence"); //$NON-NLS-1$
5762
				_remoteObject = remoteObject;
5763
				_parentItem = parentItem;
5764
				_context = context;
5765
			}
5766
			
5767
			public IStatus run(IProgressMonitor monitor)
5768
			{				
5769
				ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_remoteObject.getAdapter(ISystemViewElementAdapter.class);
5770
5771
				final Object[] children =  adapter.getChildren(_context, monitor);
5772
				if (contains(children, _remoteObject))
5773
				{
5774
					// we want to end this so the user sees the error message
5775
				}
5776
				else
5777
				{
5778
					Display.getDefault().asyncExec(new Runnable(){
5779
						public void run()
5780
						{
5781
							// first need to remove the old items
5782
							TreeItem[] items = _parentItem.getItems();
5783
							for (int i = 0; i < items.length; i++) {
5784
								if (items[i].getData() != null) {
5785
									disassociate(items[i]);
5786
									items[i].dispose();
5787
								} else {
5788
									items[i].dispose();
5789
									}
5790
								}
5791
							
5792
5793
							// we want to propagate the changes to the view
5794
							add(_context.getModelObject(), children);
5795
						}		
5796
					});
5797
				}
5798
				
5799
				return Status.OK_STATUS;
5800
			}
5801
			
5802
			private boolean contains(Object[] children, IAdaptable remoteObject)
5803
			{
5804
				ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)remoteObject.getAdapter(ISystemViewElementAdapter.class);
5805
				String path1 = adapter1.getAbsoluteName(remoteObject);
5806
				for (int i = 0; i < children.length; i++)
5807
				{
5808
					if (children[i] == remoteObject)
5809
					{
5810
						return true;
5811
					}
5812
					else if (children[i] instanceof IAdaptable)
5813
					{
5814
						IAdaptable remoteObject2 = (IAdaptable)children[i];
5815
					
5816
						ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)remoteObject2.getAdapter(ISystemViewElementAdapter.class);
5817
						String path2 = adapter2.getAbsoluteName(remoteObject2);
5818
						if (path1.equals(path2))
5819
						{
5820
							return true;
5821
						}
5822
					}
5823
				}				
5824
				return false;
5825
			}
5826
		}
5827
		
5828
5741
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5829
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5742
		assertElementsNotNull(childElements);
5830
		assertElementsNotNull(childElements);
5743
		
5831
		
Lines 5831-5840 Link Here
5831
				{
5919
				{
5832
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5920
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5833
					{
5921
					{
5834
						// refresh the parent
5922
						/*
5835
						Object par = adapter.getParent(parentElementOrTreePath);					
5923
				
5836
						ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5924
							// refresh the parent
5837
						sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5925
							Object par = adapter.getParent(parentElementOrTreePath);					
5926
							ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5927
							sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5928
					
5929
							*/
5930
						
5931
						// for bug 204684, using this job to determine whether or not the object exists before trying to update
5932
						if (match instanceof TreeItem)
5933
						{
5934
							TreeItem parentItem = ((TreeItem)match).getParentItem();
5935
							if (parentItem != null)
5936
							{
5937
								IContextObject context = getContextObject(parentItem);
5938
								CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, parentItem, context);
5939
								job.schedule();
5940
							}
5941
						}
5838
					}
5942
					}
5839
				}
5943
				}
5840
				
5944
				

Return to bug 204684