|
30 | 30 | import javafx.fxml.FXML; |
31 | 31 | import javafx.scene.Cursor; |
32 | 32 | import javafx.scene.control.*; |
| 33 | +import javafx.scene.control.MenuItem; |
33 | 34 | import javafx.scene.image.Image; |
34 | 35 | import javafx.scene.image.ImageView; |
35 | 36 | import javafx.scene.input.MouseEvent; |
|
42 | 43 | import org.phoebus.logbook.Attachment; |
43 | 44 | import org.phoebus.logbook.olog.ui.write.AttachmentsViewController; |
44 | 45 | import org.phoebus.ui.application.ApplicationLauncherService; |
| 46 | +import org.phoebus.ui.application.PhoebusApplication; |
45 | 47 | import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog; |
46 | 48 | import org.phoebus.ui.javafx.ImageCache; |
47 | 49 |
|
@@ -120,13 +122,19 @@ public void changed(ObservableValue<? extends Attachment> observable, Attachment |
120 | 122 | defaultApp.create(attachment.getFile().toURI()); |
121 | 123 | return; |
122 | 124 | } |
| 125 | + |
123 | 126 | // If not internal apps are found look for external apps |
124 | 127 | String fileName = attachment.getFile().getName(); |
125 | 128 | String[] parts = fileName.split("\\."); |
126 | 129 | if(parts.length == 1 || !ApplicationService.getExtensionsHandledByExternalApp().contains(parts[parts.length - 1])){ |
127 | | - // If there is no app configured for the file type, show an error message and return. |
128 | | - ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null); |
129 | | - return; |
| 130 | + // If there is no app configured for the file type, then use the default configured for the OS/User |
| 131 | + // Note: Do not use Desktop API, as using Java AWT can hang Phoebus / JavaFX Applications |
| 132 | + try { |
| 133 | + String filePathString = attachment.getFile().toPath().toUri().toString(); |
| 134 | + PhoebusApplication.INSTANCE.getHostServices().showDocument(filePathString); |
| 135 | + } catch (Exception e) { |
| 136 | + ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null); |
| 137 | + } |
130 | 138 | } |
131 | 139 | } |
132 | 140 | ApplicationLauncherService.openFile(attachment.getFile(), false, null); |
|
0 commit comments