mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
[277911] cached results of remote file query need to be sorted
This commit is contained in:
parent
837b060804
commit
2f85b3ea6e
1 changed files with 56 additions and 62 deletions
|
@ -20,12 +20,14 @@
|
|||
* Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal
|
||||
* Martin Oberhuber (Wind River) - [219975] Fix implementations of clone()
|
||||
* David McKnight (IBM) - [231209] [api][breaking] IRemoteFile.getSystemConnection() should be changed to IRemoteFile.getHost()
|
||||
* David McKnight (IBM) - [277911] cached results of remote file query need to be sorted
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -678,7 +680,7 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
public Object[] getContents(ISystemContentsType contentsType, String filter)
|
||||
{
|
||||
HashMap filters = (HashMap)(_contents.get(contentsType));
|
||||
|
||||
Object[] results = null;
|
||||
if (filters == null || filters.isEmpty())
|
||||
{
|
||||
if (contentsType == RemoteChildrenContentsType.getInstance())
|
||||
|
@ -715,66 +717,59 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
filter = "*"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (filters.containsKey(filter))
|
||||
{
|
||||
if (filters.containsKey(filter)){
|
||||
Object[] filterResults = (Object[])filters.get(filter);
|
||||
if (contentsType == RemoteChildrenContentsType.getInstance() ||
|
||||
contentsType == RemoteFileChildrenContentsType.getInstance() ||
|
||||
contentsType == RemoteFolderChildrenContentsType.getInstance()
|
||||
)
|
||||
{
|
||||
return filterResults;
|
||||
}
|
||||
else
|
||||
{
|
||||
return filterResults;
|
||||
}
|
||||
results = filterResults;
|
||||
}
|
||||
|
||||
ArrayList calculatedResults = new ArrayList();
|
||||
|
||||
StringComparePatternMatcher fmatcher = new StringComparePatternMatcher(filter);
|
||||
|
||||
// the filter may be a subset of existing filters
|
||||
Object[] keySet = filters.keySet().toArray();
|
||||
|
||||
for (int i = 0; i < keySet.length; i++) {
|
||||
|
||||
String key = (String)keySet[i];
|
||||
|
||||
// KM: we need to match with the key to ensure that the filter is a subset
|
||||
StringComparePatternMatcher matcher = new StringComparePatternMatcher(key);
|
||||
|
||||
if (matcher.stringMatches(filter)) {
|
||||
// get all children, i.e. the superset
|
||||
Object[] all = (Object[]) filters.get(key);
|
||||
|
||||
if (all != null) {
|
||||
|
||||
for (int s = 0; s < all.length; s++) {
|
||||
|
||||
Object subContent = all[s];
|
||||
|
||||
if (!calculatedResults.contains(subContent)) {
|
||||
|
||||
if (subContent instanceof IRemoteFile) {
|
||||
|
||||
IRemoteFile temp = (IRemoteFile) subContent;
|
||||
|
||||
if (temp.isFile()) {
|
||||
String compareTo = null;
|
||||
boolean filterForFileTypes = isFilterForFileTypes(filter);
|
||||
|
||||
if (!filterForFileTypes) {
|
||||
compareTo = temp.getName();
|
||||
else {
|
||||
ArrayList calculatedResults = new ArrayList();
|
||||
|
||||
StringComparePatternMatcher fmatcher = new StringComparePatternMatcher(filter);
|
||||
|
||||
// the filter may be a subset of existing filters
|
||||
Object[] keySet = filters.keySet().toArray();
|
||||
|
||||
for (int i = 0; i < keySet.length; i++) {
|
||||
|
||||
String key = (String)keySet[i];
|
||||
|
||||
// KM: we need to match with the key to ensure that the filter is a subset
|
||||
StringComparePatternMatcher matcher = new StringComparePatternMatcher(key);
|
||||
|
||||
if (matcher.stringMatches(filter)) {
|
||||
// get all children, i.e. the superset
|
||||
Object[] all = (Object[]) filters.get(key);
|
||||
|
||||
if (all != null) {
|
||||
|
||||
for (int s = 0; s < all.length; s++) {
|
||||
|
||||
Object subContent = all[s];
|
||||
|
||||
if (!calculatedResults.contains(subContent)) {
|
||||
|
||||
if (subContent instanceof IRemoteFile) {
|
||||
|
||||
IRemoteFile temp = (IRemoteFile) subContent;
|
||||
|
||||
if (temp.isFile()) {
|
||||
String compareTo = null;
|
||||
boolean filterForFileTypes = isFilterForFileTypes(filter);
|
||||
|
||||
if (!filterForFileTypes) {
|
||||
compareTo = temp.getName();
|
||||
}
|
||||
else {
|
||||
compareTo = temp.getExtension();
|
||||
}
|
||||
|
||||
// match with the filter to take out those
|
||||
// that do not match the filter
|
||||
if (compareTo != null && fmatcher.stringMatches(compareTo)) {
|
||||
calculatedResults.add(subContent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
compareTo = temp.getExtension();
|
||||
}
|
||||
|
||||
// match with the filter to take out those
|
||||
// that do not match the filter
|
||||
if (compareTo != null && fmatcher.stringMatches(compareTo)) {
|
||||
calculatedResults.add(subContent);
|
||||
}
|
||||
}
|
||||
|
@ -782,16 +777,15 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
calculatedResults.add(subContent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
calculatedResults.add(subContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
results = calculatedResults.toArray();
|
||||
}
|
||||
|
||||
return calculatedResults.toArray();
|
||||
Arrays.sort(results);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue