From 5aad35e7a91011fbe10502295424d0f758cbe3cf Mon Sep 17 00:00:00 2001 From: Percy Baker Date: Thu, 26 Nov 2026 11:24:31 +0000 Subject: [PATCH 1/2] Improve alarm tree text colors and backgrounds --- .../applications/alarm/ui/AlarmUI.java | 11 +++++ .../alarm/ui/tree/AlarmTreeViewCell.java | 43 ++++++++++++------- .../main/java/org/phoebus/ui/Preferences.java | 4 ++ .../phoebus_ui_preferences.properties | 5 +++ 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/AlarmUI.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/AlarmUI.java index e62af387bd..a37fc1811f 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/AlarmUI.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/AlarmUI.java @@ -137,6 +137,8 @@ else if (rgb.length == 4) createColor(Preferences.undefined_severity_text_color), // UNDEFINED }; + private static final Color disabled_color = createColor(Preferences.disabled_alarms_text_color); + private static final Background disabled_background = new Background(new BackgroundFill(createColor(Preferences.disabled_alarms_background_color), CornerRadii.EMPTY, Insets.EMPTY)); /** Icon for disabled alarms */ public static final Image disabled_icon = ImageCache.getImage(AlarmUI.class, "/icons/disabled.png"); @@ -181,6 +183,15 @@ public static Background getBackground(final SeverityLevel severity) return severity_backgrounds[severity.ordinal()]; } + public static Color getDisabledColor() + { + return disabled_color; + } + + public static Background getDisabledBackground() + { + return disabled_background; + } /** @param severity {@link SeverityLevel} * @return Background, may be null diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeViewCell.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeViewCell.java index 6879c30802..de375cf441 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeViewCell.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeViewCell.java @@ -7,12 +7,15 @@ *******************************************************************************/ package org.phoebus.applications.alarm.ui.tree; -import javafx.application.Platform; +import javafx.beans.binding.Bindings; +import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.control.TreeCell; import javafx.scene.image.ImageView; import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.CornerRadii; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; @@ -22,7 +25,6 @@ import org.phoebus.applications.alarm.model.SeverityLevel; import org.phoebus.applications.alarm.ui.AlarmUI; import org.phoebus.applications.alarm.ui.Messages; -import org.phoebus.framework.jobs.JobManager; import org.phoebus.util.time.TimestampFormats; import java.time.LocalDateTime; @@ -43,8 +45,8 @@ class AlarmTreeViewCell extends TreeCell> // So we add our own "graphics" to hold an icon and text private final Label label = new Label(); private final ImageView image = new ImageView(); - private final Label disabledTimerIndicator = new Label(""); - private final HBox content = new HBox(image, label, disabledTimerIndicator); + private final Label infoLabel = new Label(""); + private final HBox content = new HBox(image, label, infoLabel); // TreeCell optimizes redraws by suppressing updates // when old and new values match. @@ -67,7 +69,10 @@ protected boolean isItemChanged(final AlarmTreeItem before, final AlarmTreeIt public AlarmTreeViewCell() { content.setAlignment(Pos.CENTER_LEFT); - disabledTimerIndicator.setTextFill(Color.GRAY); + infoLabel.textFillProperty().bind(Bindings.createObjectBinding( + () -> isSelected() ? Color.WHITE : Color.gray(0.2), + selectedProperty() + )); } @Override @@ -102,18 +107,18 @@ protected void updateItem(final AlarmTreeItem item, final boolean empty) label.setBackground(AlarmUI.getBackground(state.severity)); image.setImage(AlarmUI.getIcon(state.severity)); - disabledTimerIndicator.setText(""); + infoLabel.setText(""); } else { if (leaf.getEnabled().enabled_date != null) { LocalDateTime enabledDate = leaf.getEnabled().enabled_date; String enabledDateString = TimestampFormats.SECONDS_FORMAT.format(enabledDate); - disabledTimerIndicator.setText("(" + Messages.disabledUntil + " " + enabledDateString + ")"); + infoLabel.setText("(" + Messages.disabledUntil + " " + enabledDateString + ")"); } else { - disabledTimerIndicator.setText("(" + Messages.disabled + ")"); + infoLabel.setText("(" + Messages.disabled + ")"); } - label.setTextFill(Color.GRAY); - label.setBackground(Background.EMPTY); + label.setTextFill(AlarmUI.getDisabledColor()); + label.setBackground(AlarmUI.getDisabledBackground()); image.setImage(AlarmUI.disabled_icon); } @@ -125,14 +130,22 @@ protected void updateItem(final AlarmTreeItem item, final boolean empty) String labelText = item.getName(); label.setText(labelText); SeverityLevel severityLevel = item.getState().severity; - disabledTimerIndicator.setText(AlarmTreeHelper.treeNodeInfoToString(info)); - if(info.disabled() + info.disabledWithEnableDate() == info.leaves().size()){ - label.setTextFill(Color.GRAY); + infoLabel.setText(AlarmTreeHelper.treeNodeInfoToString(info)); + if (info.leaves().isEmpty()) + { + label.setTextFill(Color.gray(0.7)); + label.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); } - else{ + else if (info.disabled() + info.disabledWithEnableDate() == info.leaves().size()) + { + label.setTextFill(AlarmUI.getDisabledColor()); + label.setBackground(AlarmUI.getDisabledBackground()); + } + else + { label.setTextFill(AlarmUI.getColor(severityLevel)); + label.setBackground(AlarmUI.getBackground(severityLevel)); } - label.setBackground(AlarmUI.getBackground(severityLevel)); image.setImage(AlarmUI.getIcon(severityLevel)); } // Profiler showed small advantage when skipping redundant 'setGraphic' call diff --git a/core/ui/src/main/java/org/phoebus/ui/Preferences.java b/core/ui/src/main/java/org/phoebus/ui/Preferences.java index 94997c637f..d58f88965e 100644 --- a/core/ui/src/main/java/org/phoebus/ui/Preferences.java +++ b/core/ui/src/main/java/org/phoebus/ui/Preferences.java @@ -96,6 +96,10 @@ public class Preferences @Preference public static int[] alarm_area_panel_invalid_severity_background_color; /** undefined_severity_background_color */ @Preference public static int[] alarm_area_panel_undefined_severity_background_color; + /** disabled_alarms_text_color */ + @Preference public static int[] disabled_alarms_text_color; + /** disabled_alarms_background_color */ + @Preference public static int[] disabled_alarms_background_color; /** cache_hint_for_picture_and_symbol_widgets */ @Preference public static String cache_hint_for_picture_and_symbol_widgets; @Preference public static boolean save_credentials; diff --git a/core/ui/src/main/resources/phoebus_ui_preferences.properties b/core/ui/src/main/resources/phoebus_ui_preferences.properties index f122b696c7..95000771d2 100644 --- a/core/ui/src/main/resources/phoebus_ui_preferences.properties +++ b/core/ui/src/main/resources/phoebus_ui_preferences.properties @@ -243,6 +243,11 @@ alarm_area_panel_invalid_severity_background_color=255,0,255 alarm_area_panel_undefined_severity_text_color=192,192,192 alarm_area_panel_undefined_severity_background_color=200,0,200,200 +# Color of text for disabled alarms +disabled_alarms_text_color=100,100,100 +# Color of background for disabled alarms +disabled_alarms_background_color=255,255,255 + # When Picture- and/or Symbol widgets are present in an OPI, # zooming in under Windows using the D3D graphics library can # cause excessive VRAM usage. Setting a cache hint can work as From 1fbe11d53fd7e0019bc8e6a5375de209792689b6 Mon Sep 17 00:00:00 2001 From: Percy Baker Date: Thu, 26 Nov 2026 11:35:09 +0000 Subject: [PATCH 2/2] satisfy pedantic linter --- core/ui/src/main/java/org/phoebus/ui/Preferences.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/ui/src/main/java/org/phoebus/ui/Preferences.java b/core/ui/src/main/java/org/phoebus/ui/Preferences.java index d58f88965e..364c9decc4 100644 --- a/core/ui/src/main/java/org/phoebus/ui/Preferences.java +++ b/core/ui/src/main/java/org/phoebus/ui/Preferences.java @@ -22,7 +22,7 @@ public class Preferences { public final static Logger logger = Logger.getLogger(Preferences.class.getPackageName()); - + /** splash */ public static final String SPLASH = "splash"; /** default_apps */ @@ -120,7 +120,7 @@ public class Preferences // (PVASettings cannot use Preferences.max_array_formatting // since the PVA library may be used standalone) System.setProperty("EPICS_PVA_MAX_ARRAY_FORMATTING", Integer.toString(max_array_formatting)); - + // Check once if the custom style sheet is accessible if (!custom_css_styling.isBlank()) {