1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 04:55:22 +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: * Contributors:
* David McKnight (IBM) - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost() * David McKnight (IBM) - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost()
* Martin Oberhuber (Wind River) - [234726] Update IRemoteFile Javadocs * 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; package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -200,5 +201,15 @@ public abstract class AbstractRemoteFile extends RemoteFile
return _hostFile; 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 * 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) - [234038] Mark IRemoteFile stale when changing permissions
* Martin Oberhuber (Wind River) - [235360][ftp][ssh][local] Return proper "Root" IHostFile * 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; package org.eclipse.rse.subsystems.files.core.servicesubsystem;
@ -419,14 +420,17 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
} }
List hostFiles = new ArrayList(10); List hostFiles = new ArrayList(10);
// query children via the service
getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor); getFileService().listMultiple(parentPaths, fileNameFilters, fileTypes, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext(); 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++) for (int i = 0; i < parents.length; i++)
{ {
IRemoteFile parent = parents[i]; IRemoteFile parent = parents[i];
@ -445,9 +449,15 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
underParent.add(child); 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) 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(); parentPaths[i] = parents[i].getAbsolutePath();
} }
List hostFiles = new ArrayList(10); List hostFiles = new ArrayList(10);
// query children via the service
getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor); getFileService().listMultiple(parentPaths, fileNameFilters, fileType, hostFiles, monitor);
IHostFile[] results = new IHostFile[hostFiles.size()];
hostFiles.toArray(results);
RemoteFileContext context = getDefaultContext(); 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++) for (int i = 0; i < parents.length; i++)
{ {
IRemoteFile parent = parents[i]; IRemoteFile parent = parents[i];
@ -486,7 +499,7 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
// what files are under this one? // what files are under this one?
for (int j = 0; j < farr.length; j++) for (int j = 0; j < farr.length; j++)
{ {
IRemoteFile child = farr[j]; AbstractRemoteFile child = farr[j];
String childParentPath = child.getParentPath(); String childParentPath = child.getParentPath();
if (parentPath.equals(childParentPath)) if (parentPath.equals(childParentPath))
@ -494,9 +507,15 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
underParent.add(child); 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) if (underParent.size() > 0)
{ {
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, underParent.toArray()); Object[] qresults = underParent.toArray();
parent.setContents(RemoteChildrenContentsType.getInstance(), filter, qresults);
} }
} }
@ -526,9 +545,15 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
// query children of the parent
IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor); IHostFile[] results = internalList(parentPath, fileNameFilter, fileType, monitor);
IRemoteFile[] farr = getHostFileToRemoteFileAdapter().convertToRemoteFiles(this, context, parent, results); // 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) if (parent != null)
parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr); parent.setContents(RemoteChildrenContentsType.getInstance(), fileNameFilter, farr);
return farr; return farr;
@ -536,6 +561,27 @@ public class FileServiceSubSystem extends RemoteFileSubSystem implements IFileSe
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 public IRemoteFile[] listRoots(IRemoteFileContext context, IProgressMonitor monitor) throws InterruptedException
{ {
IHostFile[] roots = null; 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) - [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 McKnight (IBM) - [233570] ClassCastException when moving filter after "go into" action
* David Dykstal (IBM) - [233530] Backing out previous change for this bug * 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; package org.eclipse.rse.internal.ui.view;
@ -1357,6 +1358,7 @@ public class SystemView extends SafeTreeViewer
} }
} }
/** /**
* Clear current selection. Ignore widget disposed message. * Clear current selection. Ignore widget disposed message.
*/ */
@ -1367,6 +1369,8 @@ public class SystemView extends SafeTreeViewer
} }
} }
/** /**
* Returns the implementation of ISystemViewElementAdapter for the given * Returns the implementation of ISystemViewElementAdapter for the given
* object. Returns null if the adapter is not defined or the * object. Returns null if the adapter is not defined or the
@ -2226,6 +2230,11 @@ public class SystemView extends SafeTreeViewer
case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE: case ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE:
if (debug) logDebugMsg("SV event: EVENT_REFRESH_REMOTE: src = " + src); //$NON-NLS-1$ 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); ISystemViewElementAdapter adapter = getViewAdapter(src);
if (adapter != null) if (adapter != null)
@ -2233,17 +2242,15 @@ public class SystemView extends SafeTreeViewer
// we need to refresh filters // we need to refresh filters
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); 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); 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 // first, find out if src is a container or not
// if it's a container, just pass into refreshRemoteObject // if it's a container, just pass into refreshRemoteObject
@ -2255,7 +2262,17 @@ public class SystemView extends SafeTreeViewer
Object srcParent = adapter.getParent(src); Object srcParent = adapter.getParent(src);
if (srcParent != null) 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 else
@ -2280,44 +2297,23 @@ public class SystemView extends SafeTreeViewer
TreeItem[] titems = titem.getItems(); TreeItem[] titems = titem.getItems();
if (titems.length > 0 && !titem.getExpanded()) 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);
/* old code - issue in 196662 // we set this so that after calling refreshRemoteObject(), the item can be re-collapsed
String key = adapter.getAbsoluteName(src); fakeExpanded = titem;
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); refreshRemoteObject(src, parent, originatedHere);
if (fakeExpanded != null){
fakeExpanded.setExpanded(false);
}
break; break;
case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE: case ISystemResourceChangeEvents.EVENT_SELECT_REMOTE:
@ -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");
}*/
} }