|
43 | 43 | import org.phoebus.logbook.Attachment; |
44 | 44 | import org.phoebus.logbook.olog.ui.write.AttachmentsViewController; |
45 | 45 | import org.phoebus.ui.application.ApplicationLauncherService; |
| 46 | +import org.phoebus.ui.application.PhoebusApplication; |
46 | 47 | import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog; |
47 | 48 | import org.phoebus.ui.javafx.ImageCache; |
48 | 49 |
|
49 | 50 | import javax.imageio.ImageIO; |
50 | | -import java.awt.*; |
51 | 51 | import java.awt.image.BufferedImage; |
52 | 52 | import java.io.File; |
53 | 53 | import java.io.IOException; |
@@ -128,14 +128,12 @@ public void changed(ObservableValue<? extends Attachment> observable, Attachment |
128 | 128 | String[] parts = fileName.split("\\."); |
129 | 129 | if(parts.length == 1 || !ApplicationService.getExtensionsHandledByExternalApp().contains(parts[parts.length - 1])){ |
130 | 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 |
131 | 132 | try { |
132 | | - if(Desktop.isDesktopSupported()) { |
133 | | - Desktop.getDesktop().open(attachment.getFile()); |
134 | | - return; |
135 | | - } else { |
136 | | - ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null); |
137 | | - } |
138 | | - } catch (IOException | UnsupportedOperationException e) { |
| 133 | + PhoebusApplication.INSTANCE.getHostServices().showDocument( |
| 134 | + attachment.getFile().toURI().getRawPath() |
| 135 | + ); |
| 136 | + } catch (Exception e) { |
139 | 137 | ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null); |
140 | 138 | } |
141 | 139 | } |
|
0 commit comments