use of com.mucommander.job.impl.TempOpenWithJob in project mucommander by mucommander.
the class CommandAction method performAction.
// - Action code -----------------------------------------------------------
// -------------------------------------------------------------------------
@Override
public void performAction() {
FileSet selectedFiles;
// Retrieves the current selection.
selectedFiles = mainFrame.getActiveTable().getSelectedFiles();
// If no files are either selected or marked, aborts.
if (command.hasSelectedFileKeyword() && selectedFiles.size() == 0)
return;
// If we're working with local files, go ahead and runs the command.
if (selectedFiles.getBaseFolder().getURL().getScheme().equals(LocalFile.SCHEMA) && (selectedFiles.getBaseFolder().hasAncestor(LocalFile.class))) {
try {
InformationDialog.showErrorDialogIfNeeded(getMainFrame(), ProcessRunner.executeAsync(command.getTokens(selectedFiles), selectedFiles.getBaseFolder()));
} catch (Exception e) {
InformationDialog.showErrorDialog(mainFrame);
LOGGER.debug("Failed to execute command: " + command.getCommand(), e);
}
} else // Otherwise, copies the files locally before running the command.
{
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
progressDialog.start(new TempOpenWithJob(new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying")), mainFrame, selectedFiles, command));
}
}
use of com.mucommander.job.impl.TempOpenWithJob in project mucommander by mucommander.
the class AbstractViewerAction method performAction.
// - AbstractAction implementation ---------------------------------------------------
// -----------------------------------------------------------------------------------
/**
* Edits the currently selected file.
*/
@Override
public synchronized void performAction() {
AbstractFile file;
Command customCommand;
file = mainFrame.getActiveTable().getSelectedFile(false, true);
// viewer/editor implementations will decide whether they allow a particular file or not.
if (file != null) {
customCommand = getCustomCommand();
// If we're using a custom command...
if (customCommand != null) {
// If it's local, run the custom editor on it.
if (file.hasAncestor(LocalFile.class)) {
try {
InformationDialog.showErrorDialogIfNeeded(getMainFrame(), ProcessRunner.executeAsync(customCommand.getTokens(file), file));
} catch (Exception e) {
InformationDialog.showErrorDialog(mainFrame);
}
} else // If it's distant, copies it locally before running the custom editor on it.
{
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
TempOpenWithJob job = new TempOpenWithJob(progressDialog, mainFrame, file, customCommand);
progressDialog.start(job);
}
} else
// If we're not using a custom editor, this action behaves exactly like its parent.
performInternalAction(file);
}
}
Aggregations