Theme Editor: support platform and light/dark specific properties in preview

This commit is contained in:
Karl Tauber
2021-10-26 18:46:08 +02:00
parent 0156a9a9d5
commit 0e4fe4e9bb

View File

@@ -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<String> 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;