From 9f55c5d209b183b644362c50f0f46d75514379f3 Mon Sep 17 00:00:00 2001 From: georgweiss Date: Tue, 29 Sep 2026 15:01:49 +0200 Subject: [PATCH 1/2] Regression bug fix: change of fonts in data browser does not work --- .../ui/properties/FontButton.java | 30 ++++++++++++++++--- .../ui/properties/MiscTabController.java | 12 ++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java index d1c76f57fe..8b85bfc658 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java @@ -43,17 +43,31 @@ public class FontButton extends Button private final ComboBox size = new ComboBox<>(FXCollections.observableArrayList("8", "10", "12", "14", "16", "18", "22", "24", "32")); private final CheckBox bold = new CheckBox(Messages.FontBtnBold), italic = new CheckBox(Messages.FontBtnItalics); - private TextField example = new TextField(Messages.FontBtnExample); + private final TextField example = new TextField(Messages.FontBtnExample); - private PopOver popover; + private final PopOver popover; private Font font; private Consumer on_font_selected; + /** + * No-arg constructor needed by FXML. + *

+ * Initial font and on_font_selected callback must be set if this constructor is used. + *

+ */ public FontButton(){ + popover = new PopOver(createContent()); + setOnAction(event -> + { + if (popover.isShowing()) + popover.hide(); + else + popover.show(this); + }); } - /** @param initial_font Intiial font + /** @param initial_font Initial font * @param on_font_selected Callback for selected font */ public FontButton(final Font initial_font, final Consumer on_font_selected) @@ -171,4 +185,12 @@ private String getDescription(final Font font) buf.append(",").append(font.getStyle()); return buf.toString(); } -} \ No newline at end of file + + public void setOnFontSelected(final Consumer onFontSelected) { + this.on_font_selected = onFontSelected; + } + + public void setInitialFont(final Font initialFont) { + this.font = initialFont; + } +} diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MiscTabController.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MiscTabController.java index 0096866473..73782d03ad 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MiscTabController.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/MiscTabController.java @@ -97,6 +97,18 @@ public void initialize() model.setAreaOpacity((int)Math.round(opacitySlider.getValue())); updating = false; }); + + titleFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getTitleFont(), font, (m, f) -> m.setTitleFont(f))); + titleFont.setInitialFont(model.getTitleFont()); + + labelFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getLabelFont(), font, (m, f) -> m.setLabelFont(f))); + labelFont.setInitialFont(model.getLabelFont()); + + scaleFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getScaleFont(), font, (m, f) -> m.setScaleFont(f))); + scaleFont.setInitialFont(model.getScaleFont()); + + legendFont.setOnFontSelected(font -> new ChangeFontCommand(model, undo, model.getLegendFont(), font, (m, f) -> m.setLegendFont(f))); + legendFont.setInitialFont(model.getLegendFont()); } // ----------------------------------------------------------------------- From bbfdd64058af38f86281d3ae002a77ae97a97d13 Mon Sep 17 00:00:00 2001 From: georgweiss Date: Tue, 29 Sep 2026 15:19:01 +0200 Subject: [PATCH 2/2] Remove a wee bit of code duplication --- .../trends/databrowser3/ui/properties/FontButton.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java index 8b85bfc658..bb39e9d402 100644 --- a/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java +++ b/app/databrowser/src/main/java/org/csstudio/trends/databrowser3/ui/properties/FontButton.java @@ -72,16 +72,9 @@ public FontButton(){ */ public FontButton(final Font initial_font, final Consumer on_font_selected) { + this(); this.font = initial_font; this.on_font_selected = on_font_selected; - popover = new PopOver(createContent()); - setOnAction(event -> - { - if (popover.isShowing()) - popover.hide(); - else - popover.show(this); - }); } private Node createContent()