Theme Editor: use deferred properties loading

This commit is contained in:
Karl Tauber
2020-07-07 14:21:31 +02:00
parent 7ed90cddf8
commit 6f71e4ada0
3 changed files with 16 additions and 10 deletions

View File

@@ -17,7 +17,6 @@
package com.formdev.flatlaf;
import java.util.Collections;
import java.util.Properties;
import java.util.function.Function;
import com.formdev.flatlaf.UIDefaultsLoader.ValueType;
@@ -49,8 +48,8 @@ public class UIDefaultsLoaderAccessor
public static Object NULL = ValueType.NULL;
public static Object LAZY = ValueType.LAZY;
public static String resolveValue( Properties properties, String value ) {
return UIDefaultsLoader.resolveValue( properties, value );
public static String resolveValue( String value, Function<String, String> propertiesGetter ) {
return UIDefaultsLoader.resolveValue( value, propertiesGetter );
}
public static Object parseValue( String key, String value, Object[] resultValueType,

View File

@@ -37,6 +37,7 @@ class FlatThemePropertiesSupport
implements DocumentListener
{
private final FlatSyntaxTextArea textArea;
private final Function<String, String> propertiesGetter;
private final Function<String, String> resolver;
private Properties propertiesCache;
private final Map<Integer, Object> parsedValueCache = new HashMap<>();
@@ -44,6 +45,9 @@ class FlatThemePropertiesSupport
FlatThemePropertiesSupport( FlatSyntaxTextArea textArea ) {
this.textArea = textArea;
propertiesGetter = key -> {
return getProperties().getProperty( key );
};
resolver = v -> {
return resolveValue( v );
};
@@ -52,7 +56,7 @@ class FlatThemePropertiesSupport
}
private String resolveValue( String value ) {
return UIDefaultsLoaderAccessor.resolveValue( getProperties(), value );
return UIDefaultsLoaderAccessor.resolveValue( value, propertiesGetter );
}
Object getParsedValueAtLine( int line ) {