use of com.mucommander.commons.file.filter.ExtensionFilenameFilter in project mucommander by mucommander.
the class MarkExtensionAction method getFilter.
// - Action code ---------------------------------------------------------------------
// -----------------------------------------------------------------------------------
/**
* Creates a {@link com.mucommander.commons.file.filter.FilenameFilter} that should be applied to all current files.
* <p>
* If the action has been configured using the <code>file.extension</code> property, the returned filter
* will match that extension. Otherwise, the currently selected file's extension will be used. If it doesn't
* have one, the returned filter will match all files such that
* <code>file.getExtension() == null</code>.
* </p>
* @param file currently selected file.
* @return the filter that should be applied by this action.
*/
private FilenameFilter getFilter(AbstractFile file) {
String ext;
ExtensionFilenameFilter filter;
// If no extension has been configured, analyse the current selection.
if ((ext = getExtension()) == null) {
// If there is no current selection, abort.
if (file == null)
return null;
// match null extensions.
if ((ext = file.getExtension()) == null)
return new AbstractFilenameFilter() {
public boolean accept(String name) {
return AbstractFile.getExtension(name) == null;
}
};
}
// At this point, ext contains the extension that should be matched.
filter = new ExtensionFilenameFilter("." + ext);
// Initialises the filter's case-sensitivy depending on the action's propeties.
filter.setCaseSensitive(isCaseSensitive());
return filter;
}
use of com.mucommander.commons.file.filter.ExtensionFilenameFilter in project mucommander by mucommander.
the class ThemeManager method getThemeNames.
private static Iterator<String> getThemeNames(AbstractFile themeFolder) {
AbstractFile[] files;
Vector<String> names;
try {
files = themeFolder.ls(new ExtensionFilenameFilter(".xml"));
names = new Vector<String>();
for (AbstractFile file : files) names.add(getThemeName(file));
return names.iterator();
} catch (Exception e) {
return new Vector<String>().iterator();
}
}
use of com.mucommander.commons.file.filter.ExtensionFilenameFilter in project mucommander by mucommander.
the class ExtensionManager method addExtensionsToClasspath.
/**
* Adds all known extensions to the current classpath.
* <p>
* This method will create the following new classpath entries:
* <ul>
* <li>{@link #getExtensionsFolder()}</li>.
* <li>All <code>JAR</code> files in {@link #getExtensionsFolder()}.</li>
* </ul>
* </p>
* @throws IOException if the extensions folder is not accessible.
*/
public static void addExtensionsToClasspath() throws IOException {
AbstractFile[] files;
// Adds the extensions folder to the classpath.
addToClassPath(getExtensionsFolder());
// Adds all JAR files contained by the extensions folder to the classpath.
files = getExtensionsFolder().ls(new ExtensionFilenameFilter(".jar"));
for (AbstractFile file : files) addToClassPath(file);
}
Aggregations