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 / +105 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
			public class UpdateView implements Runnable
5755
			{
5756
				public Object[] _children;
5757
				public UpdateView(Object[] children)
5758
				{
5759
					_children = children;
5760
				}
5761
				
5762
				public void run()
5763
				{
5764
					// first need to remove the old items
5765
					TreeItem[] items = _parentItem.getItems();
5766
					for (int i = 0; i < items.length; i++) {
5767
						if (items[i].getData() != null) {
5768
							disassociate(items[i]);
5769
							items[i].dispose();
5770
						} else {
5771
							items[i].dispose();
5772
							}
5773
						}
5774
					
5775
5776
					// we want to propagate the changes to the view
5777
					add(_context.getModelObject(), _children);
5778
				}
5779
			}
5780
			
5781
			
5782
			private IAdaptable _remoteObject;
5783
			private TreeItem _parentItem;
5784
			private IContextObject _context;
5785
			public CheckExistenceJob(IAdaptable remoteObject, TreeItem parentItem, IContextObject context)
5786
			{
5787
				super("Check existence");
5788
				_remoteObject = remoteObject;
5789
				_parentItem = parentItem;
5790
				_context = context;
5791
				setSystem(true);
5792
			}
5793
			
5794
			public IStatus run(IProgressMonitor monitor)
5795
			{				
5796
				ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)_remoteObject.getAdapter(ISystemViewElementAdapter.class);
5797
5798
				Object[] children =  adapter.getChildren(_context, monitor);
5799
				if (contains(children, _remoteObject))
5800
				{
5801
					// we want to end this so the user sees the error message
5802
				}
5803
				else
5804
				{
5805
					UpdateView runnable = new UpdateView(children);
5806
					Display.getDefault().asyncExec(runnable);
5807
				}
5808
				
5809
				return Status.OK_STATUS;
5810
			}
5811
			
5812
			private boolean contains(Object[] children, IAdaptable remoteObject)
5813
			{
5814
				for (int i = 0; i < children.length; i++)
5815
				{
5816
					if (children[i] == remoteObject)
5817
					{
5818
						return true;
5819
					}
5820
				}				
5821
				return false;
5822
			}
5823
		}
5824
		
5825
5741
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5826
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5742
		assertElementsNotNull(childElements);
5827
		assertElementsNotNull(childElements);
5743
		
5828
		
Lines 5831-5840 Link Here
5831
				{
5916
				{
5832
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5917
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5833
					{
5918
					{
5834
						// refresh the parent
5919
						/*
5835
						Object par = adapter.getParent(parentElementOrTreePath);					
5920
				
5836
						ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5921
							// refresh the parent
5837
						sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5922
							Object par = adapter.getParent(parentElementOrTreePath);					
5923
							ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5924
							sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5925
					
5926
							*/
5927
						
5928
						// for bug 204684, using this job to determine whether or not the object exists before trying to update
5929
						if (match instanceof TreeItem)
5930
						{
5931
							TreeItem parentItem = ((TreeItem)match).getParentItem();
5932
							if (parentItem != null)
5933
							{
5934
								IContextObject context = getContextObject(parentItem);
5935
								CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, parentItem, context);
5936
								job.schedule();
5937
							}
5938
						}
5838
					}
5939
					}
5839
				}
5940
				}
5840
				
5941
				

Return to bug 204684