use of com.mucommander.ui.dialog.file.ProgressDialog 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.ui.dialog.file.ProgressDialog in project mucommander by mucommander.
the class OpenNativelyAction method performAction.
@Override
public void performAction() {
AbstractFile selectedFile = mainFrame.getActiveTable().getSelectedFile(true, true);
if (selectedFile == null)
return;
// file is not on a local filesystem or file is an archive entry
if (!LocalFile.SCHEMA.equals(selectedFile.getURL().getScheme()) || selectedFile.hasAncestor(AbstractArchiveEntryFile.class)) {
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
TempExecJob job = new TempExecJob(progressDialog, mainFrame, selectedFile);
progressDialog.start(job);
} else {
// Tries to execute file with native file associations
try {
OpenAction.openFile(getMainFrame(), selectedFile);
RecentExecutedFilesQL.addFile(selectedFile);
} catch (IOException | UnsupportedOperationException e) {
InformationDialog.showErrorDialog(mainFrame);
}
}
}
use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.
the class PasteClipboardFilesAction method performAction.
@Override
public void performAction() {
// Retrieve clipboard files
FileSet clipboardFiles = ClipboardSupport.getClipboardFiles();
if (clipboardFiles == null || clipboardFiles.isEmpty())
return;
// Start copying files
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
AbstractFile destFolder = mainFrame.getActivePanel().getCurrentFolder();
CopyJob job = new CopyJob(progressDialog, mainFrame, clipboardFiles, destFolder, null, TransferMode.COPY, FileCollisionDialog.FileCollisionAction.ASK);
progressDialog.start(job);
}
use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.
the class CheckVersionDialog method run.
/**
* Checks for updates and notifies the user of the outcome.
*/
public void run() {
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
String message;
String title;
VersionChecker version;
URL downloadURL = null;
boolean downloadOption = false;
String jarURL = null;
try {
LOGGER.debug("Checking for new version...");
version = VersionChecker.getInstance();
// A newer version is available
if (version.isNewVersionAvailable()) {
LOGGER.info("A new version is available!");
title = Translator.get("version_dialog.new_version_title");
// Checks if the current platform can open a new browser window
downloadURL = new URL(version.getDownloadURL());
downloadOption = DesktopManager.isOperationSupported(DesktopManager.BROWSE, new Object[] { downloadURL });
// display the download URL.
if (downloadOption) {
message = Translator.get("version_dialog.new_version");
} else {
message = Translator.get("version_dialog.new_version_url", downloadURL.toString());
}
jarURL = version.getJarURL();
} else // We're already running latest version
{
LOGGER.debug("No new version.");
// we do not need to inform the user that he already has the latest version
if (!userInitiated) {
dispose();
return;
}
title = Translator.get("version_dialog.no_new_version_title");
message = Translator.get("version_dialog.no_new_version");
}
}// Check failed
catch (Exception e) {
// we do not need to inform the user that the check failed
if (!userInitiated) {
dispose();
return;
}
title = Translator.get("version_dialog.not_available_title");
message = Translator.get("version_dialog.not_available");
}
// Set title
setTitle(title);
List<DialogAction> actions = new ArrayList<>();
actions.add(CheckVersionAction.OK);
// 'Go to website' choice (if available)
if (downloadOption) {
actions.add(CheckVersionAction.GO_TO_WEBSITE);
}
// // 'Install and restart' choice (if available)
// if(jarURL!=null) {
// actionsV.add(new Integer(INSTALL_AND_RESTART_ACTION));
// labelsV.add(Translator.get("version_dialog.install_and_restart"));
// }
init(new InformationPane(message, null, Font.PLAIN, InformationPane.INFORMATION_ICON), actions, 0);
JCheckBox showNextTimeCheckBox = new JCheckBox(Translator.get("prefs_dialog.check_for_updates_on_startup"), MuConfigurations.getPreferences().getVariable(MuPreference.CHECK_FOR_UPDATE, MuPreferences.DEFAULT_CHECK_FOR_UPDATE));
addComponent(showNextTimeCheckBox);
setMinimumSize(MINIMUM_DIALOG_DIMENSION);
// Show dialog and get user action
DialogAction action = getActionValue();
if (action == CheckVersionAction.GO_TO_WEBSITE) {
try {
DesktopManager.executeOperation(DesktopManager.BROWSE, new Object[] { downloadURL });
} catch (Exception e) {
InformationDialog.showErrorDialog(this);
}
} else if (action == CheckVersionAction.INSTALL_AND_RESTART) {
ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("Installing new version"));
SelfUpdateJob job = new SelfUpdateJob(progressDialog, mainFrame, FileFactory.getFile(jarURL));
progressDialog.start(job);
}
// Remember user preference
MuConfigurations.getPreferences().setVariable(MuPreference.CHECK_FOR_UPDATE, showNextTimeCheckBox.isSelected());
}
use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.
the class XfceTrash 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;
}
Aggregations