Skip to content

Commit 80c61ac

Browse files
authored
Merge pull request #3591 from rjwills28/custom_disabled_widget_style
Add property to configure the 'not_enabled' css styling for widgets
2 parents 365709a + 9893fdf commit 80c61ac

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

core/ui/src/main/java/org/phoebus/ui/Preferences.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
*******************************************************************************/
88
package org.phoebus.ui;
99

10+
import java.net.URI;
11+
import java.util.logging.Level;
12+
import java.util.logging.Logger;
13+
1014
import org.phoebus.framework.preferences.AnnotatedPreferences;
1115
import org.phoebus.framework.preferences.Preference;
1216

@@ -17,6 +21,8 @@
1721

1822
public class Preferences
1923
{
24+
public final static Logger logger = Logger.getLogger(Preferences.class.getPackageName());
25+
2026
/** splash */
2127
public static final String SPLASH = "splash";
2228
/** default_apps */
@@ -99,6 +105,8 @@ public class Preferences
99105
@Preference public static String window_title_format;
100106
/** default_window_title **/
101107
@Preference public static String default_window_title;
108+
/** Custom stylings file */
109+
@Preference public static String custom_css_styling;
102110

103111
static
104112
{
@@ -108,5 +116,19 @@ public class Preferences
108116
// (PVASettings cannot use Preferences.max_array_formatting
109117
// since the PVA library may be used standalone)
110118
System.setProperty("EPICS_PVA_MAX_ARRAY_FORMATTING", Integer.toString(max_array_formatting));
119+
120+
// Check once if the custom style sheet is accessible
121+
if (!custom_css_styling.isBlank())
122+
{
123+
try
124+
{
125+
new URI(custom_css_styling).toURL().openStream().close();
126+
}
127+
catch (Exception ex)
128+
{
129+
logger.log(Level.WARNING, custom_css_styling + " is inaccessible", ex);
130+
custom_css_styling = "";
131+
}
132+
}
111133
}
112134
}

core/ui/src/main/java/org/phoebus/ui/javafx/Styles.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
******************************************************************************/
88
package org.phoebus.ui.javafx;
99

10+
import org.phoebus.ui.Preferences;
11+
1012
import javafx.scene.Node;
1113
import javafx.scene.Scene;
1214

@@ -24,6 +26,10 @@ public static void setSceneStyle(final Scene scene)
2426
{
2527
final String css = Styles.class.getResource("csstudio.css").toExternalForm();
2628
set(scene, css);
29+
if (!Preferences.custom_css_styling.isEmpty())
30+
{
31+
set(scene, Preferences.custom_css_styling);
32+
}
2733
}
2834

2935
/** Apply style sheet to scene (but only once)

core/ui/src/main/resources/phoebus_ui_preferences.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,9 @@ documentation_location=
188188
# When there is no active tab, the default_window_title is used instead.
189189
window_title_format=CS-Studio: %s
190190
default_window_title=CS-Studio
191+
192+
# Custom stylings .css file allows users to override Phoebus and JavaFX
193+
# default stylings.Set the full path to the .css file
194+
# For a system file use syntax; 'file:</path/to/custom.css>'
195+
# For a file served over http use syntax: 'http://<address:port/custom.css>'
196+
custom_css_styling=

0 commit comments

Comments
 (0)