UIDefaultsLoader: further reduced need for value type prefixes in properties files and in CSS styles

This commit is contained in:
Karl Tauber
2021-10-29 13:55:28 +02:00
parent fb4fe175d9
commit 8152b7dad6
4 changed files with 34 additions and 11 deletions

View File

@@ -340,6 +340,7 @@ class UIDefaultsLoader
private static ValueType[] tempResultValueType = new ValueType[1];
private static Map<Class<?>, ValueType> javaValueTypes;
private static Map<String, ValueType> knownValueTypes;
static Object parseValue( String key, String value, Class<?> valueType ) {
return parseValue( key, value, valueType, null, v -> v, Collections.emptyList() );
@@ -446,6 +447,28 @@ class UIDefaultsLoader
}
}
if( valueType == ValueType.UNKNOWN ) {
if( knownValueTypes == null ) {
// create lazy
knownValueTypes = new HashMap<>();
// SplitPane
knownValueTypes.put( "SplitPane.dividerSize", ValueType.INTEGER );
knownValueTypes.put( "SplitPaneDivider.gripDotSize", ValueType.INTEGER );
knownValueTypes.put( "dividerSize", ValueType.INTEGER );
knownValueTypes.put( "gripDotSize", ValueType.INTEGER );
// TabbedPane
knownValueTypes.put( "TabbedPane.closeCrossPlainSize", ValueType.FLOAT );
knownValueTypes.put( "TabbedPane.closeCrossFilledSize", ValueType.FLOAT );
knownValueTypes.put( "closeCrossPlainSize", ValueType.FLOAT );
knownValueTypes.put( "closeCrossFilledSize", ValueType.FLOAT );
// Table
knownValueTypes.put( "Table.intercellSpacing", ValueType.DIMENSION );
knownValueTypes.put( "intercellSpacing", ValueType.DIMENSION );
}
valueType = knownValueTypes.getOrDefault( key, ValueType.UNKNOWN );
}
// determine value type from key
if( valueType == ValueType.UNKNOWN ) {
if( key.endsWith( "UI" ) )

View File

@@ -563,7 +563,7 @@ Spinner.buttonStyle = button
#---- SplitPane ----
SplitPane.dividerSize = {integer}5
SplitPane.dividerSize = 5
SplitPane.continuousLayout = true
SplitPane.border = null
SplitPane.centerOneTouchButtons = true
@@ -578,7 +578,7 @@ SplitPaneDivider.oneTouchPressedArrowColor = @buttonPressedArrowColor
SplitPaneDivider.style = grip
SplitPaneDivider.gripColor = @icon
SplitPaneDivider.gripDotCount = 3
SplitPaneDivider.gripDotSize = {integer}3
SplitPaneDivider.gripDotSize = 3
SplitPaneDivider.gripGap = 2
@@ -624,7 +624,7 @@ TabbedPane.scrollButtonsPlacement = both
TabbedPane.closeIcon = com.formdev.flatlaf.icons.FlatTabbedPaneCloseIcon
TabbedPane.closeSize = 16,16
TabbedPane.closeArc = 4
TabbedPane.closeCrossPlainSize = {float}7.5
TabbedPane.closeCrossPlainSize = 7.5
TabbedPane.closeCrossFilledSize = $TabbedPane.closeCrossPlainSize
TabbedPane.closeCrossLineWidth = 1
@@ -636,7 +636,7 @@ Table.showHorizontalLines = false
Table.showVerticalLines = false
Table.showTrailingVerticalLine = false
Table.consistentHomeEndKeyBehavior = true
Table.intercellSpacing = {dimension}0,0
Table.intercellSpacing = 0,0
Table.scrollPaneBorder = com.formdev.flatlaf.ui.FlatBorder
Table.ascendingSortIcon = com.formdev.flatlaf.icons.FlatAscendingSortIcon
Table.descendingSortIcon = com.formdev.flatlaf.icons.FlatDescendingSortIcon

View File

@@ -800,7 +800,7 @@ public class TestFlatStyling
ui.applyStyle( "style: grip" );
ui.applyStyle( "gripColor: #fff" );
ui.applyStyle( "gripDotCount: 3" );
ui.applyStyle( "gripDotSize: {integer}3" );
ui.applyStyle( "gripDotSize: 3" );
ui.applyStyle( "gripGap: 2" );
// JComponent properties
@@ -809,7 +809,7 @@ public class TestFlatStyling
ui.applyStyle( "border: 2,2,2,2,#f00" );
// JSplitPane properties
ui.applyStyle( "dividerSize: {integer}20" );
ui.applyStyle( "dividerSize: 20" );
}
@Test
@@ -867,8 +867,8 @@ public class TestFlatStyling
// FlatTabbedPaneCloseIcon
ui.applyStyle( "closeSize: 16,16" );
ui.applyStyle( "closeArc: 4" );
ui.applyStyle( "closeCrossPlainSize: {float}7.5" );
ui.applyStyle( "closeCrossFilledSize: {float}7.5" );
ui.applyStyle( "closeCrossPlainSize: 7.5" );
ui.applyStyle( "closeCrossFilledSize: 7.5" );
ui.applyStyle( "closeCrossLineWidth: 1" );
ui.applyStyle( "closeBackground: #fff" );
ui.applyStyle( "closeForeground: #fff" );
@@ -911,7 +911,7 @@ public class TestFlatStyling
ui.applyStyle( "rowHeight: 30" );
ui.applyStyle( "showHorizontalLines: true" );
ui.applyStyle( "showVerticalLines: true" );
ui.applyStyle( "intercellSpacing: {dimension}1,1" );
ui.applyStyle( "intercellSpacing: 1,1" );
}
@Test