Search in sources :

Example 1 with CopyJob

use of com.mucommander.job.impl.CopyJob in project mucommander by mucommander.

the class CopyDialog method createTransferFileJob.

// ////////////////////////////////////////////
// TransferDestinationDialog implementation //
// ////////////////////////////////////////////
@Override
protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, int defaultFileExistsAction) {
    AbstractFile baseFolder = files.getBaseFolder();
    AbstractArchiveFile parentArchiveFile = baseFolder.getParentArchive();
    TransferFileJob job;
    String newName = resolvedDest.getDestinationType() == DestinationType.EXISTING_FOLDER ? null : resolvedDest.getDestinationFile().getName();
    // their natural order (more efficient)
    if (parentArchiveFile != null) {
        // Add all selected archive entries to a vector
        int nbFiles = files.size();
        List<ArchiveEntry> selectedEntries = new Vector<ArchiveEntry>();
        for (int i = 0; i < nbFiles; i++) {
            selectedEntries.add((ArchiveEntry) files.elementAt(i).getAncestor(AbstractArchiveEntryFile.class).getUnderlyingFileObject());
        }
        job = new UnpackJob(progressDialog, mainFrame, parentArchiveFile, PathUtils.getDepth(baseFolder.getAbsolutePath(), baseFolder.getSeparator()) - PathUtils.getDepth(parentArchiveFile.getAbsolutePath(), parentArchiveFile.getSeparator()), resolvedDest.getDestinationFolder(), newName, defaultFileExistsAction, selectedEntries);
    } else {
        job = new CopyJob(progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), newName, TransferMode.COPY, defaultFileExistsAction);
    }
    return job;
}
Also used : AbstractArchiveFile(com.mucommander.commons.file.archive.AbstractArchiveFile) AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) TransferFileJob(com.mucommander.job.impl.TransferFileJob) AbstractFile(com.mucommander.commons.file.AbstractFile) UnpackJob(com.mucommander.job.impl.UnpackJob) CopyJob(com.mucommander.job.impl.CopyJob) ArchiveEntry(com.mucommander.commons.file.archive.ArchiveEntry) Vector(java.util.Vector)

Example 2 with CopyJob

use of com.mucommander.job.impl.CopyJob 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 3 with CopyJob

use of com.mucommander.job.impl.CopyJob in project mucommander by mucommander.

the class CopyDialog method createTransferFileJob.

// ////////////////////////////////////////////
// TransferDestinationDialog implementation //
// ////////////////////////////////////////////
@Override
protected TransferFileJob createTransferFileJob(ProgressDialog progressDialog, PathUtils.ResolvedDestination resolvedDest, FileCollisionDialog.FileCollisionAction defaultFileExistsAction) {
    AbstractFile baseFolder = files.getBaseFolder();
    AbstractArchiveFile parentArchiveFile = baseFolder.getParentArchive();
    TransferFileJob job;
    String newName = resolvedDest.getDestinationType() == DestinationType.EXISTING_FOLDER ? null : resolvedDest.getDestinationFile().getName();
    // their natural order (more efficient)
    if (parentArchiveFile != null) {
        // Add all selected archive entries to a vector
        int nbFiles = files.size();
        List<ArchiveEntry> selectedEntries = new Vector<ArchiveEntry>();
        for (int i = 0; i < nbFiles; i++) {
            selectedEntries.add((ArchiveEntry) files.elementAt(i).getAncestor(AbstractArchiveEntryFile.class).getUnderlyingFileObject());
        }
        job = new UnpackJob(progressDialog, mainFrame, parentArchiveFile, PathUtils.getDepth(baseFolder.getAbsolutePath(), baseFolder.getSeparator()) - PathUtils.getDepth(parentArchiveFile.getAbsolutePath(), parentArchiveFile.getSeparator()), resolvedDest.getDestinationFolder(), newName, defaultFileExistsAction, selectedEntries);
    } else {
        job = new CopyJob(progressDialog, mainFrame, files, resolvedDest.getDestinationFolder(), newName, TransferMode.COPY, defaultFileExistsAction);
    }
    return job;
}
Also used : AbstractArchiveFile(com.mucommander.commons.file.archive.AbstractArchiveFile) AbstractArchiveEntryFile(com.mucommander.commons.file.archive.AbstractArchiveEntryFile) TransferFileJob(com.mucommander.job.impl.TransferFileJob) AbstractFile(com.mucommander.commons.file.AbstractFile) UnpackJob(com.mucommander.job.impl.UnpackJob) CopyJob(com.mucommander.job.impl.CopyJob) ArchiveEntry(com.mucommander.commons.file.archive.ArchiveEntry) Vector(java.util.Vector)

Example 4 with CopyJob

use of com.mucommander.job.impl.CopyJob 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)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)4 CopyJob (com.mucommander.job.impl.CopyJob)4 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)2 AbstractArchiveFile (com.mucommander.commons.file.archive.AbstractArchiveFile)2 ArchiveEntry (com.mucommander.commons.file.archive.ArchiveEntry)2 FileSet (com.mucommander.commons.file.util.FileSet)2 TransferFileJob (com.mucommander.job.impl.TransferFileJob)2 UnpackJob (com.mucommander.job.impl.UnpackJob)2 ProgressDialog (com.mucommander.ui.dialog.file.ProgressDialog)2 Vector (java.util.Vector)2 MoveJob (com.mucommander.job.impl.MoveJob)1 MainFrame (com.mucommander.ui.main.MainFrame)1