mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
UIDefaultsLoader:
- changed "globals" to "wildcard replacements" - strict checking for background/foreground keys
This commit is contained in:
@@ -70,7 +70,7 @@ class UIDefaultsLoader
|
|||||||
private static final String VARIABLE_PREFIX = "@";
|
private static final String VARIABLE_PREFIX = "@";
|
||||||
private static final String PROPERTY_PREFIX = "$";
|
private static final String PROPERTY_PREFIX = "$";
|
||||||
private static final String OPTIONAL_PREFIX = "?";
|
private static final String OPTIONAL_PREFIX = "?";
|
||||||
private static final String GLOBAL_PREFIX = "*.";
|
private static final String WILDCARD_PREFIX = "*.";
|
||||||
|
|
||||||
static void loadDefaultsFromProperties( Class<?> lookAndFeelClass, List<FlatDefaultsAddon> addons,
|
static void loadDefaultsFromProperties( Class<?> lookAndFeelClass, List<FlatDefaultsAddon> addons,
|
||||||
Properties additionalDefaults, boolean dark, UIDefaults defaults )
|
Properties additionalDefaults, boolean dark, UIDefaults defaults )
|
||||||
@@ -198,19 +198,19 @@ class UIDefaultsLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get (and remove) globals, which override all other defaults that end with same suffix
|
// get (and remove) wildcard replacements, which override all other defaults that end with same suffix
|
||||||
HashMap<String, String> globals = new HashMap<>();
|
HashMap<String, String> wildcards = new HashMap<>();
|
||||||
Iterator<Entry<Object, Object>> it = properties.entrySet().iterator();
|
Iterator<Entry<Object, Object>> it = properties.entrySet().iterator();
|
||||||
while( it.hasNext() ) {
|
while( it.hasNext() ) {
|
||||||
Entry<Object, Object> e = it.next();
|
Entry<Object, Object> e = it.next();
|
||||||
String key = (String) e.getKey();
|
String key = (String) e.getKey();
|
||||||
if( key.startsWith( GLOBAL_PREFIX ) ) {
|
if( key.startsWith( WILDCARD_PREFIX ) ) {
|
||||||
globals.put( key.substring( GLOBAL_PREFIX.length() ), (String) e.getValue() );
|
wildcards.put( key.substring( WILDCARD_PREFIX.length() ), (String) e.getValue() );
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// override UI defaults with globals
|
// override UI defaults with wildcard replacements
|
||||||
for( Object key : defaults.keySet() ) {
|
for( Object key : defaults.keySet() ) {
|
||||||
int dot;
|
int dot;
|
||||||
if( !(key instanceof String) ||
|
if( !(key instanceof String) ||
|
||||||
@@ -218,10 +218,10 @@ class UIDefaultsLoader
|
|||||||
(dot = ((String)key).lastIndexOf( '.' )) < 0 )
|
(dot = ((String)key).lastIndexOf( '.' )) < 0 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String globalKey = ((String)key).substring( dot + 1 );
|
String wildcardKey = ((String)key).substring( dot + 1 );
|
||||||
String globalValue = globals.get( globalKey );
|
String wildcardValue = wildcards.get( wildcardKey );
|
||||||
if( globalValue != null )
|
if( wildcardValue != null )
|
||||||
properties.put( key, globalValue );
|
properties.put( key, wildcardValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
Function<String, String> propertiesGetter = key -> {
|
Function<String, String> propertiesGetter = key -> {
|
||||||
@@ -341,7 +341,12 @@ class UIDefaultsLoader
|
|||||||
|
|
||||||
// determine value type from key
|
// determine value type from key
|
||||||
if( valueType == ValueType.UNKNOWN ) {
|
if( valueType == ValueType.UNKNOWN ) {
|
||||||
if( key.endsWith( "ground" ) || key.endsWith( "Color" ) )
|
if( key.endsWith( "UI" ) )
|
||||||
|
valueType = ValueType.STRING;
|
||||||
|
else if( key.endsWith( "Color" ) ||
|
||||||
|
(key.endsWith( "ground" ) &&
|
||||||
|
(key.endsWith( ".background" ) || key.endsWith( "Background" ) ||
|
||||||
|
key.endsWith( ".foreground" ) || key.endsWith( "Foreground" ))) )
|
||||||
valueType = ValueType.COLOR;
|
valueType = ValueType.COLOR;
|
||||||
else if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
else if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
||||||
valueType = ValueType.BORDER;
|
valueType = ValueType.BORDER;
|
||||||
@@ -356,8 +361,6 @@ class UIDefaultsLoader
|
|||||||
valueType = ValueType.INTEGER;
|
valueType = ValueType.INTEGER;
|
||||||
else if( key.endsWith( "Char" ) )
|
else if( key.endsWith( "Char" ) )
|
||||||
valueType = ValueType.CHARACTER;
|
valueType = ValueType.CHARACTER;
|
||||||
else if( key.endsWith( "UI" ) )
|
|
||||||
valueType = ValueType.STRING;
|
|
||||||
else if( key.endsWith( "grayFilter" ) )
|
else if( key.endsWith( "grayFilter" ) )
|
||||||
valueType = ValueType.GRAYFILTER;
|
valueType = ValueType.GRAYFILTER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ ViewportUI = com.formdev.flatlaf.ui.FlatViewportUI
|
|||||||
@menuItemMargin = 3,6,3,6
|
@menuItemMargin = 3,6,3,6
|
||||||
|
|
||||||
|
|
||||||
#---- globals ----
|
#---- wildcard replacements ----
|
||||||
|
|
||||||
*.background = @background
|
*.background = @background
|
||||||
*.foreground = @foreground
|
*.foreground = @foreground
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
@dropLineShortColor = #ff0
|
@dropLineShortColor = #ff0
|
||||||
|
|
||||||
|
|
||||||
#---- globals ----
|
#---- wildcard replacements ----
|
||||||
|
|
||||||
*.caretForeground = #00f
|
*.caretForeground = #00f
|
||||||
*.inactiveBackground = #f0f0f0
|
*.inactiveBackground = #f0f0f0
|
||||||
|
|||||||
Reference in New Issue
Block a user