Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 110369 Details for
Bug 187739
[refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch to defer expansion via callbacks
patch.txt (text/plain), 13.36 KB, created by
David McKnight
on 2008-08-19 13:32:21 EDT
(
hide
)
Description:
patch to defer expansion via callbacks
Filename:
MIME Type:
Creator:
David McKnight
Created:
2008-08-19 13:32:21 EDT
Size:
13.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.ui >Index: UI/org/eclipse/rse/internal/ui/view/SystemView.java >=================================================================== >RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java,v >retrieving revision 1.180 >diff -u -r1.180 SystemView.java >--- UI/org/eclipse/rse/internal/ui/view/SystemView.java 24 Jul 2008 14:00:56 -0000 1.180 >+++ UI/org/eclipse/rse/internal/ui/view/SystemView.java 19 Aug 2008 17:29:31 -0000 >@@ -61,6 +61,7 @@ > * David McKnight (IBM) - [236874] NPE upon selecting an item that is not associated with subsystem > * David McKnight (IBM) - [238363] Performance improvement for refresh in system view. > * David McKnight (IBM) - [241722] New -> File doesn't select the newly created file >+ * David McKnight (IBM) - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems > ********************************************************************************/ > > package org.eclipse.rse.internal.ui.view; >@@ -130,6 +131,7 @@ > import org.eclipse.rse.core.filters.ISystemFilterString; > import org.eclipse.rse.core.filters.ISystemFilterStringReference; > import org.eclipse.rse.core.model.IHost; >+import org.eclipse.rse.core.model.IRSECallback; > import org.eclipse.rse.core.model.ISystemContainer; > import org.eclipse.rse.core.model.ISystemMessageObject; > import org.eclipse.rse.core.model.ISystemRegistry; >@@ -173,7 +175,6 @@ > import org.eclipse.rse.ui.model.SystemRemoteElementResourceSet; > import org.eclipse.rse.ui.model.SystemResourceChangeEventUI; > import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; >-import org.eclipse.rse.ui.view.ContextObject; > import org.eclipse.rse.ui.view.IContextObject; > import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; > import org.eclipse.rse.ui.view.ISystemSelectAllTarget; >@@ -3177,6 +3178,9 @@ > TreeItem matchedItem = (TreeItem)match; > Object data = matchedItem.getData(); > boolean wasExpanded = matchedItem.getExpanded(); >+ >+ >+ > smartRefresh(new TreeItem[] { matchedItem }); // refresh the remote object > if (firstSelection && // for now, we just select the first binary occurrence we find > (data == remoteObject)) // same binary object as given? >@@ -3190,10 +3194,11 @@ > allowExpand = rmtAdapter.hasChildren((IAdaptable)data); > } > if (allowExpand && wasExpanded && !getExpanded(matchedItem)) // assume if callers wants to select kids that they want to expand parent >- { >- createChildren(matchedItem); >+ { >+ createChildren(matchedItem); > setExpanded(matchedItem, true); > } >+ /* > // todo: handle cumulative selections. > // STEP 4: If requested, select the kids in the newly refreshed object. > // If the same binary object appears multiple times, select the kids in the first occurrence. >@@ -3204,6 +3209,7 @@ > //in the deferred case the objects will be retrieved in a separate job. > selectRemoteObjects(toSelect, null, match); // select the given kids in this parent > } >+ */ > } > } > } >@@ -3649,7 +3655,78 @@ > ourInternalRefresh(currItem, currItem.getData(), true, true); // dispose of children, update plus > > if (wasExpanded[idx]) { >- createChildren(currItem); // re-expand >+ >+ // for deferred queries >+ class ExpandRemoteObjects implements IRSECallback { >+ private List _toExpand; >+ >+ public ExpandRemoteObjects(List toExpand){ >+ _toExpand = toExpand; >+ } >+ >+ public void done(IStatus status, Object result) { >+ >+ if (Display.getCurrent() != null){ // on main thread >+ execute(); >+ } >+ else { >+ // need to run this code on main thread >+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() >+ { >+ public void run() { >+ execute(); >+ } >+ }); >+ } >+ } >+ >+ private void execute() >+ { >+ // expand each previously expanded sub-node, recursively >+ for (int idx = 0; idx < _toExpand.size(); idx++) { >+ ExpandedItem itemToExpand = (ExpandedItem) _toExpand.get(idx); >+ if (itemToExpand.isRemote()) { >+ // find remote item based on its original name and unchanged root parent >+ Item item = null; >+ item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem); >+ >+ // if found, re-expand it >+ if (item != null) { >+ IRSECallback callback = getCallbackForSubChildren(itemToExpand.remoteName, _toExpand); >+ createChildren(item, callback); >+ ((TreeItem) item).setExpanded(true); >+ } >+ } else if (itemToExpand.data!=null) { >+ setExpandedState(itemToExpand.data, true); >+ } >+ } >+ } >+ >+ private IRSECallback getCallbackForSubChildren(String remoteParentName, List itemsToExpand){ >+ List subChildren = new ArrayList(); >+ for (int i = 0; i < itemsToExpand.size(); i++){ >+ ExpandedItem itemToExpand = (ExpandedItem) itemsToExpand.get(i); >+ if (remoteParentName.equals(itemToExpand.remoteName)){ >+ // same item >+ } >+ else if (itemToExpand.remoteName.startsWith(remoteParentName)){ >+ // child item >+ subChildren.add(itemToExpand); >+ } >+ } >+ >+ if (subChildren.size() > 0){ >+ return new ExpandRemoteObjects(subChildren); >+ } >+ else { >+ return null; >+ } >+ } >+ } >+ >+ IRSECallback callback = new ExpandRemoteObjects(expandedChildren); >+ >+ createChildren(currItem, callback); // re-expand > currItem.setExpanded(true); > } else // hmm, item was not expanded so just flush its memory > { >@@ -3657,7 +3734,8 @@ > } > } > >- >+ // for non-deferred queries >+ > // 2. expand each previously expanded sub-node, recursively > for (int idx = 0; idx < expandedChildren.size(); idx++) { > ExpandedItem itemToExpand = (ExpandedItem) expandedChildren.get(idx); >@@ -3669,12 +3747,11 @@ > //else > //item = (Item)findRemoteItem(itemToExpand.remoteName, itemToExpand.subsystem); > >- //************************************************************/// > // FIXME!! > // TODO > // DKM - problem here is that if a query is in progress, then we won't find it until the deferred query completes > item = findFirstRemoteItemReference(itemToExpand.remoteName, itemToExpand.subsystem, itemToExpand.parentItem); >- //************************************************************/// >+ > // if found, re-expand it > if (item != null) { > //setExpanded(item, true); >@@ -6105,13 +6182,14 @@ > public void add(Object parentElementOrTreePath, Object[] childElements) { > > assertElementsNotNull(childElements); >- >+ IContextObject contextObject = null; > ISystemFilterReference originalFilter = null; > if (parentElementOrTreePath instanceof IContextObject) > { >- IContextObject context = (IContextObject)parentElementOrTreePath; >- originalFilter = context.getFilterReference(); >- parentElementOrTreePath = context.getModelObject(); >+ contextObject = (IContextObject)parentElementOrTreePath; >+ originalFilter = contextObject.getFilterReference(); >+ parentElementOrTreePath = contextObject.getModelObject(); >+ > } > > List matches = new Vector(); >@@ -6178,8 +6256,8 @@ > Object[] newChildren = null; > if (match instanceof TreeItem) > { >- IContextObject contextObject = getContextObject((TreeItem)match); >- newChildren = adapter.getChildren(contextObject, new NullProgressMonitor()); >+ IContextObject context = getContextObject((TreeItem)match); >+ newChildren = adapter.getChildren(context, new NullProgressMonitor()); > internalAdd(match, parentElementOrTreePath, newChildren); > } > } >@@ -6236,7 +6314,14 @@ > } > } > >- >+ // for bug 187739 >+ if (contextObject instanceof ContextObjectWithViewer) { >+ ContextObjectWithViewer ctx = (ContextObjectWithViewer)contextObject; >+ IRSECallback cb = ctx.getCallback(); >+ if (cb!=null) { >+ cb.done(Status.OK_STATUS, childElements); >+ } >+ } > } > > >@@ -6320,18 +6405,18 @@ > ISystemFilterReference filterReference = getContainingFilterReference(item); > if (filterReference != null) > { >- return new ContextObject(data, filterReference.getSubSystem(), filterReference); >+ return new ContextObjectWithViewer(data, filterReference.getSubSystem(), filterReference, this); > } > else > { > ISubSystem subSystem = getContainingSubSystem(item); > if (subSystem != null) > { >- return new ContextObject(data, subSystem); >+ return new ContextObjectWithViewer(data, subSystem, this); > } > else > { >- return new ContextObject(data); >+ return new ContextObjectWithViewer(data, this); > } > } > } >@@ -6365,10 +6450,9 @@ > } > > /** >- * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead >- * of the model object, itself >+ * For bug 187739 > */ >- protected void createChildren(final Widget widget) >+ protected void createChildren(final Widget widget, IRSECallback callback) > { > if (widget instanceof TreeItem) > { >@@ -6379,6 +6463,7 @@ > return; // children already there! > } > } >+ final IRSECallback cb = callback; > > BusyIndicator.showWhile(widget.getDisplay(), new Runnable() { > public void run() { >@@ -6399,6 +6484,10 @@ > if (d != null) > { > Object parentElement = getContextObject((TreeItem)widget); >+ if (cb != null && parentElement instanceof ContextObjectWithViewer){ >+ ((ContextObjectWithViewer)parentElement).setCallback(cb); >+ } >+ > Object[] children = getSortedChildren(parentElement); > if (children != null) > { >@@ -6417,6 +6506,15 @@ > super.createChildren(widget); > } > } >+ >+ /** >+ * Overridden so that we can pass a wrapper IContextObject into the provider to get children instead >+ * of the model object, itself >+ */ >+ protected void createChildren(final Widget widget) >+ { >+ createChildren(widget, null); >+ } > > /** > * Override to pass context into hasChildren() >Index: UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java >=================================================================== >RCS file: UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java >diff -N UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ UI/org/eclipse/rse/internal/ui/view/ContextObjectWithViewer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,77 @@ >+/******************************************************************************** >+ * Copyright (c) 2008 IBM Corporation. All rights reserved. >+ * This program and the accompanying materials are made available under the terms >+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Initial Contributors: >+ * The following IBM employees contributed to the Remote System Explorer >+ * component that contains this file: David McKnight. >+ * >+ * Contributors: >+ * David McKnight (IBM) - [187739] [refresh] Sub Directories are collapsed when Parent Directory is Refreshed on Remote Systems >+ ********************************************************************************/ >+package org.eclipse.rse.internal.ui.view; >+ >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.rse.core.filters.ISystemFilterReference; >+import org.eclipse.rse.core.model.IRSECallback; >+import org.eclipse.rse.core.subsystems.ISubSystem; >+import org.eclipse.rse.ui.view.ContextObject; >+ >+public class ContextObjectWithViewer extends ContextObject { >+ private Viewer _viewer; >+ private IRSECallback _callback; >+ >+ public ContextObjectWithViewer(Object modelObject, Viewer viewer){ >+ super(modelObject); >+ _viewer = viewer; >+ } >+ >+ public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer){ >+ super(modelObject, subsystem); >+ _viewer = viewer; >+ } >+ >+ public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer){ >+ super(modelObject, subsystem, filterReference); >+ _viewer = viewer; >+ } >+ >+ public ContextObjectWithViewer(Object modelObject, Viewer viewer, IRSECallback callback){ >+ super(modelObject); >+ _viewer = viewer; >+ _callback = callback; >+ } >+ >+ public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, Viewer viewer, IRSECallback callback){ >+ super(modelObject, subsystem); >+ _viewer = viewer; >+ _callback = callback; >+ } >+ >+ public ContextObjectWithViewer(Object modelObject, ISubSystem subsystem, ISystemFilterReference filterReference, Viewer viewer, IRSECallback callback){ >+ super(modelObject, subsystem, filterReference); >+ _viewer = viewer; >+ _callback = callback; >+ } >+ >+ public Viewer getViewer() >+ { >+ return _viewer; >+ } >+ >+ public IRSECallback getCallback() >+ { >+ return _callback; >+ } >+ >+ public void setCallback(IRSECallback callback){ >+ _callback = callback; >+ } >+ >+ public void setViewer(Viewer viewer){ >+ _viewer = viewer; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 187739
:
110369
|
110372