mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +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 java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
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.ISystemFileTypes;
|
||||||
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||||
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
||||||
|
@ -123,18 +125,28 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
||||||
|
|
||||||
public class LocalFileNameFilter implements FilenameFilter
|
public class LocalFileNameFilter implements FilenameFilter
|
||||||
{
|
{
|
||||||
private NamePatternMatcher _matcher;
|
private IMatcher _matcher;
|
||||||
public LocalFileNameFilter(String filter)
|
public LocalFileNameFilter(String filter)
|
||||||
{
|
{
|
||||||
|
if (filter.endsWith(",")) {
|
||||||
|
String[] types = filter.split(",");
|
||||||
|
_matcher = new FileTypeMatcher(types);
|
||||||
|
} else {
|
||||||
_matcher = new NamePatternMatcher(filter);
|
_matcher = new NamePatternMatcher(filter);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public boolean accept(File dir, String name)
|
public boolean accept(File dir, String name)
|
||||||
{
|
{
|
||||||
return _matcher.matches(name);
|
return _matcher.matches(name);
|
||||||
}
|
}
|
||||||
public boolean isGeneric()
|
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
|
public IRemoteFile[] listFiles(IRemoteFile parent, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
RemoteFileFilterString filterString = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration());
|
fileNameFilter = (fileNameFilter == null) ? "*" : fileNameFilter;
|
||||||
filterString.setPath(parent.getAbsolutePath());
|
String parentPath = parent.getAbsolutePath();
|
||||||
filterString.setFile((fileNameFilter == null) ? "*" : fileNameFilter);
|
IRemoteFileSubSystemConfiguration config = getParentRemoteFileSubSystemConfiguration();
|
||||||
|
RemoteFileFilterString filterString = new RemoteFileFilterString(config, parentPath, fileNameFilter);
|
||||||
filterString.setShowFiles(true);
|
filterString.setShowFiles(true);
|
||||||
filterString.setShowSubDirs(false);
|
filterString.setShowSubDirs(false);
|
||||||
RemoteFileContext context = new RemoteFileContext(this, parent, filterString);
|
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
|
public IRemoteFile[] listFoldersAndFiles(IRemoteFile parent, String fileNameFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||||
{
|
{
|
||||||
|
String path = parent.getAbsolutePath();
|
||||||
|
fileNameFilter = (fileNameFilter == null) ? "*" : fileNameFilter;
|
||||||
RemoteFileFilterString filterString = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration());
|
IRemoteFileSubSystemConfiguration config = getParentRemoteFileSubSystemConfiguration();
|
||||||
filterString.setPath(parent.getAbsolutePath());
|
RemoteFileFilterString filterString = new RemoteFileFilterString(config, path, fileNameFilter);
|
||||||
if (fileNameFilter == null)
|
|
||||||
fileNameFilter = "*"; //$NON-NLS-1$
|
|
||||||
filterString.setFile(fileNameFilter);
|
|
||||||
filterString.setShowFiles(true);
|
filterString.setShowFiles(true);
|
||||||
filterString.setShowSubDirs(true);
|
filterString.setShowSubDirs(true);
|
||||||
RemoteFileContext context = new RemoteFileContext(this, parent, filterString);
|
RemoteFileContext context = new RemoteFileContext(this, parent, filterString);
|
||||||
|
|
Loading…
Add table
Reference in a new issue