use of com.mucommander.commons.file.filter.RegexpFilenameFilter in project mucommander by mucommander.
the class CommandManager method buildFilter.
// - Associations building -------------------------------------------------
// -------------------------------------------------------------------------
private static void buildFilter(FileFilter filter, AssociationBuilder builder) throws CommandException {
// Filter on the file type.
if (filter instanceof AttributeFileFilter) {
AttributeFileFilter attributeFilter;
attributeFilter = (AttributeFileFilter) filter;
switch(attributeFilter.getAttribute()) {
case HIDDEN:
builder.setIsHidden(!attributeFilter.isInverted());
break;
case SYMLINK:
builder.setIsSymlink(!attributeFilter.isInverted());
break;
}
} else if (filter instanceof PermissionsFileFilter) {
PermissionsFileFilter permissionFilter = (PermissionsFileFilter) filter;
switch(permissionFilter.getPermission()) {
case READ:
builder.setIsReadable(permissionFilter.getFilter());
break;
case WRITE:
builder.setIsWritable(permissionFilter.getFilter());
break;
case EXECUTE:
builder.setIsExecutable(permissionFilter.getFilter());
break;
}
} else if (filter instanceof RegexpFilenameFilter) {
RegexpFilenameFilter regexpFilter = (RegexpFilenameFilter) filter;
builder.setMask(regexpFilter.getRegularExpression(), regexpFilter.isCaseSensitive());
}
}
use of com.mucommander.commons.file.filter.RegexpFilenameFilter in project mucommander by mucommander.
the class FileSelectionDialog method actionPerformed.
// //////////////////////////
// ActionListener methods //
// //////////////////////////
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
FileTable activeTable = mainFrame.getActiveTable();
// Action coming from the selection dialog
if ((source == okButton || source == selectionField)) {
// Save values for next time this dialog is invoked
caseSensitive = caseSensitiveCheckBox.isSelected();
includeFolders = includeFoldersCheckBox.isSelected();
comparison = comparisonComboBox.getSelectedIndex();
String testString;
keywordString = selectionField.getText();
if (comparison != REGEXP) {
// Remove '*' characters
testString = keywordString.replace("*", "");
} else {
testString = keywordString;
}
// Instantiate the main file filter
FileFilter filter;
switch(comparison) {
case CONTAINS:
filter = new ContainsFilenameFilter(testString, caseSensitive);
break;
case STARTS_WITH:
filter = new StartsWithFilenameFilter(testString, caseSensitive);
break;
case ENDS_WIDTH:
filter = new EndsWithFilenameFilter(testString, caseSensitive);
break;
case IS:
filter = new EqualsFilenameFilter(testString, caseSensitive);
break;
case REGEXP:
default:
try {
filter = new RegexpFilenameFilter(testString, caseSensitive);
} catch (PatternSyntaxException ex) {
// Todo: let the user know the regexp is invalid
LOGGER.debug("Invalid regexp", ex);
// This filter does match any file
filter = new PassThroughFileFilter(false);
}
break;
}
// If folders are excluded, add a regular file filter and chain it with an AndFileFilter
if (!includeFolders) {
filter = new AndFileFilter(new AttributeFileFilter(FileAttribute.FILE), filter);
}
// Mark/unmark the files using the filter
activeTable.getFileTableModel().setFilesMarked(filter, addToSelection);
// Notify registered listeners that currently marked files have changed on this FileTable
activeTable.fireMarkedFilesChangedEvent();
activeTable.repaint();
}
dispose();
}
use of com.mucommander.commons.file.filter.RegexpFilenameFilter in project mucommander by mucommander.
the class WindowsDesktopAdapter method init.
@Override
public void init(boolean install) throws DesktopInitialisationException {
try {
CommandManager.registerDefaultCommand(new WindowsCmdCommand(CommandManager.FILE_OPENER_ALIAS, FILE_OPENER_COMMAND, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new WindowsCmdCommand(CommandManager.URL_OPENER_ALIAS, FILE_OPENER_COMMAND, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new WindowsCmdCommand(CommandManager.FILE_MANAGER_ALIAS, EXPLORER_COMMAND, CommandType.SYSTEM_COMMAND, EXPLORER_NAME));
CommandManager.registerDefaultCommand(new WindowsCmdCommand(CommandManager.EXE_OPENER_ALIAS, EXE_OPENER_COMMAND, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new WindowsCmdCommand(CommandManager.CMD_OPENER_ALIAS, CMD_OPENER_COMMAND, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultAssociation(CommandManager.EXE_OPENER_ALIAS, new RegexpFilenameFilter(EXE_REGEXP, false));
} catch (CommandException e) {
throw new DesktopInitialisationException(e);
}
}
use of com.mucommander.commons.file.filter.RegexpFilenameFilter in project mucommander by mucommander.
the class GnomeDesktopAdapter method init.
@Override
public void init(boolean install) throws DesktopInitialisationException {
String fileOpener = String.format("%s $f", getFileOpenerCommand());
try {
CommandManager.registerDefaultCommand(new Command(CommandManager.FILE_OPENER_ALIAS, fileOpener, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new Command(CommandManager.URL_OPENER_ALIAS, fileOpener, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new Command(CommandManager.EXE_OPENER_ALIAS, EXE_OPENER, CommandType.SYSTEM_COMMAND, null));
CommandManager.registerDefaultCommand(new Command(CommandManager.FILE_MANAGER_ALIAS, fileOpener, CommandType.SYSTEM_COMMAND, FILE_MANAGER_NAME));
CommandManager.registerDefaultCommand(new Command(CommandManager.CMD_OPENER_ALIAS, CMD_OPENER_COMMAND, CommandType.SYSTEM_COMMAND, null));
// Disabled actual permissions checking as this will break normal +x files.
// With this, a +x PDF file will not be opened.
/*
// Identifies which kind of filter should be used to match executable files.
if(JavaVersion.JAVA_6.isCurrentOrHigher())
filter = new PermissionsFileFilter(PermissionTypes.EXECUTE_PERMISSION, true);
else
*/
FileFilter filter = new RegexpFilenameFilter("[^.]+", true);
CommandManager.registerDefaultAssociation(CommandManager.EXE_OPENER_ALIAS, filter);
// Multi-click interval retrieval
try {
String value = GnomeConfig.getValue(DOUBLE_CLICK_CONFIG_KEY);
if (value == null)
multiClickInterval = super.getMultiClickInterval();
multiClickInterval = Integer.parseInt(value);
} catch (Exception e) {
LOGGER.debug("Error while retrieving double-click interval from gconftool", e);
multiClickInterval = super.getMultiClickInterval();
}
} catch (CommandException e) {
throw new DesktopInitialisationException(e);
}
}
Aggregations