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 / +123 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
				if (adapter != null)
5771
				{
5772
					final Object[] children =  adapter.getChildren(_context, monitor);
5773
					if (contains(children, _remoteObject))
5774
					{
5775
						// we want to end this so the user sees the error message
5776
					}
5777
					else
5778
					{
5779
						Display.getDefault().asyncExec(new Runnable(){
5780
							public void run()
5781
							{
5782
								/*
5783
								// first need to remove the old items
5784
								TreeItem[] items = _parentItem.getItems();
5785
								for (int i = 0; i < items.length; i++) {
5786
									if (items[i].getData() != null) {
5787
										disassociate(items[i]);
5788
										items[i].dispose();
5789
									} else {
5790
										items[i].dispose();
5791
										}
5792
									}
5793
								
5794
	
5795
								// we want to propagate the changes to the view
5796
								add(_context.getModelObject(), children);
5797
								*/
5798
								// refresh using the event since other views may need updating
5799
								IAdaptable par = _context.getModelObject();
5800
								ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5801
								sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5802
						
5803
							}		
5804
						});
5805
					}
5806
				}
5807
				
5808
				return Status.OK_STATUS;
5809
			}
5810
			
5811
			private boolean contains(Object[] children, IAdaptable remoteObject)
5812
			{
5813
				ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)remoteObject.getAdapter(ISystemViewElementAdapter.class);
5814
				if (adapter1 != null)
5815
				{
5816
					String path1 = adapter1.getAbsoluteName(remoteObject);
5817
					for (int i = 0; i < children.length; i++)
5818
					{
5819
						if (children[i] == remoteObject)
5820
						{
5821
							return true;
5822
						}
5823
						else if (children[i] instanceof IAdaptable)
5824
						{
5825
							IAdaptable remoteObject2 = (IAdaptable)children[i];
5826
					
5827
							ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)remoteObject2.getAdapter(ISystemViewElementAdapter.class);
5828
							if (adapter2 != null)
5829
							{
5830
								String path2 = adapter2.getAbsoluteName(remoteObject2);
5831
								if (path1 != null && path2 != null && path1.equals(path2))
5832
								{
5833
									return true;
5834
								}
5835
							}
5836
						}
5837
					}
5838
				}
5839
				return false;
5840
			}
5841
		}
5842
		
5843
5741
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5844
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5742
		assertElementsNotNull(childElements);
5845
		assertElementsNotNull(childElements);
5743
		
5846
		
Lines 5831-5840 Link Here
5831
				{
5934
				{
5832
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5935
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5833
					{
5936
					{
5834
						// refresh the parent
5937
						/*
5835
						Object par = adapter.getParent(parentElementOrTreePath);					
5938
				
5836
						ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5939
							// refresh the parent
5837
						sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5940
							Object par = adapter.getParent(parentElementOrTreePath);					
5941
							ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5942
							sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5943
					
5944
							*/
5945
						
5946
						// for bug 204684, using this job to determine whether or not the object exists before trying to update
5947
						if (match instanceof TreeItem)
5948
						{
5949
							TreeItem parentItem = ((TreeItem)match).getParentItem();
5950
							if (parentItem != null)
5951
							{
5952
								IContextObject context = getContextObject(parentItem);
5953
								CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, parentItem, context);
5954
								job.schedule();
5955
							}
5956
						}
5838
					}
5957
					}
5839
				}
5958
				}
5840
				
5959
				

Return to bug 204684