Search in sources :

Example 1 with FolderPanel

use of com.mucommander.ui.main.FolderPanel in project mucommander by mucommander.

the class FocusNextAction method performAction.

@Override
public void performAction() {
    Component focusOwner = mainFrame.getFocusOwner();
    // Abort if the focus is not in the MainFrame this action is tied to
    if (focusOwner == null)
        return;
    FolderPanel folderPanel = mainFrame.getActivePanel();
    FileTable fileTable = folderPanel.getFileTable();
    JTextField locationField = folderPanel.getLocationTextField();
    JTree tree = folderPanel.getFoldersTreePanel().getTree();
    // Request focus on the 'next' component, the cycle order being from left to right, top to bottom.
    Component nextComponent;
    if (focusOwner == locationField)
        nextComponent = folderPanel.isTreeVisible() ? tree : fileTable;
    else if (focusOwner == tree)
        nextComponent = fileTable;
    else if (focusOwner == fileTable)
        nextComponent = locationField;
    else
        return;
    FocusRequester.requestFocusInWindow(nextComponent);
}
Also used : JTree(javax.swing.JTree) FileTable(com.mucommander.ui.main.table.FileTable) Component(java.awt.Component) JTextField(javax.swing.JTextField) FolderPanel(com.mucommander.ui.main.FolderPanel)

Example 2 with FolderPanel

use of com.mucommander.ui.main.FolderPanel in project mucommander by mucommander.

the class ToggleTreeAction method performAction.

@Override
public void performAction() {
    FolderPanel folderPanel = mainFrame.getActiveTable().getFolderPanel();
    folderPanel.setTreeVisible(!folderPanel.isTreeVisible());
}
Also used : FolderPanel(com.mucommander.ui.main.FolderPanel)

Example 3 with FolderPanel

use of com.mucommander.ui.main.FolderPanel in project mucommander by mucommander.

the class FocusPreviousAction method performAction.

@Override
public void performAction() {
    Component focusOwner = mainFrame.getFocusOwner();
    // Abort if the focus is not in the MainFrame this action is tied to
    if (focusOwner == null)
        return;
    FolderPanel folderPanel = mainFrame.getActivePanel();
    FileTable fileTable = folderPanel.getFileTable();
    JTextField locationField = folderPanel.getLocationTextField();
    JTree tree = folderPanel.getFoldersTreePanel().getTree();
    // Request focus on the 'previous' component, the cycle order being from right to left, bottom to top.
    Component previousComponent;
    if (focusOwner == fileTable)
        previousComponent = folderPanel.isTreeVisible() ? tree : locationField;
    else if (focusOwner == tree)
        previousComponent = locationField;
    else if (focusOwner == locationField)
        previousComponent = fileTable;
    else
        return;
    FocusRequester.requestFocusInWindow(previousComponent);
}
Also used : JTree(javax.swing.JTree) FileTable(com.mucommander.ui.main.table.FileTable) Component(java.awt.Component) JTextField(javax.swing.JTextField) FolderPanel(com.mucommander.ui.main.FolderPanel)

Example 4 with FolderPanel

use of com.mucommander.ui.main.FolderPanel 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 5 with FolderPanel

use of com.mucommander.ui.main.FolderPanel in project mucommander by mucommander.

the class Activator method createCoreService.

private CoreService createCoreService() {
    return new CoreService() {

        @Override
        public void showAbout() {
            MainFrame mainFrame = WindowManager.getCurrentMainFrame();
            // Do nothing (return) when in 'no events mode'
            if (mainFrame.getNoEventsMode())
                return;
            new AboutDialog(mainFrame).showDialog();
        }

        @Override
        public void showPreferences() {
            MainFrame mainFrame = WindowManager.getCurrentMainFrame();
            // Do nothing (return) when in 'no events mode'
            if (mainFrame.getNoEventsMode())
                return;
            ActionManager.performAction(com.mucommander.ui.action.impl.ShowPreferencesAction.Descriptor.ACTION_ID, mainFrame);
        }

        @Override
        public boolean doQuit() {
            // Ask the user for confirmation and abort if user refused to quit.
            if (!QuitDialog.confirmQuit())
                return false;
            // We got a green -> quit!
            Application.initiateShutdown();
            return true;
        }

        @Override
        public void openFile(String path) {
            // Wait until the application has been launched. This step is required to properly handle the case where the
            // application is launched with a file to open, for instance when drag-n-dropping a file to the Dock icon
            // when muCommander is not started yet. In this case, this method is called while Launcher is still busy
            // launching the application (no mainframe exists yet).
            Application.waitUntilLaunched();
            AbstractFile file = FileFactory.getFile(path);
            FolderPanel activePanel = WindowManager.getCurrentMainFrame().getActivePanel();
            if (file.isBrowsable())
                activePanel.tryChangeCurrentFolder(file);
            else
                activePanel.tryChangeCurrentFolder(file.getParent(), file, false);
        }
    };
}
Also used : AboutDialog(com.mucommander.ui.dialog.about.AboutDialog) AbstractFile(com.mucommander.commons.file.AbstractFile) CoreService(com.mucommander.os.api.CoreService) MainFrame(com.mucommander.ui.main.MainFrame) FolderPanel(com.mucommander.ui.main.FolderPanel)

Aggregations

FolderPanel (com.mucommander.ui.main.FolderPanel)8 AbstractFile (com.mucommander.commons.file.AbstractFile)5 FileTable (com.mucommander.ui.main.table.FileTable)3 MainFrame (com.mucommander.ui.main.MainFrame)2 Component (java.awt.Component)2 JTextField (javax.swing.JTextField)2 JTree (javax.swing.JTree)2 FileSet (com.mucommander.commons.file.util.FileSet)1 CoreService (com.mucommander.os.api.CoreService)1 AboutDialog (com.mucommander.ui.dialog.about.AboutDialog)1 LocalCopyDialog (com.mucommander.ui.dialog.file.LocalCopyDialog)1 IOException (java.io.IOException)1 Random (java.util.Random)1