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 (-8 / +127 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 static 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
			public static boolean contains(Object[] children, IAdaptable remoteObject)
5812
			{
5813
				ISystemViewElementAdapter adapter1 = (ISystemViewElementAdapter)remoteObject.getAdapter(ISystemViewElementAdapter.class);
5814
				String path1 = adapter1==null ? null : adapter1.getAbsoluteName(remoteObject);
5815
				for (int i = 0; i < children.length; i++)
5816
				{
5817
					if (remoteObject==children[i] || remoteObject.equals(children[i]))
5818
					{
5819
						return true;
5820
					}
5821
					else if (children[i] instanceof IAdaptable)
5822
					{
5823
						IAdaptable remoteObject2 = (IAdaptable)children[i];
5824
						ISystemViewElementAdapter adapter2 = (ISystemViewElementAdapter)remoteObject2.getAdapter(ISystemViewElementAdapter.class);
5825
						if (adapter2 != null)
5826
						{
5827
							String path2 = adapter2.getAbsoluteName(remoteObject2);
5828
							if (path1 != null && path2 != null && path1.equals(path2))
5829
							{
5830
								return true;
5831
							}
5832
						}
5833
					}
5834
				}
5835
				return false;
5836
			}
5837
		}
5838
		
5839
5741
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5840
	public void add(Object parentElementOrTreePath, Object[] childElements) {
5742
		assertElementsNotNull(childElements);
5841
		assertElementsNotNull(childElements);
5743
		
5842
		
Lines 5817-5829 Link Here
5817
					newChildren = adapter.getChildren(contextObject, new NullProgressMonitor());
5916
					newChildren = adapter.getChildren(contextObject, new NullProgressMonitor());
5818
					internalAdd(match, parentElementOrTreePath, newChildren);
5917
					internalAdd(match, parentElementOrTreePath, newChildren);
5819
				}	
5918
				}	
5820
				
5821
			}
5919
			}
5822
			else
5920
			else
5823
			{	
5921
			{	
5824
	
5825
				
5826
				
5827
				internalAdd(match, parentElementOrTreePath, childElements);
5922
				internalAdd(match, parentElementOrTreePath, childElements);
5828
				
5923
				
5829
				// refresh parent in this case because the parentElementOrTreePath may no longer exist
5924
				// refresh parent in this case because the parentElementOrTreePath may no longer exist
Lines 5831-5840 Link Here
5831
				{
5926
				{
5832
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5927
					if (adapter.isRemote(parentElementOrTreePath) && !adapter.hasChildren((IAdaptable)parentElementOrTreePath))						
5833
					{
5928
					{
5834
						// refresh the parent
5929
						/*
5835
						Object par = adapter.getParent(parentElementOrTreePath);					
5930
							// refresh the parent
5836
						ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5931
							Object par = adapter.getParent(parentElementOrTreePath);					
5837
						sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5932
							ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5933
							sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5934
					
5935
							*/
5936
						
5937
						// for bug 204684, using this job to determine whether or not the object exists before trying to update
5938
						if (match instanceof TreeItem)
5939
						{
5940
							TreeItem parentItem = ((TreeItem)match).getParentItem();
5941
							if (parentItem != null)
5942
							{
5943
								IContextObject context = getContextObject(parentItem);
5944
								if (adapter.supportsDeferredQueries(context.getSubSystem())) {
5945
									CheckExistenceJob job = new CheckExistenceJob((IAdaptable)parentElementOrTreePath, parentItem, context);
5946
									job.schedule();
5947
								} else {
5948
									Object[] children =  adapter.getChildren(context, new NullProgressMonitor());
5949
									if (!CheckExistenceJob.contains(children, (IAdaptable)parentElementOrTreePath)) {
5950
										IAdaptable par = context.getModelObject();
5951
										ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
5952
										sr.fireEvent(new SystemResourceChangeEvent(par, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null));
5953
									}
5954
								}
5955
							}
5956
						}
5838
					}
5957
					}
5839
				}
5958
				}
5840
				
5959
				

Return to bug 204684