1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter

This commit is contained in:
David McKnight 2008-06-06 17:54:31 +00:00
parent 917193d7cd
commit 9836bd29b2
3 changed files with 118 additions and 60 deletions

View file

@ -14,6 +14,7 @@
* Contributors:
* David McKnight (IBM) - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost()
* Martin Oberhuber (Wind River) - [234726] Update IRemoteFile Javadocs
* David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -199,6 +200,16 @@ public abstract class AbstractRemoteFile extends RemoteFile
{
return _hostFile;
}
/**
* Replacing the current associated IHostFile with a new one
*
* @param hostFile the new host file
*
* @since 3.0
*/
public void setHostFile(IHostFile hostFile) {
_hostFile = hostFile;
}
}

View file

@ -40,6 +40,7 @@
* David Dykstal (IBM) - [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
* Martin Oberhuber (Wind River) - [234038] Mark IRemoteFile stale when changing permissions
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile
* David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -419,14 +420,17 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
}
List hostFiles = new ArrayList(10);
// query children via the service
getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext();
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]);
// caching
// convert the IHostFiles into AbstractRemoteFiles
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
// cache the results corresponding to each parent under each parent
for (int i = 0; i < parents.length; i++)
{
IRemoteFile parent = parents[i];
@ -445,9 +449,15 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
underParent.add(child);
}
}
// update the parent with it's latest properties
// null is passed for the second argument because we currently don't get the parent in our results query
updateRemoteFile(parent, null, monitor);
if (underParent.size() > 0)
{
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray());
Object[] qresults = underParent.toArray();
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults);
}
}
@ -467,15 +477,18 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
parentPaths[i] = parents[i].getAbsolutePath();
}
List hostFiles = new ArrayList(10);
// query children via the service
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext();
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
// caching
IHostFile[] results = (IHostFile[])hostFiles.toArray(new IHostFile[hostFiles.size()]);
// convert the IHostFiles into AbstractRemoteFiles
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, null, results);
// cache the results corresponding to each parent under each parent
for (int i = 0; i < parents.length; i++)
{
IRemoteFile parent = parents[i];
@ -486,7 +499,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
// what files are under this one?
for (int j = 0; j < farr.length; j++)
{
IRemoteFile child = farr[j];
AbstractRemoteFile child = farr[j];
String childParentPath = child.getParentPath();
if (parentPath.equals(childParentPath))
@ -494,9 +507,15 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
underParent.add(child);
}
}
// update the parent with it's latest properties
// null is passed for the second argument because we currently don't get the parent in our results query
updateRemoteFile(parent, null, monitor);
if (underParent.size() > 0)
{
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray());
Object[] qresults = underParent.toArray();
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults);
}
}
@ -525,17 +544,44 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
IStatus.INFO, msgTxt);
throw new SystemMessageException(msg);
}
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor);
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results);
// query children of the parent
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor);
// update the parent with it's latest properties
// null is passed for the second argument because we currently don't get the parent in our results query
updateRemoteFile(parent, null, monitor);
// convert the IHostFiles to AbstractRemoteFile[]
AbstractRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results);
if (parent != null)
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr);
return farr;
}
private void updateRemoteFile(IRemoteFile parent, IHostFile newHostParent, IProgressMonitor monitor) throws SystemMessageException
{
// now newHostParent file passed in so we'll assume it wasn't returned and explicitly get it
if (newHostParent == null){
String parentParentPath = parent.getParentPath();
if (parentParentPath == null){
parentParentPath = ""; //$NON-NLS-1$
}
newHostParent = getFileService().getFile(parentParentPath, parent.getName(), monitor);
}
if (newHostParent != null){
IHostFile oldHostParent = parent.getHostFile();
if (!newHostParent.equals(oldHostParent)){
((AbstractRemoteFile)parent).setHostFile(newHostParent);
parent.markStale(false);
}
}
}
public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException
{
IHostFile[] roots = null;

View file

@ -57,6 +57,7 @@
* David McKnight (IBM) - [233530] Not Prompted on Promptable Filters after using once by double click
* David McKnight (IBM) - [233570] ClassCastException when moving filter after "go into" action
* David Dykstal (IBM) - [233530] Backing out previous change for this bug
* David McKnight (IBM) - [223461] [Refresh][api] Refresh expanded folder under filter refreshes Filter
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -1357,6 +1358,7 @@ public class SystemView extends SafeTreeViewer
}
}
/**
* Clear current selection. Ignore widget disposed message.
*/
@ -1366,6 +1368,8 @@ public class SystemView extends SafeTreeViewer
} catch (Exception exc) {
}
}
/**
* Returns the implementation of ISystemViewElementAdapter for the given
@ -2226,6 +2230,11 @@ public class SystemView extends SafeTreeViewer
case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
if (debug) logDebugMsg("SV event: EVENT_REFRESH_REMOTE: src = " + src); //$NON-NLS-1$
// Fake expanded is set to the item for the src object if the object is in a collapsed state and
// resides directly under a filter. The item is artificially expanded in order to allow
// refreshRemoteObject() to go through with a query of the item. After the query is kicked off,
// fakeExpanded is contracted in order to retain the original tree expand state.
TreeItem fakeExpanded = null;
ISystemViewElementAdapter adapter = getViewAdapter(src);
if (adapter != null)
@ -2233,17 +2242,15 @@ public class SystemView extends SafeTreeViewer
// we need to refresh filters
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
// if this is a filter reference, we just need to refresh it
if (src instanceof ISystemFilterReference)
{
refresh(src);
break;
}
// need to find filter references contain this object
List filterReferences = sr.findFilterReferencesFor(src, adapter.getSubSystem(src), false);
// if filters reference this resource we need them refreshed
for (int f = 0; f < filterReferences.size(); f++)
{
ISystemFilterReference ref = (ISystemFilterReference)filterReferences.get(f);
if (!ref.isStale())
{
ref.markStale(true);
smartRefresh(ref, true);
}
}
// first, find out if src is a container or not
// if it's a container, just pass into refreshRemoteObject
@ -2255,7 +2262,17 @@ public class SystemView extends SafeTreeViewer
Object srcParent = adapter.getParent(src);
if (srcParent != null)
{
src = srcParent;
if (filterReferences.size() > 0){
for (int r = 0; r < filterReferences.size(); r++){
ISystemFilterReference ref = (ISystemFilterReference)filterReferences.get(r);
refresh(ref);
}
break;
}
else {
src = srcParent;
}
}
}
else
@ -2280,45 +2297,24 @@ public class SystemView extends SafeTreeViewer
TreeItem[] titems = titem.getItems();
if (titems.length > 0 && !titem.getExpanded())
{
src = adapter.getParent(src);
// the item is artificially expanded in order to allow the query to go through in
// refreshRemoteObject()
titem.setExpanded(true);
// we set this so that after calling refreshRemoteObject(), the item can be re-collapsed
fakeExpanded = titem;
}
}
/* old code - issue in 196662
String key = adapter.getAbsoluteName(src);
if (key != null)
{
try
{
Object srcParent = adapter.getParent(src); // get parent before we query
// because if after query src doesn't exist,
// we can't get parent
if (srcParent != null)
{
src = ss.getObjectWithAbsoluteName(key);
hasChildren = adapter.hasChildren((IAdaptable)src);
if (!hasChildren)
{
// make the src the parent of the src
src = srcParent;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
*/
}
}
}
}
refreshRemoteObject(src, parent, originatedHere);
if (fakeExpanded != null){
fakeExpanded.setExpanded(false);
}
break;
case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE:
if (debug) logDebugMsg("SV event: EVENT_SELECT_REMOTE: src = " + src); //$NON-NLS-1$
@ -6383,4 +6379,9 @@ public class SystemView extends SafeTreeViewer
}
}
/** commented out - this is workaround for performance problem
protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
//System.out.println("handleLableProviderChanged");
}*/
}