mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 23:55:26 +02:00
Bug 160397 - get filtering by file type to work properly in the local and dstore subsystems.
This commit is contained in:
parent
2cf0186dbd
commit
edd4669f53
2 changed files with 23 additions and 13 deletions
|
@ -32,6 +32,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.rse.services.clientserver.FileTypeMatcher;
|
||||
import org.eclipse.rse.services.clientserver.IMatcher;
|
||||
import org.eclipse.rse.services.clientserver.ISystemFileTypes;
|
||||
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
||||
|
@ -123,10 +125,15 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
|||
|
||||
public class LocalFileNameFilter implements FilenameFilter
|
||||
{
|
||||
private NamePatternMatcher _matcher;
|
||||
private IMatcher _matcher;
|
||||
public LocalFileNameFilter(String filter)
|
||||
{
|
||||
_matcher = new NamePatternMatcher(filter);
|
||||
if (filter.endsWith(",")) {
|
||||
String[] types = filter.split(",");
|
||||
_matcher = new FileTypeMatcher(types);
|
||||
} else {
|
||||
_matcher = new NamePatternMatcher(filter);
|
||||
}
|
||||
}
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
|
@ -134,7 +141,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
|||
}
|
||||
public boolean isGeneric()
|
||||
{
|
||||
return _matcher.isGeneric();
|
||||
boolean result = true;
|
||||
if (_matcher instanceof NamePatternMatcher) {
|
||||
NamePatternMatcher new_name = (NamePatternMatcher) _matcher;
|
||||
result = new_name.isGeneric();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -894,9 +894,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
*/
|
||||
public IRemoteFile[] listFiles(IRemoteFile parent, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
RemoteFileFilterString filterString = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration());
|
||||
filterString.setPath(parent.getAbsolutePath());
|
||||
filterString.setFile((fileNameFilter == null) ? "*" : fileNameFilter);
|
||||
fileNameFilter = (fileNameFilter == null) ? "*" : fileNameFilter;
|
||||
String parentPath = parent.getAbsolutePath();
|
||||
IRemoteFileSubSystemConfiguration config = getParentRemoteFileSubSystemConfiguration();
|
||||
RemoteFileFilterString filterString = new RemoteFileFilterString(config, parentPath, fileNameFilter);
|
||||
filterString.setShowFiles(true);
|
||||
filterString.setShowSubDirs(false);
|
||||
RemoteFileContext context = new RemoteFileContext(this, parent, filterString);
|
||||
|
@ -923,13 +924,10 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
|
|||
*/
|
||||
public IRemoteFile[] listFoldersAndFiles(IRemoteFile parent, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
|
||||
|
||||
RemoteFileFilterString filterString = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration());
|
||||
filterString.setPath(parent.getAbsolutePath());
|
||||
if (fileNameFilter == null)
|
||||
fileNameFilter = "*"; //$NON-NLS-1$
|
||||
filterString.setFile(fileNameFilter);
|
||||
String path = parent.getAbsolutePath();
|
||||
fileNameFilter = (fileNameFilter == null) ? "*" : fileNameFilter;
|
||||
IRemoteFileSubSystemConfiguration config = getParentRemoteFileSubSystemConfiguration();
|
||||
RemoteFileFilterString filterString = new RemoteFileFilterString(config, path, fileNameFilter);
|
||||
filterString.setShowFiles(true);
|
||||
filterString.setShowSubDirs(true);
|
||||
RemoteFileContext context = new RemoteFileContext(this, parent, filterString);
|
||||
|
|
Loading…
Add table
Reference in a new issue