Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing files when using the "Show Resulting File" button #60

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.kordamp.ikonli.javafx.FontIcon;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;

Expand Down Expand Up @@ -110,13 +111,23 @@ public class MultiButtonTableCell extends TableCell<BaseWorkflow, Void> {
showFile.setGraphic(openDirIcon);
showFile.setTooltip(new Tooltip("Open containing folder"));
showFile.setOnAction(evt -> {
File target = getTableRow().getItem().finalOutput;
if (!target.exists()) {
// If the user split the file we might need to show the parent directory instead.
target = target.getParentFile();
if (!target.exists()) {
// User probably nuked the entire directory
getTableRow().getItem().controller.updateStatus("Unable to locate output file");
return;
}
}
Desktop desktop = Desktop.getDesktop();
try {
desktop.browseFileDirectory(getTableRow().getItem().finalOutput);
desktop.browseFileDirectory(target);
} catch (UnsupportedOperationException e) {
// Some Windows versions don't support browse for some reason
// Some Windows versions don't support browsing to a specific file for some reason
try {
desktop.open(getTableRow().getItem().finalOutput.getParentFile());
desktop.open(target.getParentFile());
} catch (IOException ex) {
throw new RuntimeException(ex);
}
Expand Down
Loading