Skip to content

Commit fb7c3d4

Browse files
authored
Merge pull request #2350 from ControlSystemStudio/CSSTUDIO-1607
CSSTUDIO-1607: External viewer of attachments (movie clips, .pdf, office files)
2 parents 1dd1009 + 0a5ea22 commit fb7c3d4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import javafx.fxml.FXML;
3131
import javafx.scene.Cursor;
3232
import javafx.scene.control.*;
33+
import javafx.scene.control.MenuItem;
3334
import javafx.scene.image.Image;
3435
import javafx.scene.image.ImageView;
3536
import javafx.scene.input.MouseEvent;
@@ -42,6 +43,7 @@
4243
import org.phoebus.logbook.Attachment;
4344
import org.phoebus.logbook.olog.ui.write.AttachmentsViewController;
4445
import org.phoebus.ui.application.ApplicationLauncherService;
46+
import org.phoebus.ui.application.PhoebusApplication;
4547
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
4648
import org.phoebus.ui.javafx.ImageCache;
4749

@@ -120,13 +122,19 @@ public void changed(ObservableValue<? extends Attachment> observable, Attachment
120122
defaultApp.create(attachment.getFile().toURI());
121123
return;
122124
}
125+
123126
// If not internal apps are found look for external apps
124127
String fileName = attachment.getFile().getName();
125128
String[] parts = fileName.split("\\.");
126129
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+
}
130138
}
131139
}
132140
ApplicationLauncherService.openFile(attachment.getFile(), false, null);

0 commit comments

Comments
 (0)