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 3b0795de07..94997c637f 100644 --- a/core/ui/src/main/java/org/phoebus/ui/Preferences.java +++ b/core/ui/src/main/java/org/phoebus/ui/Preferences.java @@ -7,6 +7,10 @@ *******************************************************************************/ package org.phoebus.ui; +import java.net.URI; +import java.util.logging.Level; +import java.util.logging.Logger; + import org.phoebus.framework.preferences.AnnotatedPreferences; import org.phoebus.framework.preferences.Preference; @@ -17,6 +21,8 @@ public class Preferences { + public final static Logger logger = Logger.getLogger(Preferences.class.getPackageName()); + /** splash */ public static final String SPLASH = "splash"; /** default_apps */ @@ -99,6 +105,8 @@ public class Preferences @Preference public static String window_title_format; /** default_window_title **/ @Preference public static String default_window_title; + /** Custom stylings file */ + @Preference public static String custom_css_styling; static { @@ -108,5 +116,19 @@ 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()) + { + try + { + new URI(custom_css_styling).toURL().openStream().close(); + } + catch (Exception ex) + { + logger.log(Level.WARNING, custom_css_styling + " is inaccessible", ex); + custom_css_styling = ""; + } + } } } diff --git a/core/ui/src/main/java/org/phoebus/ui/javafx/Styles.java b/core/ui/src/main/java/org/phoebus/ui/javafx/Styles.java index 18cce81cf3..d675319dd8 100644 --- a/core/ui/src/main/java/org/phoebus/ui/javafx/Styles.java +++ b/core/ui/src/main/java/org/phoebus/ui/javafx/Styles.java @@ -7,6 +7,8 @@ ******************************************************************************/ package org.phoebus.ui.javafx; +import org.phoebus.ui.Preferences; + import javafx.scene.Node; import javafx.scene.Scene; @@ -24,6 +26,10 @@ public static void setSceneStyle(final Scene scene) { final String css = Styles.class.getResource("csstudio.css").toExternalForm(); set(scene, css); + if (!Preferences.custom_css_styling.isEmpty()) + { + set(scene, Preferences.custom_css_styling); + } } /** Apply style sheet to scene (but only once) diff --git a/core/ui/src/main/resources/phoebus_ui_preferences.properties b/core/ui/src/main/resources/phoebus_ui_preferences.properties index f99f2d00e5..1802bd12e0 100644 --- a/core/ui/src/main/resources/phoebus_ui_preferences.properties +++ b/core/ui/src/main/resources/phoebus_ui_preferences.properties @@ -188,3 +188,9 @@ documentation_location= # When there is no active tab, the default_window_title is used instead. window_title_format=CS-Studio: %s default_window_title=CS-Studio + +# Custom stylings .css file allows users to override Phoebus and JavaFX +# default stylings.Set the full path to the .css file +# For a system file use syntax; 'file:' +# For a file served over http use syntax: 'http://' +custom_css_styling= \ No newline at end of file