Search in sources :

Example 1 with CalculateChecksumJob

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

the class CalculateChecksumDialog method actionPerformed.

// /////////////////////////////////
// ActionListener implementation //
// /////////////////////////////////
public void actionPerformed(ActionEvent e) {
    // Start by disposing this dialog
    dispose();
    if (e.getSource() == okButton) {
        try {
            MessageDigest digest = getSelectedMessageDigest();
            String algorithm = digest.getAlgorithm();
            AbstractFile checksumFile;
            if (specificLocationRadioButton.isSelected()) {
                // User-defined checksum file
                String enteredPath = specificLocationTextField.getText();
                PathUtils.ResolvedDestination resolvedDest = PathUtils.resolveDestination(enteredPath, mainFrame.getActivePanel().getCurrentFolder());
                // The path entered doesn't correspond to any existing folder
                if (resolvedDest == null) {
                    showErrorDialog(Translator.get("invalid_path", enteredPath));
                    return;
                }
                if (resolvedDest.getDestinationType() == DestinationType.EXISTING_FOLDER)
                    checksumFile = resolvedDest.getDestinationFile().getDirectChild(getChecksumFilename(algorithm));
                else
                    checksumFile = resolvedDest.getDestinationFile();
            } else {
                // Temporary file
                checksumFile = FileFactory.getTemporaryFile(getChecksumFilename(algorithm), true);
            }
            // Save the algorithm that was used for the next time this dialog is invoked
            lastUsedAlgorithm = algorithm;
            // Start processing files
            ProgressDialog progressDialog = new ProgressDialog(mainFrame, Translator.get("properties_dialog.calculating"));
            CalculateChecksumJob job = new CalculateChecksumJob(progressDialog, mainFrame, files, checksumFile, digest);
            progressDialog.start(job);
        } catch (IOException ex) {
            // Note: FileFactory.getTemporaryFile() should never throw an IOException
            showErrorDialog(Translator.get("invalid_path", specificLocationTextField.getText()));
        }
    }
}
Also used : AbstractFile(com.mucommander.commons.file.AbstractFile) CalculateChecksumJob(com.mucommander.job.impl.CalculateChecksumJob) IOException(java.io.IOException) MessageDigest(java.security.MessageDigest) PathUtils(com.mucommander.commons.file.util.PathUtils)

Aggregations

AbstractFile (com.mucommander.commons.file.AbstractFile)1 PathUtils (com.mucommander.commons.file.util.PathUtils)1 CalculateChecksumJob (com.mucommander.job.impl.CalculateChecksumJob)1 IOException (java.io.IOException)1 MessageDigest (java.security.MessageDigest)1