* @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;
// If the current file doesn't have an extension, return a filename filter that
// 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;
}