5151import javafx .scene .text .Text ;
5252import javafx .util .converter .DoubleStringConverter ;
5353import org .epics .vtype .Alarm ;
54+ import org .epics .vtype .AlarmSeverity ;
5455import org .epics .vtype .Display ;
5556import org .epics .vtype .Time ;
5657import org .epics .vtype .VEnum ;
@@ -271,6 +272,12 @@ public class SnapshotController extends SaveAndRestoreBaseController implements
271272 @ FXML
272273 protected TableColumn <TableEntry , ?> baseSnapshotColumn ;
273274
275+ @ FXML
276+ private TableColumn <TableEntry , AlarmSeverity > storedSeverityColumn ;
277+
278+ @ FXML
279+ private TableColumn <TableEntry , AlarmSeverity > liveSeverityColumn ;
280+
274281 @ FXML
275282 protected TooltipTableColumn <VType > baseSnapshotValueColumn ;
276283
@@ -357,7 +364,6 @@ public SnapshotController(SnapshotTab snapshotTab) {
357364 }
358365
359366
360-
361367 @ FXML
362368 public void initialize () {
363369
@@ -396,7 +402,7 @@ public void initialize() {
396402
397403 saveSnapshotButton .disableProperty ().bind (Bindings .createBooleanBinding (() ->
398404 // TODO: support save (=update) a composite snapshot from the snapshot view. In the meanwhile, disable save button.
399- snapshotDataDirty .not ().get () ||
405+ snapshotDataDirty .not ().get () ||
400406 snapshotNameProperty .isEmpty ().get () ||
401407 snapshotCommentProperty .isEmpty ().get () ||
402408 userIdentity .isNull ().get (),
@@ -468,7 +474,7 @@ public void initialize() {
468474
469475 showLiveReadbackButton .setGraphic (new ImageView (new Image (getClass ().getResourceAsStream ("/icons/show_live_readback_column.png" ))));
470476 showLiveReadbackButton .selectedProperty ()
471- .addListener ((a , o , n ) ->{
477+ .addListener ((a , o , n ) -> {
472478 this .showReadbacks .set (n );
473479 actionResultReadbackColumn .visibleProperty ().setValue (actionResultReadbackColumn .getGraphic () != null );
474480 });
@@ -668,6 +674,9 @@ protected void updateItem(TableEntry item, boolean empty) {
668674 storedReadbackColumn .setCellFactory (e -> new VTypeCellEditor <>());
669675 readbackColumn .visibleProperty ().bind (showReadbacks );
670676
677+ liveSeverityColumn .setCellFactory (a -> new AlarmSeverityCell ());
678+ storedSeverityColumn .setCellFactory (a -> new AlarmSeverityCell ());
679+
671680 timeColumn .visibleProperty ().bind (compareViewEnabled .not ());
672681 firstDividerColumn .visibleProperty ().bind (compareViewEnabled );
673682 statusColumn .visibleProperty ().bind (compareViewEnabled .not ());
@@ -763,7 +772,7 @@ public void takeSnapshot() {
763772 * Restores snapshot meta-data properties to indicate that the UI
764773 * is not showing persisted {@link Snapshot} data.
765774 */
766- private void resetMetaData (){
775+ private void resetMetaData () {
767776 tabTitleProperty .setValue (Messages .unnamedSnapshot );
768777 snapshotNameProperty .setValue (null );
769778 snapshotCommentProperty .setValue (null );
@@ -1141,7 +1150,7 @@ private void showTakeSnapshotResult(List<SnapshotItem> snapshotItems) {
11411150 break ;
11421151 }
11431152 }
1144- for (SnapshotItem snapshotItem : snapshotItems ){
1153+ for (SnapshotItem snapshotItem : snapshotItems ) {
11451154 if (snapshotItem .getConfigPv ().getReadbackPvName () != null && snapshotItem .getReadbackValue () != null &&
11461155 snapshotItem .getReadbackValue ().equals (VDisconnectedData .INSTANCE )) {
11471156 disconnectedReadbackPvEncountered .set (true );
@@ -1155,7 +1164,7 @@ private void showTakeSnapshotResult(List<SnapshotItem> snapshotItems) {
11551164 if (!disconnectedPvEncountered .get ()) {
11561165 actionResultColumn .setGraphic (new ImageView (ImageCache .getImage (SnapshotController .class , "/icons/ok.png" )));
11571166 }
1158- if (!disconnectedReadbackPvEncountered .get ()){
1167+ if (!disconnectedReadbackPvEncountered .get ()) {
11591168 actionResultReadbackColumn .setGraphic (new ImageView (ImageCache .getImage (SnapshotController .class , "/icons/ok.png" )));
11601169 }
11611170 });
@@ -1329,8 +1338,7 @@ private void showRestoreResult(List<RestoreResult> restoreResultList) {
13291338 Platform .runLater (() -> {
13301339 if (!disconnectedPvEncountered .get ()) {
13311340 actionResultColumn .setGraphic (new ImageView (ImageCache .getImage (SnapshotController .class , "/icons/ok.png" )));
1332- }
1333- else {
1341+ } else {
13341342 actionResultColumn .setGraphic (new ImageView (ImageCache .getImage (SnapshotController .class , "/icons/error.png" )));
13351343 }
13361344 });
@@ -1508,15 +1516,13 @@ private void showSnapshotInTable() {
15081516 tableEntry .setStoredReadbackValue (entry .getReadbackValue (), 0 );
15091517 if (entry .getValue () == null || entry .getValue ().equals (VDisconnectedData .INSTANCE )) {
15101518 tableEntry .setActionResult (ActionResult .FAILED );
1511- }
1512- else {
1519+ } else {
15131520 tableEntry .setActionResult (ActionResult .OK );
15141521 }
1515- if (entry .getConfigPv ().getReadbackPvName () != null ){
1516- if (entry .getReadbackValue () == null || entry .getReadbackValue ().equals (VDisconnectedData .INSTANCE )) {
1522+ if (entry .getConfigPv ().getReadbackPvName () != null ) {
1523+ if (entry .getReadbackValue () == null || entry .getReadbackValue ().equals (VDisconnectedData .INSTANCE )) {
15171524 tableEntry .setActionResultReadback (ActionResult .FAILED );
1518- }
1519- else {
1525+ } else {
15201526 tableEntry .setActionResultReadback (ActionResult .OK );
15211527 }
15221528 }
@@ -1590,22 +1596,20 @@ private void connectPVs() {
15901596 }
15911597
15921598 /**
1593- *
15941599 * @param configurationData {@link ConfigurationData} obejct of a {@link org.phoebus.applications.saveandrestore.model.Configuration}
15951600 * @return <code>true</code> if any if the {@link ConfigPv} items in {@link ConfigurationData#getPvList()} defines a non-null read-back
15961601 * PV name, otherwise <code>false</code>.
15971602 */
1598- private boolean configurationHasReadbackPvs (ConfigurationData configurationData ){
1603+ private boolean configurationHasReadbackPvs (ConfigurationData configurationData ) {
15991604 return configurationData .getPvList ().stream ().anyMatch (cp -> cp .getReadbackPvName () != null );
16001605 }
16011606
16021607 /**
1603- *
16041608 * @param snapshotData {@link SnapshotData} obejct of a {@link org.phoebus.applications.saveandrestore.model.Snapshot}
16051609 * @return <code>true</code> if any if the {@link ConfigPv} items in {@link SnapshotData#getSnapshotItems()} defines a non-null read-back
16061610 * PV name, otherwise <code>false</code>.
16071611 */
1608- private boolean configurationHasReadbackPvs (SnapshotData snapshotData ){
1612+ private boolean configurationHasReadbackPvs (SnapshotData snapshotData ) {
16091613 return snapshotData .getSnapshotItems ().stream ().anyMatch (si -> si .getConfigPv ().getReadbackPvName () != null );
16101614 }
16111615
@@ -1660,4 +1664,32 @@ public void updateItem(org.phoebus.applications.saveandrestore.ui.snapshot.Actio
16601664 }
16611665 }
16621666 }
1667+
1668+ /**
1669+ * {@link TableCell} customized for the alarm severity column such that alarm information is
1670+ * decorated in the same manner as in other applications.
1671+ */
1672+ private static class AlarmSeverityCell extends TableCell <TableEntry , AlarmSeverity > {
1673+
1674+ @ Override
1675+ public void updateItem (AlarmSeverity alarmSeverity , boolean empty ) {
1676+ if (empty ) {
1677+ setText (null );
1678+ setStyle (TableCellColors .REGULAR_CELL_STYLE );
1679+ } else if (alarmSeverity == null ) {
1680+ setText ("---" );
1681+ setStyle (TableCellColors .REGULAR_CELL_STYLE );
1682+ } else {
1683+ setText (alarmSeverity .toString ());
1684+ switch (alarmSeverity ) {
1685+ case NONE -> setStyle (TableCellColors .ALARM_NONE_STYLE );
1686+ case UNDEFINED -> setStyle (TableCellColors .ALARM_UNDEFINED_STYLE );
1687+ case MINOR -> setStyle (TableCellColors .ALARM_MINOR_STYLE );
1688+ case MAJOR -> setStyle (TableCellColors .ALARM_MAJOR_STYLE );
1689+ case INVALID -> setStyle (TableCellColors .ALARM_INVALID_STYLE );
1690+ }
1691+ }
1692+
1693+ }
1694+ }
16631695}
0 commit comments