Search in sources :

Example 1 with DestinationType

use of com.mucommander.commons.file.util.DestinationType in project mucommander by mucommander.

the class MkdirDialog method startJob.

/**
 * Starts an {@link com.mucommander.job.impl.MkdirJob}. This method is trigged by the 'OK' button or the return key.
 */
public void startJob() {
    String enteredPath = pathField.getText();
    AbstractFile currentFolder = mainFrame.getActivePanel().getCurrentFolder();
    // Resolves destination folder
    PathUtils.ResolvedDestination resolvedDest = PathUtils.resolveDestination(enteredPath, currentFolder, currentFolder);
    // The path entered doesn't correspond to any existing folder
    if (resolvedDest == null) {
        InformationDialog.showErrorDialog(mainFrame, Translator.get("invalid_path", enteredPath));
        return;
    }
    // Checks if the directory already exists and reports the error if that's the case
    DestinationType destinationType = resolvedDest.getDestinationType();
    if (destinationType == DestinationType.EXISTING_FOLDER) {
        InformationDialog.showErrorDialog(mainFrame, Translator.get("directory_already_exists", enteredPath));
        return;
    }
    // Don't check for existing regular files, MkdirJob will take of it and popup a FileCollisionDialog
    AbstractFile destFile = resolvedDest.getDestinationFile();
    FileSet fileSet = new FileSet(destFile.getParent());
    // Job's FileSet needs to contain at least one file
    fileSet.add(destFile);
    ProgressDialog progressDialog = new ProgressDialog(mainFrame, getTitle());
    MkdirJob job;
    if (mkfileMode)
        job = new MkdirJob(progressDialog, mainFrame, fileSet, allocateSpaceCheckBox.isSelected() ? allocateSpaceChooser.getValue() : -1);
    else
        job = new MkdirJob(progressDialog, mainFrame, fileSet);
    progressDialog.start(job);
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) FileSet(com.mucommander.commons.file.util.FileSet) MkdirJob(com.mucommander.job.impl.MkdirJob) DestinationType(com.mucommander.commons.file.util.DestinationType) PathUtils(com.mucommander.commons.file.util.PathUtils)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)1 DestinationType (com.mucommander.commons.file.util.DestinationType)1 FileSet (com.mucommander.commons.file.util.FileSet)1 PathUtils (com.mucommander.commons.file.util.PathUtils)1 MkdirJob (com.mucommander.job.impl.MkdirJob)1