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()));
}
}
}
Aggregations