Search in sources :

Example 1 with ProgressDialog

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));
    }
}
Also used : FileSet(com.mucommander.commons.file.util.FileSet) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) TempOpenWithJob(com.mucommander.job.impl.TempOpenWithJob)

Example 2 with ProgressDialog

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);
        }
    }
}
Also used : AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) AbstractFile(com.mucommander.commons.file.AbstractFile) TempExecJob(com.mucommander.job.impl.TempExecJob) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog)

Example 3 with ProgressDialog

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);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) CopyJob(com.mucommander.job.impl.CopyJob) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog)

Example 4 with ProgressDialog

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());
}
Also used : ArrayList(java.util.ArrayList) InformationPane(com.mucommander.ui.layout.InformationPane) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) URL(java.net.URL) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) VersionChecker(com.mucommander.VersionChecker) BorderLayout(java.awt.BorderLayout) DialogAction(com.mucommander.ui.dialog.DialogAction) SelfUpdateJob(com.mucommander.job.impl.SelfUpdateJob)

Example 5 with ProgressDialog

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;
}
Also used : DeleteJob(com.mucommander.job.impl.DeleteJob) FileSet(com.mucommander.commons.file.util.FileSet) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) MainFrame(com.mucommander.ui.main.MainFrame)

Aggregations

ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)10 AbstractFile (com.mucommander.commons.file.AbstractFile)5 FileSet (com.mucommander.commons.file.util.FileSet)5 IOException (java.io.IOException)5 MainFrame (com.mucommander.ui.main.MainFrame)4 TempExecJob (com.mucommander.job.impl.TempExecJob)3 CopyJob (com.mucommander.job.impl.CopyJob)2 DeleteJob (com.mucommander.job.impl.DeleteJob)2 TempOpenWithJob (com.mucommander.job.impl.TempOpenWithJob)2 VersionChecker (com.mucommander.VersionChecker)1 Command (com.mucommander.command.Command)1 FileURL (com.mucommander.commons.file.FileURL)1 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)1 LocalFile (com.mucommander.commons.file.protocol.local.LocalFile)1 MoveJob (com.mucommander.job.impl.MoveJob)1 SelfUpdateJob (com.mucommander.job.impl.SelfUpdateJob)1 DialogAction (com.mucommander.ui.dialog.DialogAction)1 InformationPane (com.mucommander.ui.layout.InformationPane)1 FileTableTabs (com.mucommander.ui.main.tabs.FileTableTabs)1 BorderLayout (java.awt.BorderLayout)1