Search in sources :

Example 1 with FilenameFilter

use of com.mucommander.commons.file.filter.FilenameFilter in project mucommander by mucommander.

the class MarkExtensionAction method performAction.

/**
 * Marks all files whose extension matches the current selection.
 */
@Override
public void performAction() {
    FileTable fileTable;
    FileTableModel tableModel;
    FilenameFilter filter;
    int rowCount;
    boolean mark;
    // Initialization. Aborts if there is no selected file.
    fileTable = mainFrame.getActiveTable();
    if ((filter = getFilter(fileTable.getSelectedFile(false, true))) == null)
        return;
    tableModel = fileTable.getFileTableModel();
    rowCount = tableModel.getRowCount();
    mark = !tableModel.isRowMarked(fileTable.getSelectedRow());
    // Goes through all files in the active table, marking all that match 'filter'.
    for (int i = tableModel.getFirstMarkableRow(); i < rowCount; i++) if (filter.accept(tableModel.getCachedFileAtRow(i)))
        tableModel.setRowMarked(i, mark);
    fileTable.repaint();
    // Notify registered listeners that currently marked files have changed on the FileTable
    fileTable.fireMarkedFilesChangedEvent();
}
Also used : AbstractFilenameFilter(com.mucommander.commons.file.filter.AbstractFilenameFilter) FilenameFilter(com.mucommander.commons.file.filter.FilenameFilter) ExtensionFilenameFilter(com.mucommander.commons.file.filter.ExtensionFilenameFilter) FileTableModel(com.mucommander.ui.main.table.FileTableModel) FileTable(com.mucommander.ui.main.table.FileTable)

Aggregations

AbstractFilenameFilter (com.mucommander.commons.file.filter.AbstractFilenameFilter)1 ExtensionFilenameFilter (com.mucommander.commons.file.filter.ExtensionFilenameFilter)1 FilenameFilter (com.mucommander.commons.file.filter.FilenameFilter)1 FileTable (com.mucommander.ui.main.table.FileTable)1 FileTableModel (com.mucommander.ui.main.table.FileTableModel)1