mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
[207178] listFolders queries folders, not both
This commit is contained in:
parent
0dfacdf39d
commit
23fd70411a
1 changed files with 74 additions and 77 deletions
|
@ -442,6 +442,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO - change this to use listMulti to be more efficient
|
||||||
for (int idx=0; idx<filterStrings.length; idx++)
|
for (int idx=0; idx<filterStrings.length; idx++)
|
||||||
{
|
{
|
||||||
if (monitor != null)
|
if (monitor != null)
|
||||||
|
@ -580,18 +581,11 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Actually resolve an absolute filter string. This is called by the
|
private String fixFilterString(IRemoteFileSubSystemConfiguration rfssf, String filterString)
|
||||||
* run(IProgressMonitor monitor) method, which in turn is called by resolveFilterString.
|
|
||||||
* @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(String,IProgressMonitor)
|
|
||||||
*/
|
|
||||||
protected Object[] internalResolveFilterString(String filterString, IProgressMonitor monitor) throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
|
|
||||||
{
|
{
|
||||||
boolean debugMode = false;
|
|
||||||
IRemoteFileSubSystemConfiguration rfssf = getParentRemoteFileSubSystemConfiguration();
|
|
||||||
boolean windows = !rfssf.isUnixStyle();
|
boolean windows = !rfssf.isUnixStyle();
|
||||||
if (debugMode)
|
|
||||||
SystemBasePlugin.logInfo("INTERNALRESOLVEFILTERSTRING: INPUT FILTERSTRING: " + filterString); //$NON-NLS-1$
|
|
||||||
if (filterString.startsWith("/") && windows) // request to list root files? //$NON-NLS-1$
|
if (filterString.startsWith("/") && windows) // request to list root files? //$NON-NLS-1$
|
||||||
{ // convert to request to list drives on Windows
|
{ // convert to request to list drives on Windows
|
||||||
int len = filterString.length();
|
int len = filterString.length();
|
||||||
|
@ -599,13 +593,24 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
filterString = "*"; // hmm, should never happen //$NON-NLS-1$
|
filterString = "*"; // hmm, should never happen //$NON-NLS-1$
|
||||||
else
|
else
|
||||||
filterString = filterString.substring(1);
|
filterString = filterString.substring(1);
|
||||||
if (debugMode)
|
|
||||||
SystemBasePlugin.logInfo("...FINAL FILTERSTRING: " + filterString); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return filterString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually resolve an absolute filter string. This is called by the
|
||||||
|
* run(IProgressMonitor monitor) method, which in turn is called by resolveFilterString.
|
||||||
|
* @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(String,IProgressMonitor)
|
||||||
|
*/
|
||||||
|
protected Object[] internalResolveFilterString(String filterString, IProgressMonitor monitor) throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
|
||||||
|
{
|
||||||
|
IRemoteFileSubSystemConfiguration rfssf = getParentRemoteFileSubSystemConfiguration();
|
||||||
|
filterString = fixFilterString(rfssf, filterString);
|
||||||
|
|
||||||
RemoteFileFilterString fs = new RemoteFileFilterString(rfssf, filterString);
|
RemoteFileFilterString fs = new RemoteFileFilterString(rfssf, filterString);
|
||||||
currFilterString = fs;
|
currFilterString = fs;
|
||||||
if (debugMode)
|
|
||||||
SystemBasePlugin.logInfo("...LISTROOTS = " + fs.listRoots()); //$NON-NLS-1$
|
|
||||||
if (fs.listRoots())
|
if (fs.listRoots())
|
||||||
return listRoots(new RemoteFileContext(this, null, fs), monitor);
|
return listRoots(new RemoteFileContext(this, null, fs), monitor);
|
||||||
else
|
else
|
||||||
|
@ -613,24 +618,16 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
boolean showDirs = fs.getShowSubDirs();
|
boolean showDirs = fs.getShowSubDirs();
|
||||||
boolean showFiles = fs.getShowFiles();
|
boolean showFiles = fs.getShowFiles();
|
||||||
String path = fs.getPath();
|
String path = fs.getPath();
|
||||||
|
boolean windows = !rfssf.isUnixStyle();
|
||||||
|
|
||||||
if (windows && (path != null) && !path.endsWith(rfssf.getSeparator()))
|
if (windows && (path != null) && !path.endsWith(rfssf.getSeparator()))
|
||||||
path = path + rfssf.getSeparatorChar();
|
path = path + rfssf.getSeparatorChar();
|
||||||
String filter = fs.getFileOrTypes();
|
|
||||||
if (debugMode)
|
|
||||||
SystemBasePlugin.logInfo("...path='" + path + "', filter='" + filter + "', showDirs=" + showDirs + ", showFiles=" + showFiles); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
||||||
|
|
||||||
|
String filter = fs.getFileOrTypes();
|
||||||
IRemoteFile parent = null;
|
IRemoteFile parent = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parent = getRemoteFileObject(path, monitor);
|
parent = getRemoteFileObject(path, monitor);
|
||||||
|
|
||||||
/* DKM - now filters should get invalidated via SystemRegistry event firing so this should not be needed
|
|
||||||
*
|
|
||||||
// DKM: this may be a filter refresh - to be safe I'm marking it stale
|
|
||||||
if (parent != null)
|
|
||||||
parent.markStale(true);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
|
@ -646,66 +643,66 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
Object[] children = null;
|
Object[] children = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// if parent exists, get its children according to the filter
|
// if parent exists, get its children according to the filter
|
||||||
if (parent != null && parentExists)
|
if (parent != null && parentExists)
|
||||||
{
|
|
||||||
boolean hasFileContents = !parent.isStale() && parent.hasContents(RemoteFileChildrenContentsType.getInstance(), filter);
|
|
||||||
boolean hasFolderContents = !parent.isStale() && parent.hasContents(RemoteFolderChildrenContentsType.getInstance(), filter);
|
|
||||||
boolean hasFileAndFolderContents = !parent.isStale() && parent.hasContents(RemoteChildrenContentsType.getInstance(), filter);
|
|
||||||
if (showDirs && showFiles)
|
|
||||||
{
|
{
|
||||||
|
boolean hasFileContents = !parent.isStale() && parent.hasContents(RemoteFileChildrenContentsType.getInstance(), filter);
|
||||||
if (hasFileAndFolderContents)
|
boolean hasFolderContents = !parent.isStale() && parent.hasContents(RemoteFolderChildrenContentsType.getInstance(), filter);
|
||||||
|
boolean hasFileAndFolderContents = !parent.isStale() && parent.hasContents(RemoteChildrenContentsType.getInstance(), filter);
|
||||||
|
if (showDirs && showFiles)
|
||||||
{
|
{
|
||||||
|
if (hasFileAndFolderContents)
|
||||||
|
{
|
||||||
|
// has everything
|
||||||
|
}
|
||||||
|
else if (hasFileContents)
|
||||||
|
{
|
||||||
|
// already have the files, now add the folders
|
||||||
|
list(parent, filter, IFileServiceConstants.FILE_TYPE_FOLDERS, monitor);
|
||||||
|
}
|
||||||
|
else if (hasFolderContents)
|
||||||
|
{
|
||||||
|
// already have the folders, now add the files
|
||||||
|
list(parent, filter, IFileServiceConstants.FILE_TYPE_FILES, monitor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// don't have anything - query both
|
||||||
|
list(parent, filter, IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS, monitor);
|
||||||
|
}
|
||||||
|
children = parent.getContents(RemoteChildrenContentsType.getInstance(), filter);
|
||||||
}
|
}
|
||||||
else if (hasFileContents)
|
else if (showDirs)
|
||||||
{
|
{
|
||||||
// already have the files, now add the folders
|
if (hasFolderContents)
|
||||||
list(parent, filter, IFileServiceConstants.FILE_TYPE_FOLDERS, monitor);
|
{
|
||||||
}
|
children = parent.getContents(RemoteFolderChildrenContentsType.getInstance(), filter);
|
||||||
else if (hasFolderContents)
|
}
|
||||||
{
|
else
|
||||||
// already have the folders, now add the files
|
{
|
||||||
list(parent, filter, IFileServiceConstants.FILE_TYPE_FILES, monitor);
|
children = listFolders(parent, filter, monitor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// don't have anything - query both
|
if (hasFileContents)
|
||||||
list(parent, filter, IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS, monitor);
|
{
|
||||||
}
|
children = parent.getContents(RemoteFileChildrenContentsType.getInstance(), filter);
|
||||||
children = parent.getContents(RemoteChildrenContentsType.getInstance(), filter);
|
}
|
||||||
}
|
else
|
||||||
else if (showDirs)
|
{
|
||||||
{
|
children = listFiles(parent, filter, monitor);
|
||||||
if (hasFolderContents)
|
}
|
||||||
{
|
|
||||||
children = parent.getContents(RemoteFolderChildrenContentsType.getInstance(), filter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
children = listFolders(parent, filter, monitor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
// otherwise return message saying parent could not be found
|
||||||
{
|
else if (parent != null && !parentExists) {
|
||||||
if (hasFileContents)
|
children = new SystemMessageObject[1];
|
||||||
{
|
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_FOLDER_NOTFOUND);
|
||||||
children = parent.getContents(RemoteFileChildrenContentsType.getInstance(), filter);
|
msg.makeSubstitution(parent.getAbsolutePath());
|
||||||
}
|
children[0] = new SystemMessageObject(msg, ISystemMessageObject.MSGTYPE_ERROR, null);
|
||||||
else
|
|
||||||
{
|
|
||||||
children = listFiles(parent, filter, monitor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise return message saying parent could not be found
|
|
||||||
else if (parent != null && !parentExists) {
|
|
||||||
children = new SystemMessageObject[1];
|
|
||||||
SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_FOLDER_NOTFOUND);
|
|
||||||
msg.makeSubstitution(parent.getAbsolutePath());
|
|
||||||
children[0] = new SystemMessageObject(msg, ISystemMessageObject.MSGTYPE_ERROR, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SystemMessageException e)
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
children = new SystemMessageObject[1];
|
children = new SystemMessageObject[1];
|
||||||
|
@ -1465,7 +1462,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
||||||
*/
|
*/
|
||||||
public IRemoteFile[] listFolders(IRemoteFile parent, IProgressMonitor monitor) throws SystemMessageException
|
public IRemoteFile[] listFolders(IRemoteFile parent, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
return list(parent, IFileServiceConstants.FILE_TYPE_FILES_AND_FOLDERS, monitor);
|
return list(parent, IFileServiceConstants.FILE_TYPE_FOLDERS, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue