From 959b3e46fa875e13ecf1dc93b0f7ece0d37f32c3 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 11 Dec 2021 00:50:05 +0100 Subject: [PATCH] Styling: fixes and added missing @since tags --- .../com/formdev/flatlaf/ui/FlatEditorPaneUI.java | 4 ++-- .../com/formdev/flatlaf/ui/FlatListCellBorder.java | 6 +++--- .../java/com/formdev/flatlaf/ui/FlatListUI.java | 6 +++--- .../formdev/flatlaf/ui/FlatMenuItemRenderer.java | 2 ++ .../com/formdev/flatlaf/ui/FlatScrollBarUI.java | 2 +- .../com/formdev/flatlaf/ui/FlatTableCellBorder.java | 2 +- .../formdev/flatlaf/ui/FlatTableHeaderBorder.java | 4 ++-- .../com/formdev/flatlaf/ui/FlatTableHeaderUI.java | 10 +++++----- .../java/com/formdev/flatlaf/ui/FlatTableUI.java | 6 +++--- .../java/com/formdev/flatlaf/ui/FlatTreeUI.java | 13 +++++++------ .../formdev/flatlaf/ui/TestFlatStyleableInfo.java | 6 +++--- .../com/formdev/flatlaf/ui/TestFlatStyling.java | 13 +++++++++++-- 12 files changed, 43 insertions(+), 31 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java index 45f02e74..66defaa2 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatEditorPaneUI.java @@ -44,8 +44,8 @@ import com.formdev.flatlaf.util.LoggingFacade; * * * @uiDefault EditorPane.font Font - * @uiDefault EditorPane.background Color also used if not editable - * @uiDefault EditorPane.foreground Color + * @uiDefault EditorPane.background Color + * @uiDefault EditorPane.foreground Color also used if not editable * @uiDefault EditorPane.caretForeground Color * @uiDefault EditorPane.selectionBackground Color * @uiDefault EditorPane.selectionForeground Color diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListCellBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListCellBorder.java index 4e87570e..2eed2653 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListCellBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListCellBorder.java @@ -37,7 +37,7 @@ import javax.swing.plaf.ListUI; public class FlatListCellBorder extends FlatLineBorder { - protected boolean showCellFocusIndicator = UIManager.getBoolean( "List.showCellFocusIndicator" ); + /** @since 2 */ protected boolean showCellFocusIndicator = UIManager.getBoolean( "List.showCellFocusIndicator" ); private Component c; @@ -113,7 +113,7 @@ public class FlatListCellBorder /** * Border for selected cell that uses margins and paints focus indicator border - * if enabled (List.showCellFocusIndicator=true) and exactly one item is selected. + * if enabled (List.showCellFocusIndicator=true) and multiple items are selected. */ public static class Selected extends FlatListCellBorder @@ -125,7 +125,7 @@ public class FlatListCellBorder if( !showCellFocusIndicator ) return; - // paint focus indicator border only if exactly one item is selected + // paint focus indicator border only if multiple items are selected JList list = (JList) SwingUtilities.getAncestorOfClass( JList.class, c ); if( list != null && list.getMinSelectionIndex() == list.getMaxSelectionIndex() ) return; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java index cd0ab3f5..3d347f9e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatListUI.java @@ -78,9 +78,9 @@ public class FlatListUI @Styleable protected Color selectionInactiveForeground; // for FlatListCellBorder - @Styleable protected Insets cellMargins; - @Styleable protected Color cellFocusColor; - @Styleable protected boolean showCellFocusIndicator; + /** @since 2 */ @Styleable protected Insets cellMargins; + /** @since 2 */ @Styleable protected Color cellFocusColor; + /** @since 2 */ @Styleable protected Boolean showCellFocusIndicator; private Map oldStyleValues; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java index 37fb87ed..010330a1 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatMenuItemRenderer.java @@ -62,6 +62,8 @@ import com.formdev.flatlaf.util.SystemInfo; * @uiDefault MenuItem.textNoAcceleratorGap int * @uiDefault MenuItem.acceleratorArrowGap int * @uiDefault MenuItem.checkBackground Color + * @uiDefault MenuItem.checkMargins Insets + * @uiDefault MenuItem.selectionType String null (default) or underline * @uiDefault MenuItem.underlineSelectionBackground Color * @uiDefault MenuItem.underlineSelectionCheckBackground Color * @uiDefault MenuItem.underlineSelectionColor Color diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java index b7e959b8..baf6a4a8 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatScrollBarUI.java @@ -47,7 +47,7 @@ import com.formdev.flatlaf.util.UIScale; * * * @uiDefault ScrollBar.background Color - * @uiDefault ScrollBar.foreground Color + * @uiDefault ScrollBar.foreground Color unused * @uiDefault ScrollBar.track Color * @uiDefault ScrollBar.thumb Color * @uiDefault ScrollBar.width int diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableCellBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableCellBorder.java index 76263b12..d5fd7b8e 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableCellBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableCellBorder.java @@ -37,7 +37,7 @@ import javax.swing.plaf.TableUI; public class FlatTableCellBorder extends FlatLineBorder { - protected boolean showCellFocusIndicator = UIManager.getBoolean( "Table.showCellFocusIndicator" ); + /** @since 2 */ protected boolean showCellFocusIndicator = UIManager.getBoolean( "Table.showCellFocusIndicator" ); private Component c; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java index 30f7a06b..d3c01011 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java @@ -141,8 +141,8 @@ public class FlatTableHeaderBorder protected boolean hideTrailingVerticalLine( JTableHeader header ) { if( header.getUI() instanceof FlatTableHeaderUI ) { FlatTableHeaderUI ui = (FlatTableHeaderUI) header.getUI(); - if( ui.showTrailingVerticalLine ) - return false; + if( ui.showTrailingVerticalLine != null ) + return !ui.showTrailingVerticalLine; } if( showTrailingVerticalLine ) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java index 8be68cbf..e85041d4 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java @@ -84,14 +84,14 @@ public class FlatTableHeaderUI @Styleable(type=String.class) protected int sortIconPosition; // for FlatTableHeaderBorder - @Styleable protected Insets cellMargins; - @Styleable protected Color separatorColor; - /** @since 2 */ @Styleable protected boolean showTrailingVerticalLine; + /** @since 2 */ @Styleable protected Insets cellMargins; + /** @since 2 */ @Styleable protected Color separatorColor; + /** @since 2 */ @Styleable protected Boolean showTrailingVerticalLine; // for FlatAscendingSortIcon and FlatDescendingSortIcon // (needs to be public because icon classes are in another package) - @Styleable public String arrowType; - @Styleable public Color sortIconColor; + /** @since 2 */ @Styleable public String arrowType; + /** @since 2 */ @Styleable public Color sortIconColor; private PropertyChangeListener propertyChangeListener; private Map oldStyleValues; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java index 930b04b8..aeac29cc 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java @@ -108,9 +108,9 @@ public class FlatTableUI @Styleable protected Color selectionInactiveForeground; // for FlatTableCellBorder - @Styleable protected Insets cellMargins; - @Styleable protected Color cellFocusColor; - @Styleable protected boolean showCellFocusIndicator; + /** @since 2 */ @Styleable protected Insets cellMargins; + /** @since 2 */ @Styleable protected Color cellFocusColor; + /** @since 2 */ @Styleable protected Boolean showCellFocusIndicator; private boolean oldShowHorizontalLines; private boolean oldShowVerticalLines; diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java index 4ce76078..ee610c2d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTreeUI.java @@ -52,6 +52,7 @@ import com.formdev.flatlaf.util.UIScale; * * @uiDefault Tree.font Font * @uiDefault Tree.background Color + * @uiDefault Tree.foreground Color unused * @uiDefault Tree.hash Color * @uiDefault Tree.dropLineColor Color * @uiDefault Tree.expandedIcon Icon @@ -136,12 +137,12 @@ public class FlatTreeUI // for icons // (needs to be public because icon classes are in another package) - @Styleable(dot=true) public String iconArrowType; - @Styleable(dot=true) public Color iconExpandedColor; - @Styleable(dot=true) public Color iconCollapsedColor; - @Styleable(dot=true) public Color iconLeafColor; - @Styleable(dot=true) public Color iconClosedColor; - @Styleable(dot=true) public Color iconOpenColor; + /** @since 2 */ @Styleable(dot=true) public String iconArrowType; + /** @since 2 */ @Styleable(dot=true) public Color iconExpandedColor; + /** @since 2 */ @Styleable(dot=true) public Color iconCollapsedColor; + /** @since 2 */ @Styleable(dot=true) public Color iconLeafColor; + /** @since 2 */ @Styleable(dot=true) public Color iconClosedColor; + /** @since 2 */ @Styleable(dot=true) public Color iconOpenColor; // only used via styling (not in UI defaults, but has likewise client properties) /** @since 2 */ @Styleable protected boolean paintSelection = true; diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java index 6475406e..bced364e 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyleableInfo.java @@ -257,7 +257,7 @@ public class TestFlatStyleableInfo // FlatListCellBorder "cellMargins", Insets.class, "cellFocusColor", Color.class, - "showCellFocusIndicator", boolean.class + "showCellFocusIndicator", Boolean.class ); assertMapEquals( expected, ui.getStyleableInfos( c ) ); @@ -760,7 +760,7 @@ public class TestFlatStyleableInfo // FlatTableCellBorder "cellMargins", Insets.class, "cellFocusColor", Color.class, - "showCellFocusIndicator", boolean.class + "showCellFocusIndicator", Boolean.class ); assertMapEquals( expected, ui.getStyleableInfos( c ) ); @@ -779,7 +779,7 @@ public class TestFlatStyleableInfo // FlatTableHeaderBorder "cellMargins", Insets.class, "separatorColor", Color.class, - "showTrailingVerticalLine", boolean.class, + "showTrailingVerticalLine", Boolean.class, // FlatAscendingSortIcon and FlatDescendingSortIcon "arrowType", String.class, diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java index c6dec738..05d46ce8 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java @@ -261,6 +261,7 @@ public class TestFlatStyling // AbstractButton properties ui.applyStyle( b, "margin: 2,2,2,2" ); + ui.applyStyle( b, "iconTextGap: 4" ); } @Test @@ -312,6 +313,9 @@ public class TestFlatStyling ui.applyStyle( "foreground: #fff" ); ui.applyStyle( "border: 2,2,2,2,#f00" ); ui.applyStyle( "font: italic 12 monospaced" ); + + // JComboBox properties + ui.applyStyle( "maximumRowCount: 20" ); } @Test @@ -335,6 +339,7 @@ public class TestFlatStyling ui.applyStyle( "selectionColor: #fff" ); ui.applyStyle( "selectedTextColor: #fff" ); ui.applyStyle( "disabledTextColor: #fff" ); + ui.applyStyle( "margin: 2,2,2,2" ); } @Test @@ -492,6 +497,7 @@ public class TestFlatStyling // AbstractButton properties applyStyle.accept( "margin: 2,2,2,2" ); + applyStyle.accept( "iconTextGap: 4" ); } private void menuItemRenderer( Consumer applyStyle ) { @@ -620,6 +626,7 @@ public class TestFlatStyling // AbstractButton properties ui.applyStyle( b, "margin: 2,2,2,2" ); + ui.applyStyle( b, "iconTextGap: 4" ); //---- icon ---- @@ -716,6 +723,7 @@ public class TestFlatStyling ui.applyStyle( "background: #fff" ); ui.applyStyle( "foreground: #fff" ); ui.applyStyle( "border: 2,2,2,2,#f00" ); + ui.applyStyle( "viewportBorder: 2,2,2,2,#f00" ); } @Test @@ -933,7 +941,6 @@ public class TestFlatStyling // JComponent properties ui.applyStyle( "background: #fff" ); ui.applyStyle( "foreground: #fff" ); - ui.applyStyle( "border: 2,2,2,2,#f00" ); ui.applyStyle( "font: italic 12 monospaced" ); // JTable properties @@ -965,7 +972,6 @@ public class TestFlatStyling // JComponent properties ui.applyStyle( "background: #fff" ); ui.applyStyle( "foreground: #fff" ); - ui.applyStyle( "border: 2,2,2,2,#f00" ); ui.applyStyle( "font: italic 12 monospaced" ); } @@ -990,6 +996,7 @@ public class TestFlatStyling ui.applyStyle( "selectionColor: #fff" ); ui.applyStyle( "selectedTextColor: #fff" ); ui.applyStyle( "disabledTextColor: #fff" ); + ui.applyStyle( "margin: 2,2,2,2" ); } @Test @@ -1024,6 +1031,7 @@ public class TestFlatStyling ui.applyStyle( "selectionColor: #fff" ); ui.applyStyle( "selectedTextColor: #fff" ); ui.applyStyle( "disabledTextColor: #fff" ); + ui.applyStyle( "margin: 2,2,2,2" ); } @Test @@ -1047,6 +1055,7 @@ public class TestFlatStyling ui.applyStyle( "selectionColor: #fff" ); ui.applyStyle( "selectedTextColor: #fff" ); ui.applyStyle( "disabledTextColor: #fff" ); + ui.applyStyle( "margin: 2,2,2,2" ); } @Test