Skip to content

Commit c8e04e2

Browse files
authored
Merge pull request #2602 from agaget/master
Save-and-restore : Add snapshot name automatically after a "Take Snapshot"
2 parents 8bc8cd6 + b803e2b commit c8e04e2

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class Preferences {
3232
public static int search_result_page_size;
3333
@Preference
3434
public static String default_search_query;
35+
@Preference
36+
public static String default_snapshot_name_date_format;
3537

3638
static
3739
{

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@
6767
import org.phoebus.ui.dialog.DialogHelper;
6868
import org.phoebus.ui.dialog.ExceptionDetailsErrorDialog;
6969

70+
import java.text.SimpleDateFormat;
7071
import java.util.ArrayList;
7172
import java.util.Arrays;
73+
import java.util.Date;
7274
import java.util.HashMap;
7375
import java.util.LinkedHashMap;
7476
import java.util.List;
@@ -265,7 +267,7 @@ public void newSnapshot(Node configurationNode) {
265267
});
266268
});
267269
}
268-
270+
269271
@FXML
270272
@SuppressWarnings("unused")
271273
private void takeSnapshot() {
@@ -286,6 +288,12 @@ private void takeSnapshot() {
286288
snapshots.set(0, snapshot);
287289
List<TableEntry> tableEntries = createTableEntries(snapshots.get(0));
288290
snapshotTable.updateTable(tableEntries, snapshots, showLiveReadbackProperty.get(), false, showDeltaPercentage);
291+
292+
if (!Preferences.default_snapshot_name_date_format.equals("")) {
293+
SimpleDateFormat formater = new SimpleDateFormat(Preferences.default_snapshot_name_date_format);
294+
snapshotNameProperty.set(formater.format(new Date()));
295+
}
296+
289297
})
290298
);
291299
}

app/save-and-restore/app/src/main/resources/save_and_restore_preferences.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ search_result_page_size=30
2121

2222
# Default save-and-restore search query. Used unless a saved query is located.
2323
default_search_query=tags=golden
24+
25+
# If declared add a date automatically in the name of the snapshot "Take Snapshot"
26+
#default_snapshot_name_date_format=yyyy-MM-dd HH:mm:ss

0 commit comments

Comments
 (0)