use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.
the class ActionKeymap method registerActionAccelerators.
/**
* Register primary and alternative accelerators to MuAction.
*/
private static void registerActionAccelerators(String actionId, KeyStroke accelerator, KeyStroke alternateAccelerator) {
// If accelerator is null, replace it with alternateAccelerator
if (accelerator == null) {
accelerator = alternateAccelerator;
alternateAccelerator = null;
}
// New accelerators are identical to the default action's accelerators
if (equals(accelerator, ActionProperties.getDefaultAccelerator(actionId)) && equals(alternateAccelerator, ActionProperties.getDefaultAlternativeAccelerator(actionId))) {
// Remove all action's accelerators customization
customPrimaryActionKeymap.remove(actionId);
customAlternateActionKeymap.remove(actionId);
acceleratorMap.remove(accelerator);
acceleratorMap.remove(alternateAccelerator);
} else // New accelerators are different from the default accelerators
{
customPrimaryActionKeymap.put(actionId, accelerator);
acceleratorMap.putAccelerator(accelerator, actionId);
customAlternateActionKeymap.put(actionId, alternateAccelerator);
acceleratorMap.putAlternativeAccelerator(alternateAccelerator, actionId);
}
// Update each MainFrame's action instance and input map
for (MuAction action : ActionManager.getActionInstances(actionId)) {
MainFrame mainFrame = action.getMainFrame();
// Remove action from MainFrame's action and input maps
unregisterAction(mainFrame, action);
// Change action's accelerators
action.setAccelerator(accelerator);
action.setAlternateAccelerator(alternateAccelerator);
// Add updated action to MainFrame's action and input maps
registerAction(mainFrame, action);
}
}
use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.
the class BringAllToFrontAction method performAction.
@Override
public void performAction() {
List<MainFrame> mainFrames = WindowManager.getMainFrames();
MainFrame currentMainFrame = WindowManager.getCurrentMainFrame();
int nbMainFrames = mainFrames.size();
MainFrame mainFrame;
for (int i = nbMainFrames - 1; i >= 0; i--) {
mainFrame = mainFrames.get(i);
if (mainFrame != currentMainFrame) {
mainFrame.toFront();
}
}
currentMainFrame.toFront();
}
use of com.mucommander.ui.main.MainFrame in project mucommander by mucommander.
the class GnomeTrash method empty.
/**
* Empty the trash
* <p>
* <b>Implementation notes:</b><br>
* Simply free the <code>TRASH_PATH</code> directory
* </p>
*
* @return True if everything went well
*/
@Override
public boolean empty() {
// Abort if there is no usable trash folder
if (TRASH_FOLDER == null)
return false;
FileSet filesToDelete = new FileSet(TRASH_FOLDER);
try {
// delete real files
filesToDelete.addAll(TRASH_FILES_SUBFOLDER.ls());
// delete spec files
filesToDelete.addAll(TRASH_INFO_SUBFOLDER.ls());
} catch (java.io.IOException ex) {
LOGGER.debug("Failed to list files", ex);
return false;
}
if (filesToDelete.size() > 0) {
// Starts deleting files
MainFrame mainFrame = WindowManager.getCurrentMainFrame();
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("delete_dialog.deleting"));
DeleteJob deleteJob = new DeleteJob(progressDialog, mainFrame, filesToDelete, false);
progressDialog.start(deleteJob);
}
return true;
}
use of com.mucommander.ui.main.MainFrame 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.MainFrame 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