Search in sources :

Example 16 with FileTable

use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.

the class StressTester method run.

public void run() {
    Random random = new Random();
    MainFrame mainFrame = WindowManager.getCurrentMainFrame();
    while (run) {
        if (random.nextInt(2) == 0)
            ActionManager.performAction(com.mucommander.ui.action.impl.SwitchActiveTableAction.Descriptor.ACTION_ID, mainFrame);
        FolderPanel folderPanel = mainFrame.getActivePanel();
        FileTable fileTable = mainFrame.getActiveTable();
        AbstractFile currentFolder = folderPanel.getCurrentFolder();
        try {
            AbstractFile parentFolder = currentFolder.getParent();
            AbstractFile[] children = currentFolder.ls();
            // 1 in 3 chance to go up if folder has children
            if (children.length == 0 || (random.nextInt(3) == 0 && parentFolder != null)) {
                fileTable.selectRow(0);
                ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
            } else {
                AbstractFile randomChild = children[random.nextInt(children.length)];
                if (!randomChild.isBrowsable())
                    continue;
                // Try to ls() in RandomChild to trigger an IOException if folder is not readable
                // so that no error dialog pops up when calling tryChangeCurrentFolder()
                randomChild.ls();
                fileTable.selectFile(randomChild);
                ActionManager.performAction(com.mucommander.ui.action.impl.OpenAction.Descriptor.ACTION_ID, mainFrame);
            // folderPanel.tryChangeCurrentFolder(randomChild, true);
            }
        } catch (Exception e) {
            LOGGER.debug("Caught Exception", e);
        }
        LOGGER.trace("Sleeping for a bit...");
        try {
            Thread.sleep(100 + random.nextInt(200));
        } catch (InterruptedException e) {
            LOGGER.debug("Caught InterruptedException", e);
        }
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) Random(java.util.Random) FileTable(com.mucommander.ui.main.table.FileTable) MainFrame(com.mucommander.ui.main.MainFrame) FolderPanel(com.mucommander.ui.main.FolderPanel) IOException(java.io.IOException)

Example 17 with FileTable

use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.

the class MainFrame method swapFolders.

/**
 * Swaps the two FolderPanel instances: after a call to this method, the left FolderPanel will be the right one and
 * vice-versa.
 */
public void swapFolders() {
    splitPane.remove(leftFolderPanel);
    splitPane.remove(rightFolderPanel);
    // Swaps the folder panels.
    FolderPanel tempPanel = leftFolderPanel;
    leftFolderPanel = rightFolderPanel;
    rightFolderPanel = tempPanel;
    // swaps folders trees
    int tempTreeWidth = leftFolderPanel.getTreeWidth();
    leftFolderPanel.setTreeWidth(rightFolderPanel.getTreeWidth());
    rightFolderPanel.setTreeWidth(tempTreeWidth);
    boolean tempTreeVisible = leftFolderPanel.isTreeVisible();
    leftFolderPanel.setTreeVisible(rightFolderPanel.isTreeVisible());
    rightFolderPanel.setTreeVisible(tempTreeVisible);
    // Resets the tables.
    FileTable tempTable = leftTable;
    leftTable = rightTable;
    rightTable = tempTable;
    // Preserve the sort order and columns visibility.
    TableColumnModel model = leftTable.getColumnModel();
    leftTable.setColumnModel(rightTable.getColumnModel());
    rightTable.setColumnModel(model);
    SortInfo sortInfo = (SortInfo) leftTable.getSortInfo().clone();
    leftTable.sortBy(rightTable.getSortInfo());
    leftTable.updateColumnsVisibility();
    rightTable.sortBy(sortInfo);
    rightTable.updateColumnsVisibility();
    // Do the swap and update the split pane
    splitPane.setLeftComponent(leftFolderPanel);
    splitPane.setRightComponent(rightFolderPanel);
    splitPane.doLayout();
    // Update split pane divider's location
    splitPane.updateDividerLocation();
    activeTable.requestFocus();
}
Also used : TableColumnModel(javax.swing.table.TableColumnModel) FileTable(com.mucommander.ui.main.table.FileTable) SortInfo(com.mucommander.ui.main.table.SortInfo)

Example 18 with FileTable

use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.

the class FileViewerPresenter method goToFile.

@Override
public void goToFile(Function<Integer, Integer> advance, FileViewerService viewerService) throws IOException {
    FileTable fileTable = getFrame().getMainFrame().getActiveTable();
    AbstractFile newFile;
    int originalRow = fileTable.getSelectedRow();
    boolean canView;
    do {
        int currentRow = fileTable.getSelectedRow();
        int newRow = advance.apply(currentRow);
        if (newRow < 0 || newRow >= fileTable.getRowCount()) {
            fileTable.selectRow(originalRow);
            return;
        }
        fileTable.selectRow(newRow);
        newFile = fileTable.getSelectedFile();
        try {
            canView = viewerService.canViewFile(newFile);
        } catch (WarnUserException ex) {
            canView = false;
        }
    } while (newFile == null || !canView);
    setCurrentFile(newFile);
    fileViewer.open(newFile);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileTable(com.mucommander.ui.main.table.FileTable) WarnUserException(com.mucommander.viewer.WarnUserException)

Example 19 with FileTable

use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.

the class InternalViewAction method performInternalAction.

// - AbstractViewerAction implementation ---------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
@Override
protected void performInternalAction(AbstractFile file) {
    if (file.isDirectory()) {
        FileTable activeTable = mainFrame.getActiveTable();
        FileTableModel fileTableModel = (FileTableModel) activeTable.getModel();
        fileTableModel.startDirectorySizeCalculation(activeTable, file);
    } else {
        ViewerRegistrar.createViewerFrame(mainFrame, file, getIcon().getImage());
    }
}
Also used : FileTableModel(com.mucommander.ui.main.table.FileTableModel) FileTable(com.mucommander.ui.main.table.FileTable)

Example 20 with FileTable

use of com.mucommander.ui.main.table.FileTable in project mucommander by mucommander.

the class InvertSelectionAction method performAction.

@Override
public void performAction() {
    FileTable fileTable = mainFrame.getActiveTable();
    FileTableModel tableModel = fileTable.getFileTableModel();
    // Starts at 1 if current folder is not root so that '..' is not marked
    AbstractFile file;
    int nbRows = tableModel.getRowCount();
    for (int i = tableModel.getFirstMarkableRow(); i < nbRows; i++) {
        file = tableModel.getFileAtRow(i);
        tableModel.setRowMarked(i, !tableModel.isRowMarked(i));
    }
    fileTable.repaint();
    // Notify registered listeners that currently marked files have changed on the FileTable
    fileTable.fireMarkedFilesChangedEvent();
}
Also used : FileTableModel(com.mucommander.ui.main.table.FileTableModel) AbstractFile(com.mucommander.commons.file.AbstractFile) FileTable(com.mucommander.ui.main.table.FileTable)

Aggregations

FileTable (com.mucommander.ui.main.table.FileTable)25 AbstractFile (com.mucommander.commons.file.AbstractFile)10 FileTableModel (com.mucommander.ui.main.table.FileTableModel)8 FolderPanel (com.mucommander.ui.main.FolderPanel)3 MainFrame (com.mucommander.ui.main.MainFrame)2 TablePopupMenu (com.mucommander.ui.main.menu.TablePopupMenu)2 Component (java.awt.Component)2 Rectangle (java.awt.Rectangle)2 JTextField (javax.swing.JTextField)2 JTree (javax.swing.JTree)2 AbstractFilenameFilter (com.mucommander.commons.file.filter.AbstractFilenameFilter)1 AndFileFilter (com.mucommander.commons.file.filter.AndFileFilter)1 AttributeFileFilter (com.mucommander.commons.file.filter.AttributeFileFilter)1 ContainsFilenameFilter (com.mucommander.commons.file.filter.ContainsFilenameFilter)1 EndsWithFilenameFilter (com.mucommander.commons.file.filter.EndsWithFilenameFilter)1 EqualsFilenameFilter (com.mucommander.commons.file.filter.EqualsFilenameFilter)1 ExtensionFilenameFilter (com.mucommander.commons.file.filter.ExtensionFilenameFilter)1 FileFilter (com.mucommander.commons.file.filter.FileFilter)1 FilenameFilter (com.mucommander.commons.file.filter.FilenameFilter)1 PassThroughFileFilter (com.mucommander.commons.file.filter.PassThroughFileFilter)1