From 0e4fe4e9bb863b7b3be8077f26e6493172960a1b Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Tue, 26 Oct 2021 18:46:08 +0200 Subject: [PATCH] Theme Editor: support platform and light/dark specific properties in preview --- .../FlatThemePropertiesSupport.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java index ba669e66..636a049d 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java @@ -33,6 +33,7 @@ import javax.swing.event.DocumentListener; import javax.swing.plaf.basic.BasicLookAndFeel; import javax.swing.text.BadLocationException; import com.formdev.flatlaf.UIDefaultsLoaderAccessor; +import com.formdev.flatlaf.util.SystemInfo; /** * Supports parsing content of text area in FlatLaf properties syntax. @@ -59,6 +60,11 @@ class FlatThemePropertiesSupport private static Set wildcardKeys; + private static final String platformPrefix = + SystemInfo.isWindows ? "[win]" : + SystemInfo.isMacOS ? "[mac]" : + SystemInfo.isLinux ? "[linux]" : "[unknown]"; + FlatThemePropertiesSupport( FlatSyntaxTextArea textArea ) { this.textArea = textArea; @@ -148,7 +154,17 @@ class FlatThemePropertiesSupport } private String getPropertyOrWildcard( String key ) { - String value = getProperty( key ); + // get platform specific properties + String value = getProperty( platformPrefix + key ); + if( value != null ) + return value; + + // get light/dark specific properties + value = getProperty( (isDark( getBaseTheme() ) ? "[dark]" : "[light]") + key ); + if( value != null ) + return value; + + value = getProperty( key ); if( value != null ) return value;