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

Collapse All | Expand All

(-)UI/org/eclipse/rse/internal/ui/view/SystemView.java (-20 / +118 lines)
Lines 61-66 Link Here
61
 * David McKnight   (IBM)        - [236874] NPE upon selecting an item that is not associated with subsystem
61
 * David McKnight   (IBM)        - [236874] NPE upon selecting an item that is not associated with subsystem
62
 * David McKnight   (IBM)        - [238363] Performance improvement for refresh in system view.
62
 * David McKnight   (IBM)        - [238363] Performance improvement for refresh in system view.
63
 * David McKnight   (IBM)        - [241722] New -> File doesn't select the newly created file
63
 * David McKnight   (IBM)        - [241722] New -> File doesn't select the newly created file
64
 * David McKnight   (IBM)        - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems
64
 ********************************************************************************/
65
 ********************************************************************************/
65
66
66
package org.eclipse.rse.internal.ui.view;
67
package org.eclipse.rse.internal.ui.view;
Lines 130-135 Link Here
130
import org.eclipse.rse.core.filters.ISystemFilterString;
131
import org.eclipse.rse.core.filters.ISystemFilterString;
131
import org.eclipse.rse.core.filters.ISystemFilterStringReference;
132
import org.eclipse.rse.core.filters.ISystemFilterStringReference;
132
import org.eclipse.rse.core.model.IHost;
133
import org.eclipse.rse.core.model.IHost;
134
import org.eclipse.rse.core.model.IRSECallback;
133
import org.eclipse.rse.core.model.ISystemContainer;
135
import org.eclipse.rse.core.model.ISystemContainer;
134
import org.eclipse.rse.core.model.ISystemMessageObject;
136
import org.eclipse.rse.core.model.ISystemMessageObject;
135
import org.eclipse.rse.core.model.ISystemRegistry;
137
import org.eclipse.rse.core.model.ISystemRegistry;
Lines 173-179 Link Here
173
import org.eclipse.rse.ui.model.SystemRemoteElementResourceSet;
175
import org.eclipse.rse.ui.model.SystemRemoteElementResourceSet;
174
import org.eclipse.rse.ui.model.SystemResourceChangeEventUI;
176
import org.eclipse.rse.ui.model.SystemResourceChangeEventUI;
175
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
177
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
176
import org.eclipse.rse.ui.view.ContextObject;
177
import org.eclipse.rse.ui.view.IContextObject;
178
import org.eclipse.rse.ui.view.IContextObject;
178
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
179
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
179
import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
180
import org.eclipse.rse.ui.view.ISystemSelectAllTarget;
Lines 3177-3182 Link Here
3177
				TreeItem matchedItem = (TreeItem)match;
3178
				TreeItem matchedItem = (TreeItem)match;
3178
				Object data = matchedItem.getData();
3179
				Object data = matchedItem.getData();
3179
				boolean wasExpanded = matchedItem.getExpanded();
3180
				boolean wasExpanded = matchedItem.getExpanded();
3181
				
3182
3183
				
3180
				smartRefresh(new TreeItem[] { matchedItem }); // refresh the remote object
3184
				smartRefresh(new TreeItem[] { matchedItem }); // refresh the remote object
3181
				if (firstSelection && // for now, we just select the first binary occurrence we find
3185
				if (firstSelection && // for now, we just select the first binary occurrence we find
3182
						(data == remoteObject)) // same binary object as given?
3186
						(data == remoteObject)) // same binary object as given?
Lines 3190-3199 Link Here
3190
							allowExpand = rmtAdapter.hasChildren((IAdaptable)data);
3194
							allowExpand = rmtAdapter.hasChildren((IAdaptable)data);
3191
						}
3195
						}
3192
						if (allowExpand && wasExpanded && !getExpanded(matchedItem)) // assume if callers wants to select kids that they want to expand parent
3196
						if (allowExpand && wasExpanded && !getExpanded(matchedItem)) // assume if callers wants to select kids that they want to expand parent
3193
						{
3197
						{							
3194
							createChildren(matchedItem);
3198
							createChildren(matchedItem);														
3195
							setExpanded(matchedItem, true);
3199
							setExpanded(matchedItem, true);
3196
						}
3200
						}
3201
						/*
3197
						// todo: handle cumulative selections.
3202
						// todo: handle cumulative selections.
3198
						// STEP 4: If requested, select the kids in the newly refreshed object.
3203
						// STEP 4: If requested, select the kids in the newly refreshed object.
3199
						// If the same binary object appears multiple times, select the kids in the first occurrence.
3204
						// If the same binary object appears multiple times, select the kids in the first occurrence.
Lines 3204-3209 Link Here
3204
							//in the deferred case the objects will be retrieved in a separate job.
3209
							//in the deferred case the objects will be retrieved in a separate job.
3205
							selectRemoteObjects(toSelect, null, match); // select the given kids in this parent
3210
							selectRemoteObjects(toSelect, null, match); // select the given kids in this parent
3206
						}
3211
						}
3212
						*/
3207
					}
3213
					}
3208
				}
3214
				}
3209
			}
3215
			}
Lines 3649-3655 Link Here
3649
			ourInternalRefresh(currItem, currItem.getData(), true, true); // dispose of children, update plus
3655
			ourInternalRefresh(currItem, currItem.getData(), true, true); // dispose of children, update plus
3650
3656
3651
			if (wasExpanded[idx]) {
3657
			if (wasExpanded[idx]) {
3652
				createChildren(currItem); // re-expand
3658
				
3659
				// for deferred queries
3660
				class ExpandRemoteObjects implements IRSECallback {
3661
					private List _toExpand;
3662
		
3663
					public ExpandRemoteObjects(List toExpand){
3664
						_toExpand = toExpand;
3665
					}						
3666
					
3667
					public void done(IStatus status, Object result) {
3668
						
3669
						if (Display.getCurrent() != null){ // on main thread
3670
							execute();
3671
						}
3672
						else {
3673
							// need to run this code on main thread
3674
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
3675
							{
3676
								public void run() {
3677
									execute();
3678
								}
3679
							});
3680
						}
3681
					}
3682
					
3683
					private void execute()
3684
					{
3685
						// expand each previously expanded sub-node, recursively
3686
						for (int idx = 0; idx < _toExpand.size(); idx++) {
3687
							ExpandedItem itemToExpand = (ExpandedItem) _toExpand.get(idx);
3688
							if (itemToExpand.isRemote()) {
3689
								// find remote item based on its original name and unchanged root parent
3690
								Item item = null;
3691
								item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem);
3692
3693
								// if found, re-expand it
3694
								if (item != null) {
3695
									IRSECallback callback = getCallbackForSubChildren(itemToExpand.remoteName, _toExpand);								
3696
									createChildren(item, callback);
3697
									((TreeItem) item).setExpanded(true);
3698
								} 
3699
							} else if (itemToExpand.data!=null) {
3700
								setExpandedState(itemToExpand.data, true);
3701
							}
3702
						}
3703
					}
3704
					
3705
					private IRSECallback getCallbackForSubChildren(String remoteParentName, List itemsToExpand){
3706
						List subChildren = new ArrayList();
3707
						for (int i = 0; i < itemsToExpand.size(); i++){
3708
							ExpandedItem itemToExpand = (ExpandedItem) itemsToExpand.get(i);
3709
							if (remoteParentName.equals(itemToExpand.remoteName)){
3710
								// same item
3711
							}
3712
							else if (itemToExpand.remoteName.startsWith(remoteParentName)){
3713
								// child item
3714
								subChildren.add(itemToExpand);
3715
							}					
3716
						}
3717
						
3718
						if (subChildren.size() > 0){
3719
							return new ExpandRemoteObjects(subChildren);
3720
						}
3721
						else {
3722
							return null;
3723
						}
3724
					}
3725
				}
3726
				
3727
				IRSECallback callback = new ExpandRemoteObjects(expandedChildren);				
3728
				
3729
				createChildren(currItem, callback); // re-expand
3653
				currItem.setExpanded(true);
3730
				currItem.setExpanded(true);
3654
			} else // hmm, item was not expanded so just flush its memory
3731
			} else // hmm, item was not expanded so just flush its memory
3655
			{
3732
			{
Lines 3657-3663 Link Here
3657
			}
3734
			}
3658
		}
3735
		}
3659
3736
3660
3737
		// for non-deferred queries
3738
		
3661
		// 2. expand each previously expanded sub-node, recursively
3739
		// 2. expand each previously expanded sub-node, recursively
3662
		for (int idx = 0; idx < expandedChildren.size(); idx++) {
3740
		for (int idx = 0; idx < expandedChildren.size(); idx++) {
3663
			ExpandedItem itemToExpand = (ExpandedItem) expandedChildren.get(idx);
3741
			ExpandedItem itemToExpand = (ExpandedItem) expandedChildren.get(idx);
Lines 3669-3680 Link Here
3669
				//else
3747
				//else
3670
				//item = (Item)findRemoteItem(itemToExpand.remoteName, itemToExpand.subsystem);
3748
				//item = (Item)findRemoteItem(itemToExpand.remoteName, itemToExpand.subsystem);
3671
3749
3672
				//************************************************************///
3673
				// FIXME!!
3750
				// FIXME!!
3674
				// TODO
3751
				// TODO
3675
				// DKM - problem here is that if a query is in progress, then we won't find it until the deferred query completes
3752
				// DKM - problem here is that if a query is in progress, then we won't find it until the deferred query completes
3676
				item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem);
3753
				item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem);
3677
				//************************************************************///
3754
3678
				// if found, re-expand it
3755
				// if found, re-expand it
3679
				if (item != null) {
3756
				if (item != null) {
3680
					//setExpanded(item, true);
3757
					//setExpanded(item, true);
Lines 6105-6117 Link Here
6105
	public void add(Object parentElementOrTreePath, Object[] childElements) {
6182
	public void add(Object parentElementOrTreePath, Object[] childElements) {
6106
6183
6107
		assertElementsNotNull(childElements);
6184
		assertElementsNotNull(childElements);
6108
6185
		IContextObject contextObject = null;
6109
		ISystemFilterReference originalFilter = null;
6186
		ISystemFilterReference originalFilter = null;
6110
		if (parentElementOrTreePath instanceof IContextObject)
6187
		if (parentElementOrTreePath instanceof IContextObject)
6111
		{
6188
		{
6112
			IContextObject context = (IContextObject)parentElementOrTreePath;
6189
			contextObject = (IContextObject)parentElementOrTreePath;
6113
			originalFilter = context.getFilterReference();
6190
			originalFilter = contextObject.getFilterReference();
6114
			parentElementOrTreePath = context.getModelObject();
6191
			parentElementOrTreePath = contextObject.getModelObject();
6192
									
6115
		}
6193
		}
6116
6194
6117
		List matches = new Vector();
6195
		List matches = new Vector();
Lines 6178-6185 Link Here
6178
				Object[] newChildren = null;
6256
				Object[] newChildren = null;
6179
				if (match instanceof TreeItem)
6257
				if (match instanceof TreeItem)
6180
				{
6258
				{
6181
					IContextObject contextObject = getContextObject((TreeItem)match);
6259
					IContextObject context = getContextObject((TreeItem)match);
6182
					newChildren = adapter.getChildren(contextObject, new NullProgressMonitor());
6260
					newChildren = adapter.getChildren(context, new NullProgressMonitor());
6183
					internalAdd(match, parentElementOrTreePath, newChildren);
6261
					internalAdd(match, parentElementOrTreePath, newChildren);
6184
				}
6262
				}
6185
			}
6263
			}
Lines 6236-6242 Link Here
6236
			}
6314
			}
6237
		}
6315
		}
6238
6316
6239
6317
		// for bug 187739
6318
		if (contextObject instanceof ContextObjectWithViewer) {
6319
   	       ContextObjectWithViewer ctx = (ContextObjectWithViewer)contextObject;
6320
   	       IRSECallback cb = ctx.getCallback();
6321
   	       if (cb!=null) {
6322
   	          cb.done(Status.OK_STATUS, childElements);
6323
   	       }
6324
   	   }
6240
	}
6325
	}
6241
6326
6242
6327
Lines 6320-6337 Link Here
6320
		ISystemFilterReference filterReference = getContainingFilterReference(item);
6405
		ISystemFilterReference filterReference = getContainingFilterReference(item);
6321
		if (filterReference != null)
6406
		if (filterReference != null)
6322
		{
6407
		{
6323
			return new ContextObject(data, filterReference.getSubSystem(), filterReference);
6408
			return new ContextObjectWithViewer(data, filterReference.getSubSystem(), filterReference, this);
6324
		}
6409
		}
6325
		else
6410
		else
6326
		{
6411
		{
6327
			ISubSystem subSystem = getContainingSubSystem(item);
6412
			ISubSystem subSystem = getContainingSubSystem(item);
6328
			if (subSystem != null)
6413
			if (subSystem != null)
6329
			{
6414
			{
6330
				return new ContextObject(data, subSystem);
6415
				return new ContextObjectWithViewer(data, subSystem, this);
6331
			}
6416
			}
6332
			else
6417
			else
6333
			{
6418
			{
6334
				return new ContextObject(data);
6419
				return new ContextObjectWithViewer(data, this);
6335
			}
6420
			}
6336
		}
6421
		}
6337
	}
6422
	}
Lines 6365-6374 Link Here
6365
	}
6450
	}
6366
6451
6367
	/**
6452
	/**
6368
	 * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead
6453
	 * For bug 187739
6369
	 * of the model object, itself
6370
	 */
6454
	 */
6371
	protected void createChildren(final Widget widget)
6455
	protected void createChildren(final Widget widget, IRSECallback callback)
6372
	{
6456
	{
6373
		if (widget instanceof TreeItem)
6457
		if (widget instanceof TreeItem)
6374
		{
6458
		{
Lines 6379-6384 Link Here
6379
				return; // children already there!
6463
				return; // children already there!
6380
			}
6464
			}
6381
		}
6465
		}
6466
		final IRSECallback cb = callback;
6382
6467
6383
		BusyIndicator.showWhile(widget.getDisplay(), new Runnable() {
6468
		BusyIndicator.showWhile(widget.getDisplay(), new Runnable() {
6384
			public void run() {
6469
			public void run() {
Lines 6399-6404 Link Here
6399
				if (d != null)
6484
				if (d != null)
6400
				{
6485
				{
6401
					Object parentElement = getContextObject((TreeItem)widget);
6486
					Object parentElement = getContextObject((TreeItem)widget);
6487
					if (cb != null && parentElement instanceof ContextObjectWithViewer){
6488
						((ContextObjectWithViewer)parentElement).setCallback(cb);
6489
					}
6490
					
6402
					Object[] children = getSortedChildren(parentElement);
6491
					Object[] children = getSortedChildren(parentElement);
6403
					if (children != null)
6492
					if (children != null)
6404
					{
6493
					{
Lines 6417-6422 Link Here
6417
			super.createChildren(widget);
6506
			super.createChildren(widget);
6418
		}
6507
		}
6419
	}
6508
	}
6509
	
6510
	/**
6511
	 * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead
6512
	 * of the model object, itself
6513
	 */
6514
	protected void createChildren(final Widget widget)
6515
	{
6516
		createChildren(widget, null);
6517
	}
6420
6518
6421
	/**
6519
	/**
6422
	 * Override to pass context into hasChildren()
6520
	 * Override to pass context into hasChildren()
(-)UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java (+77 lines)
Added Link Here
1
/********************************************************************************
2
 * Copyright (c) 2008 IBM Corporation. All rights reserved.
3
 * This program and the accompanying materials are made available under the terms
4
 * of the Eclipse Public License v1.0 which accompanies this distribution, and is 
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Initial Contributors:
8
 * The following IBM employees contributed to the Remote System Explorer
9
 * component that contains this file: David McKnight.
10
 * 
11
 * Contributors:
12
 * David McKnight   (IBM)        - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems
13
 ********************************************************************************/
14
package org.eclipse.rse.internal.ui.view;
15
16
import org.eclipse.jface.viewers.Viewer;
17
import org.eclipse.rse.core.filters.ISystemFilterReference;
18
import org.eclipse.rse.core.model.IRSECallback;
19
import org.eclipse.rse.core.subsystems.ISubSystem;
20
import org.eclipse.rse.ui.view.ContextObject;
21
22
public class ContextObjectWithViewer extends ContextObject {
23
	private Viewer _viewer;
24
	private IRSECallback _callback;
25
	
26
	public ContextObjectWithViewer(Object modelObject, Viewer viewer){
27
		super(modelObject);
28
		_viewer = viewer;
29
	}
30
	
31
	public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer){
32
		super(modelObject, subsystem);
33
		_viewer = viewer;
34
	}
35
	
36
	public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer){
37
		super(modelObject, subsystem, filterReference);
38
		_viewer = viewer;
39
	}
40
	
41
	public ContextObjectWithViewer(Object modelObject, Viewer viewer, IRSECallback callback){
42
		super(modelObject);
43
		_viewer = viewer;
44
		_callback = callback;
45
	}
46
	
47
	public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer, IRSECallback callback){
48
		super(modelObject, subsystem);
49
		_viewer = viewer;
50
		_callback = callback;
51
	}
52
	
53
	public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer, IRSECallback callback){
54
		super(modelObject, subsystem, filterReference);
55
		_viewer = viewer;
56
		_callback = callback;
57
	}
58
	
59
	public Viewer getViewer()
60
	{
61
		return _viewer;
62
	}
63
	
64
	public IRSECallback getCallback()
65
	{
66
		return _callback;
67
	}
68
	
69
	public void setCallback(IRSECallback callback){
70
		_callback = callback;
71
	}
72
	
73
	public void setViewer(Viewer viewer){
74
		_viewer = viewer;
75
	}
76
	
77
}

Return to bug 187739