ignore internal UI keys in dumps and in UI defaults inspector

This commit is contained in:
Karl Tauber
2021-10-28 20:47:47 +02:00
parent b77b338c7a
commit ef25575f85
5 changed files with 2160 additions and 5 deletions

2151
compare1.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -80,7 +80,7 @@ class UIDefaultsLoader
private static final String OPTIONAL_PREFIX = "?"; private static final String OPTIONAL_PREFIX = "?";
private static final String WILDCARD_PREFIX = "*."; private static final String WILDCARD_PREFIX = "*.";
private static final String FLATLAF_VARIABLES = "FlatLaf.variables"; private static final String KEY_VARIABLES = "FlatLaf.internal.variables";
private static int parseColorDepth; private static int parseColorDepth;
@@ -263,7 +263,7 @@ class UIDefaultsLoader
} }
// remember variables in defaults to allow using them in styles // remember variables in defaults to allow using them in styles
defaults.put( FLATLAF_VARIABLES, variables ); defaults.put( KEY_VARIABLES, variables );
} catch( IOException ex ) { } catch( IOException ex ) {
LoggingFacade.INSTANCE.logSevere( "FlatLaf: Failed to load properties files.", ex ); LoggingFacade.INSTANCE.logSevere( "FlatLaf: Failed to load properties files.", ex );
} }
@@ -309,7 +309,7 @@ class UIDefaultsLoader
static String resolveValueFromUIManager( String value ) { static String resolveValueFromUIManager( String value ) {
if( value.startsWith( VARIABLE_PREFIX ) ) { if( value.startsWith( VARIABLE_PREFIX ) ) {
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
Map<String, String> variables = (Map<String, String>) UIManager.get( FLATLAF_VARIABLES ); Map<String, String> variables = (Map<String, String>) UIManager.get( KEY_VARIABLES );
String newValue = (variables != null) ? variables.get( value ) : null; String newValue = (variables != null) ? variables.get( value ) : null;
if( newValue == null ) if( newValue == null )
throw new IllegalArgumentException( "variable '" + value + "' not found" ); throw new IllegalArgumentException( "variable '" + value + "' not found" );

View File

@@ -313,6 +313,10 @@ public class FlatUIDefaultsInspector
if( !(key instanceof String) ) if( !(key instanceof String) )
continue; continue;
// ignore internal keys
if( ((String)key).startsWith( "FlatLaf.internal." ) )
continue;
// ignore values of type Class // ignore values of type Class
Object value = defaults.get( key ); Object value = defaults.get( key );
if( value instanceof Class ) if( value instanceof Class )

View File

@@ -373,7 +373,7 @@ public class UIDefaultsDump
Object value = entry.getValue(); Object value = entry.getValue();
String strKey = String.valueOf( key ); String strKey = String.valueOf( key );
if( !keyFilter.test( strKey ) ) if( !keyFilter.test( strKey ) || strKey.startsWith( "FlatLaf.internal." ) )
return; return;
String prefix = keyPrefix( strKey ); String prefix = keyPrefix( strKey );

View File

@@ -87,7 +87,7 @@ public class UIDefaultsKeysDump
UIDefaults defaults = UIManager.getLookAndFeel().getDefaults(); UIDefaults defaults = UIManager.getLookAndFeel().getDefaults();
for( Object key : defaults.keySet() ) { for( Object key : defaults.keySet() ) {
if( key instanceof String ) if( key instanceof String && !((String)key).startsWith( "FlatLaf.internal." ) )
keys.add( (String) key ); keys.add( (String) key );
} }
} }