Search in sources :

Example 1 with ExtensionFilenameFilter

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;
}
Also used : AbstractFilenameFilter(com.mucommander.commons.file.filter.AbstractFilenameFilter) ExtensionFilenameFilter(com.mucommander.commons.file.filter.ExtensionFilenameFilter)

Example 2 with ExtensionFilenameFilter

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();
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) ExtensionFilenameFilter(com.mucommander.commons.file.filter.ExtensionFilenameFilter) Vector(java.util.Vector) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 3 with ExtensionFilenameFilter

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);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) ExtensionFilenameFilter(com.mucommander.commons.file.filter.ExtensionFilenameFilter)

Aggregations

ExtensionFilenameFilter (com.mucommander.commons.file.filter.ExtensionFilenameFilter)3 AbstractFile (com.mucommander.commons.file.AbstractFile)2 AbstractFilenameFilter (com.mucommander.commons.file.filter.AbstractFilenameFilter)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Vector (java.util.Vector)1