Skip to content

Commit 323b72e

Browse files
authored
Merge pull request #3161 from ControlSystemStudio/sar
SAR
2 parents 72b8cc9 + 8f7eace commit 323b72e

File tree

32 files changed

+362
-189
lines changed

32 files changed

+362
-189
lines changed

app/save-and-restore/app/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
<artifactId>save-and-restore-model</artifactId>
2222
<version>4.7.4-SNAPSHOT</version>
2323
</dependency>
24+
<dependency>
25+
<groupId>org.phoebus</groupId>
26+
<artifactId>save-and-restore-util</artifactId>
27+
<version>4.7.4-SNAPSHOT</version>
28+
<scope>compile</scope>
29+
</dependency>
2430
<dependency>
2531
<groupId>org.phoebus</groupId>
2632
<artifactId>app-display-model</artifactId>
@@ -76,6 +82,7 @@
7682
<scope>test</scope>
7783
</dependency>
7884

85+
7986
</dependencies>
8087
<build>
8188
<resources>

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/Messages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class Messages {
3636
public static String closeCompositeSnapshotWarning;
3737
public static String closeTabPrompt;
3838
public static String compositeSnapshotConsistencyCheckFailed;
39+
public static String contextMenuAddTag;
40+
@Deprecated
3941
public static String contextMenuAddTagWithComment;
4042
public static String contextMenuCreateSnapshot;
4143
public static String contextMenuCompareSnapshots;
@@ -52,6 +54,8 @@ public class Messages {
5254
public static String contextMenuRename;
5355
public static String contextMenuRemoveGoldenTag;
5456
public static String contextMenuTagAsGolden;
57+
public static String contextMenuTags;
58+
@Deprecated
5559
public static String contextMenuTagsWithComment;
5660
public static String contextMenuOpenCompositeSnapshotForRestore;
5761

@@ -129,6 +133,8 @@ public class Messages {
129133
public static String restore;
130134
public static String restoreFailed;
131135
public static String restoreFailedPVs;
136+
public static String restoreFromClient;
137+
public static String restoreFromService;
132138
public static String saveFilter;
133139

134140
public static String saveFilterConfirmOverwrite;

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/Preferences.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ public class Preferences {
5757
@Preference
5858
public static String default_snapshot_mode;
5959

60+
/**
61+
* Default restore mode
62+
*/
63+
@Preference
64+
public static String default_restore_mode;
65+
6066
static {
6167
AnnotatedPreferences.initialize(Preferences.class, "/save_and_restore_preferences.properties");
6268
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ContextMenuCompositeSnapshot extends ContextMenuBase {
3838
public ContextMenuCompositeSnapshot(SaveAndRestoreController saveAndRestoreController) {
3939
super(saveAndRestoreController);
4040

41-
Image snapshotTagsWithCommentIcon = ImageCache.getImage(SaveAndRestoreController.class, "/icons/save-and-restore/snapshot-tags.png");
41+
Image snapshotTagsIcon = ImageCache.getImage(SaveAndRestoreController.class, "/icons/save-and-restore/snapshot-tags.png");
4242

4343
MenuItem editCompositeSnapshotMenuItem = new MenuItem(Messages.Edit, new ImageView(ImageRepository.EDIT_CONFIGURATION));
4444
editCompositeSnapshotMenuItem.disableProperty().bind(multipleNodesSelectedProperty);
@@ -48,20 +48,20 @@ public ContextMenuCompositeSnapshot(SaveAndRestoreController saveAndRestoreContr
4848
userIsAuthenticatedProperty.not().get() || multipleNodesSelectedProperty.get(),
4949
userIsAuthenticatedProperty, multipleNodesSelectedProperty));
5050

51-
ImageView snapshotTagsWithCommentIconImage = new ImageView(snapshotTagsWithCommentIcon);
52-
snapshotTagsWithCommentIconImage.setFitHeight(22);
53-
snapshotTagsWithCommentIconImage.setFitWidth(22);
51+
ImageView snapshotTagsIconImage = new ImageView(snapshotTagsIcon);
52+
snapshotTagsIconImage.setFitHeight(22);
53+
snapshotTagsIconImage.setFitWidth(22);
5454

55-
Menu tagWithComment = new Menu(Messages.contextMenuTagsWithComment, snapshotTagsWithCommentIconImage);
56-
tagWithComment.setOnShowing(event -> saveAndRestoreController.tagWithComment(tagWithComment));
57-
tagWithComment.disableProperty().bind(Bindings.createBooleanBinding(() ->
55+
Menu tags = new Menu(Messages.contextMenuTags, snapshotTagsIconImage);
56+
tags.setOnShowing(event -> saveAndRestoreController.tag(tags));
57+
tags.disableProperty().bind(Bindings.createBooleanBinding(() ->
5858
multipleNodesSelectedProperty.get() || userIsAuthenticatedProperty.not().get(),
5959
multipleNodesSelectedProperty, userIsAuthenticatedProperty));
6060

61-
CustomMenuItem addTagWithCommentMenuItem = TagWidget.AddTagWithCommentMenuItem();
62-
addTagWithCommentMenuItem.setOnAction(action -> saveAndRestoreController.addTagToSnapshots());
61+
CustomMenuItem addTagMenuItem = TagWidget.AddTagMenuItem();
62+
addTagMenuItem.setOnAction(action -> saveAndRestoreController.addTagToSnapshots());
6363

64-
tagWithComment.getItems().addAll(addTagWithCommentMenuItem, new SeparatorMenuItem());
64+
tags.getItems().addAll(addTagMenuItem, new SeparatorMenuItem());
6565

6666
Image copyIcon = ImageCache.getImage(SaveAndRestoreController.class, "/icons/copy.png");
6767
MenuItem copyMenuItem = new MenuItem(Messages.copy, new ImageView(copyIcon));
@@ -76,7 +76,7 @@ public ContextMenuCompositeSnapshot(SaveAndRestoreController saveAndRestoreContr
7676
copyMenuItem,
7777
deleteNodesMenuItem,
7878
copyUniqueIdToClipboardMenuItem,
79-
tagWithComment);
79+
tags);
8080
}
8181

8282
/**

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class ContextMenuSnapshot extends ContextMenuBase {
4040

4141
private final MenuItem tagGoldenMenuItem;
4242

43-
private final Menu tagWithComment;
43+
private final Menu tags;
4444

4545
private final SimpleBooleanProperty mayTagProperty = new SimpleBooleanProperty();
4646

@@ -55,21 +55,21 @@ public ContextMenuSnapshot(SaveAndRestoreController saveAndRestoreController) {
5555
compareSnapshotsMenuItem.setOnAction(ae -> saveAndRestoreController.compareSnapshot());
5656
compareSnapshotsMenuItem.disableProperty().bind(mayCompareSnapshotsProperty.not());
5757

58-
ImageView snapshotTagsWithCommentIconImage = new ImageView(ImageRepository.SNAPSHOT_ADD_TAG_WITH_COMMENT);
58+
ImageView snapshotTagsIconImage = new ImageView(ImageRepository.SNAPSHOT_ADD_TAG);
5959

60-
tagWithComment = new Menu(Messages.contextMenuTagsWithComment, snapshotTagsWithCommentIconImage);
61-
tagWithComment.setOnShowing(event -> saveAndRestoreController.tagWithComment(tagWithComment));
62-
tagWithComment.disableProperty().bind(Bindings.createBooleanBinding(() ->
60+
tags = new Menu(Messages.contextMenuTags, snapshotTagsIconImage);
61+
tags.setOnShowing(event -> saveAndRestoreController.tag(tags));
62+
tags.disableProperty().bind(Bindings.createBooleanBinding(() ->
6363
multipleNodesSelectedProperty.get() || userIsAuthenticatedProperty.not().get(),
6464
multipleNodesSelectedProperty, userIsAuthenticatedProperty));
6565

66-
MenuItem addTagWithCommentMenuItem = TagWidget.AddTagWithCommentMenuItem();
67-
addTagWithCommentMenuItem.setOnAction(action -> saveAndRestoreController.addTagToSnapshots());
68-
addTagWithCommentMenuItem.disableProperty().bind(Bindings.createBooleanBinding(() ->
66+
MenuItem addTagMenuItem = TagWidget.AddTagMenuItem();
67+
addTagMenuItem.setOnAction(action -> saveAndRestoreController.addTagToSnapshots());
68+
addTagMenuItem.disableProperty().bind(Bindings.createBooleanBinding(() ->
6969
multipleNodesSelectedProperty.get() || mayTagProperty.not().get(),
7070
multipleNodesSelectedProperty, mayTagProperty));
7171

72-
tagWithComment.getItems().addAll(addTagWithCommentMenuItem);
72+
tags.getItems().addAll(addTagMenuItem);
7373

7474
MenuItem findReferencesMenuItem = new MenuItem(Messages.findSnapshotReferences, new ImageView(ImageRepository.COMPOSITE_SNAPSHOT));
7575
findReferencesMenuItem.setOnAction(ae -> saveAndRestoreController.findSnapshotReferences());
@@ -97,7 +97,7 @@ public ContextMenuSnapshot(SaveAndRestoreController saveAndRestoreController) {
9797
deleteNodesMenuItem,
9898
compareSnapshotsMenuItem,
9999
tagGoldenMenuItem,
100-
tagWithComment,
100+
tags,
101101
copyMenuItem,
102102
copyUniqueIdToClipboardMenuItem,
103103
exportSnapshotMenuItem);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class ImageRepository {
4343
public static final Image EDIT_CONFIGURATION =
4444
ImageCache.getImage(ImageRepository.class, "/icons/save-and-restore/edit-configuration.png");
4545

46-
public static final Image SNAPSHOT_ADD_TAG_WITH_COMMENT =
46+
public static final Image SNAPSHOT_ADD_TAG =
4747
ImageCache.getImage(ImageRepository.class, "/icons/save-and-restore/snapshot-add_tag.png");
4848

4949
public static final Image DELETE = ImageCache.getImage(SaveAndRestoreController.class, "/icons/delete.png");
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (C) 2024 European Spallation Source ERIC.
3+
*/
4+
5+
package org.phoebus.applications.saveandrestore.ui;
6+
7+
import org.phoebus.applications.saveandrestore.Messages;
8+
9+
public enum RestoreMode {
10+
11+
/**
12+
* Classic mode: read data from IOC
13+
*/
14+
CLIENT_RESTORE(Messages.restoreFromClient),
15+
16+
/**
17+
* Read PV data from archiver
18+
*/
19+
SERVICE_RESTORE(Messages.restoreFromService);
20+
21+
private final String name;
22+
23+
RestoreMode(final String name) {
24+
this.name = name;
25+
}
26+
27+
@Override
28+
public String toString(){
29+
return name;
30+
}
31+
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,17 +1026,17 @@ protected void addTagToSnapshots() {
10261026
}
10271027

10281028
/**
1029-
* Configures the "tag with comment" sub-menu. Items are added based on existing {@link Tag}s on the
1029+
* Configures the "tag" sub-menu. Items are added based on existing {@link Tag}s on the
10301030
* selected {@link Node}s
10311031
*
1032-
* @param tagWithCommentMenu The {@link Menu} subject to configuration.
1032+
* @param tagMenu The {@link Menu} subject to configuration.
10331033
*/
1034-
public void tagWithComment(final Menu tagWithCommentMenu) {
1034+
public void tag(final Menu tagMenu) {
10351035

10361036
List<Node> selectedNodes =
10371037
browserSelectionModel.getSelectedItems().stream().map(TreeItem::getValue).collect(Collectors.toList());
10381038

1039-
TagUtil.tagWithComment(tagWithCommentMenu, selectedNodes, updatedNodes -> updatedNodes.forEach(this::nodeChanged));
1039+
TagUtil.tag(tagMenu, selectedNodes, updatedNodes -> updatedNodes.forEach(this::nodeChanged));
10401040
}
10411041

10421042
/**

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/search/SearchAndFilterViewController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,20 @@ protected void updateItem(Node node, boolean empty) {
417417
ContextMenu contextMenu = new ContextMenu();
418418
MenuItem tagGoldenMenuItem = new MenuItem(Messages.contextMenuTagAsGolden, new ImageView(ImageRepository.SNAPSHOT));
419419

420-
ImageView snapshotTagsWithCommentIconImage = new ImageView(ImageRepository.SNAPSHOT_ADD_TAG_WITH_COMMENT);
421-
Menu tagMenuItem = new Menu(Messages.contextMenuTagsWithComment, snapshotTagsWithCommentIconImage);
420+
ImageView snapshotTagsIconImage = new ImageView(ImageRepository.SNAPSHOT_ADD_TAG);
421+
Menu tagMenuItem = new Menu(Messages.contextMenuTags, snapshotTagsIconImage);
422422

423-
MenuItem addTagWithCommentMenuItem = TagWidget.AddTagWithCommentMenuItem();
424-
addTagWithCommentMenuItem.setOnAction(event -> TagUtil.addTag(resultTableView.getSelectionModel().getSelectedItems()));
425-
tagMenuItem.getItems().add(addTagWithCommentMenuItem);
423+
MenuItem addTagMenuItem = TagWidget.AddTagMenuItem();
424+
addTagMenuItem.setOnAction(event -> TagUtil.addTag(resultTableView.getSelectionModel().getSelectedItems()));
425+
tagMenuItem.getItems().add(addTagMenuItem);
426426

427427
MenuItem restoreMenuItem = new MenuItem(Messages.restore);
428428
restoreMenuItem.setOnAction(e -> doRestore(resultTableView.getSelectionModel().getSelectedItem().getUniqueId()));
429429

430430
contextMenu.setOnShowing(event -> {
431431
NodeType selectedItemType = resultTableView.getSelectionModel().getSelectedItem().getNodeType();
432432
if (selectedItemType.equals(NodeType.SNAPSHOT)) {
433-
TagUtil.tagWithComment(tagMenuItem,
433+
TagUtil.tag(tagMenuItem,
434434
resultTableView.getSelectionModel().getSelectedItems(),
435435
updatedNodes -> { // Callback, any extra handling added here
436436
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public void loadSnapshot(Node snapshotNode) {
359359
}
360360

361361
public void restore(ActionEvent actionEvent) {
362-
snapshotTableViewController.restore(snapshotProperty.get(), restoreResultList -> {
362+
snapshotTableViewController.restoreSnapshot(snapshotControlsViewController.getRestoreMode(), snapshotProperty.get(), restoreResultList -> {
363363
if (snapshotControlsViewController.logAction()) {
364364
eventReceivers.forEach(r -> r.snapshotRestored(snapshotProperty.get().getSnapshotNode(), restoreResultList, this::showLoggingError));
365365
}

0 commit comments

Comments
 (0)