Search in sources :

Example 1 with TransferFileJob

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

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

the class TransferDestinationDialog method startJob.

/**
 * This method is called after the destination has been validated to start the job, with the resolved destination
 * that has been validated by {@link #isValidDestination(PathUtils.ResolvedDestination, String)}.
 *
 * @param resolvedDest the resolved destination
 */
private void startJob(PathUtils.ResolvedDestination resolvedDest) {
    FileCollisionDialog.FileCollisionAction defaultFileExistsAction = ASK;
    boolean skipErrors = false;
    boolean verifyIntegrity = false;
    boolean runInBackground = runInBackgroundCheckBox.isSelected();
    if (enableTransferOptions) {
        // Retrieve default action when a file exists in destination, default choice
        // (if not specified by the user) is 'Ask'
        defaultFileExistsAction = (FileCollisionDialog.FileCollisionAction) fileExistsActionComboBox.getSelectedItem();
        if (defaultFileExistsAction == DIALOG_DISPOSED_ACTION)
            defaultFileExistsAction = ASK;
        // Note: we don't remember default action on purpose: we want the user to specify it each time,
        // it would be too dangerous otherwise.
        skipErrors = skipErrorsCheckBox.isSelected();
        verifyIntegrity = verifyIntegrityCheckBox.isSelected();
    }
    ProgressDialog progressDialog = new ProgressDialog(mainFrame, getProgressDialogTitle());
    TransferFileJob job = createTransferFileJob(progressDialog, resolvedDest, defaultFileExistsAction);
    if (job != null) {
        job.setAutoSkipErrors(skipErrors);
        job.setIntegrityCheckEnabled(verifyIntegrity);
        job.setRunInBackground(runInBackground);
        progressDialog.start(job);
    }
}
Also used : TransferFileJob(com.mucommander.job.impl.TransferFileJob)

Example 3 with TransferFileJob

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

Aggregations

TransferFileJob (com.mucommander.job.impl.TransferFileJob)3 AbstractFile (com.mucommander.commons.file.AbstractFile)2 AbstractArchiveEntryFile (com.mucommander.commons.file.archive.AbstractArchiveEntryFile)2 AbstractArchiveFile (com.mucommander.commons.file.archive.AbstractArchiveFile)2 ArchiveEntry (com.mucommander.commons.file.archive.ArchiveEntry)2 CopyJob (com.mucommander.job.impl.CopyJob)2 UnpackJob (com.mucommander.job.impl.UnpackJob)2 Vector (java.util.Vector)2