Skip to content

Commit 8854527

Browse files
authored
Merge pull request #3595 from High-Voltage-Engineering/dh-sar-snapshot-ui-behavior
improve SaR snapshot UI behavior
2 parents 50cba81 + 66880c2 commit 8854527

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,18 @@ public void takeSnapshot() {
758758
*/
759759
private void resetMetaData() {
760760
tabTitleProperty.setValue(Messages.unnamedSnapshot);
761-
snapshotNameProperty.setValue(null);
762-
snapshotCommentProperty.setValue(null);
763761
createdDateTextProperty.setValue(null);
764762
lastModifiedDateTextProperty.setValue(null);
765763
createdByTextProperty.setValue(null);
766764
}
767765

766+
public static Throwable getRootCause(Throwable throwable) {
767+
if (throwable.getCause() != null)
768+
return getRootCause(throwable.getCause());
769+
770+
return throwable;
771+
}
772+
768773
@SuppressWarnings("unused")
769774
public void saveSnapshot(ActionEvent actionEvent) {
770775
disabledUi.set(true);
@@ -796,7 +801,8 @@ public void saveSnapshot(ActionEvent actionEvent) {
796801
Platform.runLater(() -> {
797802
Alert alert = new Alert(Alert.AlertType.ERROR);
798803
alert.setTitle(Messages.errorActionFailed);
799-
alert.setContentText(e.getMessage());
804+
// get root cause of exception because the nested exception names are not very friendly
805+
alert.setContentText(getRootCause(e).getMessage());
800806
alert.setHeaderText(Messages.saveSnapshotErrorContent);
801807
DialogHelper.positionDialog(alert, borderPane, -150, -150);
802808
alert.showAndWait();
@@ -1102,7 +1108,14 @@ private void takeSnapshotReadPVs(Consumer<Optional<Snapshot>> consumer) {
11021108
});
11031109
showTakeSnapshotResult(snapshotItems);
11041110
Snapshot snapshot = new Snapshot();
1105-
snapshot.setSnapshotNode(Node.builder().nodeType(NodeType.SNAPSHOT).build());
1111+
snapshot.setSnapshotNode(
1112+
Node.builder()
1113+
.nodeType(NodeType.SNAPSHOT)
1114+
// set name and description to preserve the name / comment fields
1115+
.name(snapshotNameProperty.getValue())
1116+
.description(snapshotCommentProperty.getValue())
1117+
.build()
1118+
);
11061119
SnapshotData snapshotData = new SnapshotData();
11071120
snapshotData.setSnapshotItems(snapshotItems);
11081121
snapshot.setSnapshotData(snapshotData);

0 commit comments

Comments
 (0)