Skip to content

Commit 3ccfe7a

Browse files
fix: wrap call in Desktop api to check if Desktop is supposed on platform/OS, and wrapped open in check on support for file open action
1 parent b4e6bcf commit 3ccfe7a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AttachmentsPreviewController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,15 @@ public void changed(ObservableValue<? extends Attachment> observable, Attachment
129129
if(parts.length == 1 || !ApplicationService.getExtensionsHandledByExternalApp().contains(parts[parts.length - 1])){
130130
// If there is no app configured for the file type, then use the default configured for the OS/User
131131
try {
132-
Desktop.getDesktop().open(attachment.getFile());
133-
return;
132+
if(Desktop.isDesktopSupported()) {
133+
Desktop desktop = Desktop.getDesktop();
134+
if(desktop.isSupported(Desktop.Action.APP_OPEN_FILE)) {
135+
Desktop.getDesktop().open(attachment.getFile());
136+
return;
137+
}
138+
} else {
139+
ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null);
140+
}
134141
} catch (IOException e) {
135142
ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null);
136143
}

0 commit comments

Comments
 (0)