From 824db2e3bdb586dfea959d5e6101616ce9a918b3 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 5 Sep 2021 11:51:28 +0200 Subject: [PATCH] Table and TableHeader: added UI defaults to show last vertical line (issue #332) --- .../java/com/formdev/flatlaf/ui/FlatTableHeaderBorder.java | 4 ++++ .../main/java/com/formdev/flatlaf/ui/FlatTableHeaderUI.java | 1 + .../src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java | 6 ++++++ .../main/resources/com/formdev/flatlaf/FlatLaf.properties | 3 ++- flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt | 2 ++ flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt | 2 ++ flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt | 2 ++ .../com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt | 2 ++ 8 files changed, 21 insertions(+), 1 deletion(-) 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 d8e6e87c..836aaac6 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 @@ -44,6 +44,7 @@ public class FlatTableHeaderBorder { protected Color separatorColor = UIManager.getColor( "TableHeader.separatorColor" ); protected Color bottomSeparatorColor = UIManager.getColor( "TableHeader.bottomSeparatorColor" ); + protected boolean showLastVerticalLine = UIManager.getBoolean( "TableHeader.showLastVerticalLine" ); public FlatTableHeaderBorder() { super( UIManager.getInsets( "TableHeader.cellMargins" ) ); @@ -108,6 +109,9 @@ public class FlatTableHeaderBorder } protected boolean hideTrailingVerticalLine( JTableHeader header ) { + if( showLastVerticalLine ) + return false; + Container viewport = header.getParent(); Container viewportParent = (viewport != null) ? viewport.getParent() : null; if( !(viewportParent instanceof JScrollPane) ) 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 82d861ad..bbf1ee7b 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 @@ -62,6 +62,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault TableHeader.cellMargins Insets * @uiDefault TableHeader.separatorColor Color * @uiDefault TableHeader.bottomSeparatorColor Color + * @uiDefault TableHeader.showLastVerticalLine boolean * * @author Karl Tauber */ 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 11ad7154..15aafe1a 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 @@ -69,6 +69,7 @@ import com.formdev.flatlaf.util.UIScale; * @uiDefault Table.rowHeight int * @uiDefault Table.showHorizontalLines boolean * @uiDefault Table.showVerticalLines boolean + * @uiDefault Table.showLastVerticalLine boolean * @uiDefault Table.intercellSpacing Dimension * @uiDefault Table.selectionInactiveBackground Color * @uiDefault Table.selectionInactiveForeground Color @@ -90,6 +91,7 @@ public class FlatTableUI { protected boolean showHorizontalLines; protected boolean showVerticalLines; + protected boolean showLastVerticalLine; protected Dimension intercellSpacing; protected Color selectionBackground; @@ -111,6 +113,7 @@ public class FlatTableUI showHorizontalLines = UIManager.getBoolean( "Table.showHorizontalLines" ); showVerticalLines = UIManager.getBoolean( "Table.showVerticalLines" ); + showLastVerticalLine = UIManager.getBoolean( "Table.showLastVerticalLine" ); intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" ); selectionBackground = UIManager.getColor( "Table.selectionBackground" ); @@ -292,6 +295,9 @@ public class FlatTableUI } protected boolean hideLastVerticalLine() { + if( showLastVerticalLine ) + return false; + Container viewport = SwingUtilities.getUnwrappedParent( table ); Container viewportParent = (viewport != null) ? viewport.getParent() : null; if( !(viewportParent instanceof JScrollPane) ) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 5688074e..77b28abc 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -628,6 +628,7 @@ TabbedPane.closeCrossLineWidth = {float}1 Table.rowHeight = 20 Table.showHorizontalLines = false Table.showVerticalLines = false +Table.showLastVerticalLine = false Table.consistentHomeEndKeyBehavior = true Table.intercellSpacing = {dimension}0,0 Table.scrollPaneBorder = com.formdev.flatlaf.ui.FlatBorder @@ -657,7 +658,7 @@ TableHeader.cellBorder = com.formdev.flatlaf.ui.FlatTableHeaderBorder TableHeader.cellMargins = 2,3,2,3 TableHeader.focusCellBackground = $TableHeader.background TableHeader.background = @textComponentBackground - +TableHeader.showLastVerticalLine = false #---- TextArea ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt index 2f401fdc..7078e1ca 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0_202.txt @@ -1078,6 +1078,7 @@ Table.selectionForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.Colo Table.selectionInactiveBackground #0d293e HSL 206 65 15 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #adadad HSL 0 0 68 javax.swing.plaf.ColorUIResource [UI] @@ -1093,6 +1094,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #5e6364 HSL 190 3 38 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt index d3942343..722b34f6 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0_202.txt @@ -1083,6 +1083,7 @@ Table.selectionForeground #ffffff HSL 0 0 100 javax.swing.plaf.Colo Table.selectionInactiveBackground #d4d4d4 HSL 0 0 83 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #afafaf HSL 0 0 69 javax.swing.plaf.ColorUIResource [UI] @@ -1098,6 +1099,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #e6e6e6 HSL 0 0 90 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt index 40d64308..394f5678 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0_202.txt @@ -1088,6 +1088,7 @@ Table.selectionForeground #ffff00 HSL 60 100 50 javax.swing.plaf.Colo Table.selectionInactiveBackground #888888 HSL 0 0 53 javax.swing.plaf.ColorUIResource [UI] Table.selectionInactiveForeground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] Table.showHorizontalLines false +Table.showLastVerticalLine false Table.showVerticalLines false Table.sortIconColor #ffff00 HSL 60 100 50 javax.swing.plaf.ColorUIResource [UI] @@ -1103,6 +1104,7 @@ TableHeader.font [active] $defaultFont [UI] TableHeader.foreground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] TableHeader.height 25 TableHeader.separatorColor #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] +TableHeader.showLastVerticalLine false TableHeaderUI com.formdev.flatlaf.ui.FlatTableHeaderUI diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index c50e3328..fd85f54b 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -830,6 +830,7 @@ Table.selectionForeground Table.selectionInactiveBackground Table.selectionInactiveForeground Table.showHorizontalLines +Table.showLastVerticalLine Table.showVerticalLines Table.sortIconColor TableHeader.ancestorInputMap @@ -842,6 +843,7 @@ TableHeader.font TableHeader.foreground TableHeader.height TableHeader.separatorColor +TableHeader.showLastVerticalLine TableHeaderUI TableUI TaskPane.background