Search in sources :

Example 6 with ProgressDialog

use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.

the class RecentExecutedFilesQL method acceptListItem.

@Override
protected void acceptListItem(AbstractFile item) {
    MainFrame mainFrame = WindowManager.getCurrentMainFrame();
    if (item.getURL().getScheme().equals(LocalFile.SCHEMA) && (item.hasAncestor(LocalFile.class))) {
        try {
            DesktopManager.open(item);
        } catch (IOException e) {
        }
    } else // Copies non-local file in a temporary local file and opens them using their native association.
    {
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
        TempExecJob job = new TempExecJob(progressDialog, mainFrame, item);
        progressDialog.start(job);
    }
}
Also used : TempExecJob(com.mucommander.job.impl.TempExecJob) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) MainFrame(com.mucommander.ui.main.MainFrame)

Example 7 with ProgressDialog

use of com.mucommander.ui.dialog.file.ProgressDialog 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);
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) Command(com.mucommander.command.Command) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) TempOpenWithJob(com.mucommander.job.impl.TempOpenWithJob)

Example 8 with ProgressDialog

use of com.mucommander.ui.dialog.file.ProgressDialog 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;
}
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)

Example 9 with ProgressDialog

use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.

the class FileDropTargetListener method drop.

public void drop(DropTargetDropEvent event) {
    // Restore default cursor, no matter what
    folderPanel.setCursor(Cursor.getDefaultCursor());
    // so this test is really necessary
    if (!dragAccepted) {
        event.rejectDrop();
        return;
    }
    // Accept drop event
    event.acceptDrop(currentDropAction);
    // Retrieve the files contained by the transferable as a FileSet (takes care of handling the different
    // DataFlavors)
    FileSet droppedFiles = TransferableFileSet.getTransferFiles(event.getTransferable());
    // Stop and report failure if no file could not be retrieved
    if (droppedFiles == null || droppedFiles.size() == 0) {
        // Report drop failure
        event.dropComplete(false);
        return;
    }
    // If more than one file is dropped, only the first one is used
    if (changeFolderOnlyMode || currentDropAction == DnDConstants.ACTION_LINK) {
        AbstractFile file = droppedFiles.elementAt(0);
        // If file is a directory, change current folder to that directory
        if (file.isDirectory())
            folderPanel.tryChangeCurrentFolder(file);
        else
            // For any other file kind (archive, regular file...), change directory to the file's parent folder
            // and select the file
            folderPanel.tryChangeCurrentFolder(file.getParent(), file, false);
        // Request focus on the FolderPanel
        folderPanel.requestFocus();
    } else // Normal mode: copy or move dropped files to the FolderPanel's current folder
    {
        MainFrame mainFrame = folderPanel.getMainFrame();
        AbstractFile destFolder = folderPanel.getCurrentFolder();
        if (currentDropAction == DnDConstants.ACTION_MOVE) {
            // Start moving files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("move_dialog.moving"));
            MoveJob moveJob = new MoveJob(progressDialog, mainFrame, droppedFiles, destFolder, null, FileCollisionDialog.FileCollisionAction.ASK, false);
            progressDialog.start(moveJob);
        } else {
            // Start copying files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
            CopyJob job = new CopyJob(progressDialog, mainFrame, droppedFiles, destFolder, null, TransferMode.COPY, FileCollisionDialog.FileCollisionAction.ASK);
            progressDialog.start(job);
        }
    }
    // Report that the drop event has been successfully handled
    event.dropComplete(true);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) CopyJob(com.mucommander.job.impl.CopyJob) MoveJob(com.mucommander.job.impl.MoveJob) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog) MainFrame(com.mucommander.ui.main.MainFrame)

Example 10 with ProgressDialog

use of com.mucommander.ui.dialog.file.ProgressDialog in project mucommander by mucommander.

the class OpenAction method open.

/**
 * Opens the specified file in the specified folder panel.
 * <p>
 * <code>file</code> will be opened using the following rules:
 * <ul>
 *   <li>
 *     If <code>file</code> is {@link com.mucommander.commons.file.AbstractFile#isBrowsable() browsable},
 *     it will be opened in <code>destination</code>.
 *   </li>
 *   <li>
 *     If <code>file</code> is local, it will be opened using its native associations.
 *   </li>
 *   <li>
 *     If <code>file</code> is remote, it will first be copied in a temporary local file and
 *     then opened using its native association.
 *   </li>
 * </ul>
 * </p>
 * @param file        file to open.
 * @param destination if <code>file</code> is browsable, folder panel in which to open the file.
 */
protected void open(AbstractFile file, FolderPanel destination) {
    AbstractFile resolvedFile;
    if (file.isSymlink()) {
        resolvedFile = resolveSymlink(file);
        if (resolvedFile == null) {
            InformationDialog.showErrorDialog(mainFrame, Translator.get("cannot_open_cyclic_symlink"));
            return;
        }
    } else
        resolvedFile = file;
    // Opens browsable files in the destination FolderPanel.
    if (resolvedFile.isBrowsable()) {
        resolvedFile = MuConfigurations.getPreferences().getVariable(MuPreference.CD_FOLLOWS_SYMLINKS, MuPreferences.DEFAULT_CD_FOLLOWS_SYMLINKS) ? resolvedFile : file;
        FileTableTabs tabs = destination.getTabs();
        if (BookmarkManager.isBookmark(resolvedFile.getURL())) {
            String bookmarkLocation = BookmarkManager.getBookmark(resolvedFile.getName()).getLocation();
            FileURL bookmarkURL;
            try {
                bookmarkURL = FileURL.getFileURL(bookmarkLocation);
            } catch (MalformedURLException e) {
                LOGGER.error("Failed to resolve bookmark's location: " + bookmarkLocation);
                return;
            }
            if (tabs.getCurrentTab().isLocked())
                tabs.add(bookmarkURL);
            else
                destination.tryChangeCurrentFolder(bookmarkURL);
        } else {
            if (tabs.getCurrentTab().isLocked())
                tabs.add(resolvedFile);
            else
                destination.tryChangeCurrentFolder(resolvedFile);
        }
    } else // Opens local files using their native associations.
    if (resolvedFile.getURL().getScheme().equals(LocalFile.SCHEMA) && (resolvedFile.hasAncestor(LocalFile.class))) {
        try {
            OpenAction.openFile(getMainFrame(), resolvedFile);
            RecentExecutedFilesQL.addFile(resolvedFile);
        } catch (IOException e) {
            InformationDialog.showErrorDialog(mainFrame);
        }
    } else // Copies non-local file in a temporary local file and opens them using their native association.
    {
        ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("copy_dialog.copying"));
        TempExecJob job = new TempExecJob(progressDialog, mainFrame, resolvedFile);
        progressDialog.start(job);
    }
}
Also used : FileTableTabs(com.mucommander.ui.main.tabs.FileTableTabs) FileURL(com.mucommander.commons.file.FileURL) MalformedURLException(java.net.MalformedURLException) LocalFile(com.mucommander.commons.file.protocol.local.LocalFile) AbstractFile(com.mucommander.commons.file.AbstractFile) TempExecJob(com.mucommander.job.impl.TempExecJob) IOException(java.io.IOException) ProgressDialog(com.mucommander.ui.dialog.file.ProgressDialog)

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