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);
}
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());
}
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);
}
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);
}
}
}
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);
}
};
}
Aggregations