Skip to content

Commit b4e6bcf

Browse files
refactor: delegate opening log attachments to desktop/user default instead of rendering error message
1 parent ab909e3 commit b4e6bcf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 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;
@@ -46,6 +47,7 @@
4647
import org.phoebus.ui.javafx.ImageCache;
4748

4849
import javax.imageio.ImageIO;
50+
import java.awt.*;
4951
import java.awt.image.BufferedImage;
5052
import java.io.File;
5153
import java.io.IOException;
@@ -120,13 +122,18 @@ 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+
try {
132+
Desktop.getDesktop().open(attachment.getFile());
133+
return;
134+
} catch (IOException e) {
135+
ExceptionDetailsErrorDialog.openError(Messages.PreviewOpenErrorTitle, Messages.PreviewOpenErrorBody, null);
136+
}
130137
}
131138
}
132139
ApplicationLauncherService.openFile(attachment.getFile(), false, null);

0 commit comments

Comments
 (0)