mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
Table: hide grid and changed intercell spacing to zero
This commit is contained in:
@@ -7,6 +7,7 @@ FlatLaf Change Log
|
|||||||
"IntelliJ Light Theme", which provides blue coloring that better match
|
"IntelliJ Light Theme", which provides blue coloring that better match
|
||||||
platform colors.
|
platform colors.
|
||||||
- Tree: Support wide selection (enabled by default).
|
- Tree: Support wide selection (enabled by default).
|
||||||
|
- Table: Hide grid and changed intercell spacing to zero.
|
||||||
- List and Tree: Paint cell focus indicator (black rectangle) only if more than
|
- List and Tree: Paint cell focus indicator (black rectangle) only if more than
|
||||||
one item is selected.
|
one item is selected.
|
||||||
- Fixed link color (in HTML text) and separator color in IntelliJ platform
|
- Fixed link color (in HTML text) and separator color in IntelliJ platform
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ class UIDefaultsLoader
|
|||||||
return resolveValue( properties, newValue );
|
return resolveValue( properties, newValue );
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ValueType { UNKNOWN, STRING, INTEGER, BORDER, ICON, INSETS, SIZE, COLOR, SCALEDINTEGER, INSTANCE, CLASS }
|
private enum ValueType { UNKNOWN, STRING, INTEGER, BORDER, ICON, INSETS, DIMENSION, COLOR, SCALEDINTEGER, INSTANCE, CLASS }
|
||||||
|
|
||||||
static Object parseValue( String key, String value ) {
|
static Object parseValue( String key, String value ) {
|
||||||
return parseValue( key, value, v -> v, Collections.emptyList() );
|
return parseValue( key, value, v -> v, Collections.emptyList() );
|
||||||
@@ -251,7 +251,7 @@ class UIDefaultsLoader
|
|||||||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
||||||
valueType = ValueType.INSETS;
|
valueType = ValueType.INSETS;
|
||||||
else if( key.endsWith( "Size" ) )
|
else if( key.endsWith( "Size" ) )
|
||||||
valueType = ValueType.SIZE;
|
valueType = ValueType.DIMENSION;
|
||||||
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||||
valueType = ValueType.INTEGER;
|
valueType = ValueType.INTEGER;
|
||||||
else if( key.endsWith( "UI" ) )
|
else if( key.endsWith( "UI" ) )
|
||||||
@@ -265,7 +265,7 @@ class UIDefaultsLoader
|
|||||||
case BORDER: return parseBorder( value, resolver, addonClassLoaders );
|
case BORDER: return parseBorder( value, resolver, addonClassLoaders );
|
||||||
case ICON: return parseInstance( value, addonClassLoaders );
|
case ICON: return parseInstance( value, addonClassLoaders );
|
||||||
case INSETS: return parseInsets( value );
|
case INSETS: return parseInsets( value );
|
||||||
case SIZE: return parseSize( value );
|
case DIMENSION: return parseDimension( value );
|
||||||
case COLOR: return parseColorOrFunction( value, true );
|
case COLOR: return parseColorOrFunction( value, true );
|
||||||
case SCALEDINTEGER: return parseScaledInteger( value );
|
case SCALEDINTEGER: return parseScaledInteger( value );
|
||||||
case INSTANCE: return parseInstance( value, addonClassLoaders );
|
case INSTANCE: return parseInstance( value, addonClassLoaders );
|
||||||
@@ -358,7 +358,7 @@ class UIDefaultsLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dimension parseSize( String value ) {
|
private static Dimension parseDimension( String value ) {
|
||||||
List<String> numbers = StringUtils.split( value, ',' );
|
List<String> numbers = StringUtils.split( value, ',' );
|
||||||
try {
|
try {
|
||||||
return new DimensionUIResource(
|
return new DimensionUIResource(
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -55,6 +56,8 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* <!-- FlatTableUI -->
|
* <!-- FlatTableUI -->
|
||||||
*
|
*
|
||||||
* @uiDefault Table.rowHeight int
|
* @uiDefault Table.rowHeight int
|
||||||
|
* @uiDefault Table.showGrid boolean
|
||||||
|
* @uiDefault Table.intercellSpacing Dimension
|
||||||
* @uiDefault Table.selectionInactiveBackground Color
|
* @uiDefault Table.selectionInactiveBackground Color
|
||||||
* @uiDefault Table.selectionInactiveForeground Color
|
* @uiDefault Table.selectionInactiveForeground Color
|
||||||
*
|
*
|
||||||
@@ -63,19 +66,39 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public class FlatTableUI
|
public class FlatTableUI
|
||||||
extends BasicTableUI
|
extends BasicTableUI
|
||||||
{
|
{
|
||||||
|
protected boolean showGrid;
|
||||||
|
protected Dimension intercellSpacing;
|
||||||
|
|
||||||
protected Color selectionBackground;
|
protected Color selectionBackground;
|
||||||
protected Color selectionForeground;
|
protected Color selectionForeground;
|
||||||
protected Color selectionInactiveBackground;
|
protected Color selectionInactiveBackground;
|
||||||
protected Color selectionInactiveForeground;
|
protected Color selectionInactiveForeground;
|
||||||
|
|
||||||
|
private boolean oldShowHorizontalLines;
|
||||||
|
private boolean oldShowVerticalLines;
|
||||||
|
private Dimension oldIntercellSpacing;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatTableUI();
|
return new FlatTableUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void installUI( JComponent c ) {
|
||||||
|
super.installUI( c );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninstallUI( JComponent c ) {
|
||||||
|
super.uninstallUI( c );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
|
showGrid = UIManager.getBoolean( "Table.showGrid" );
|
||||||
|
intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" );
|
||||||
|
|
||||||
selectionBackground = UIManager.getColor( "Table.selectionBackground" );
|
selectionBackground = UIManager.getColor( "Table.selectionBackground" );
|
||||||
selectionForeground = UIManager.getColor( "Table.selectionForeground" );
|
selectionForeground = UIManager.getColor( "Table.selectionForeground" );
|
||||||
selectionInactiveBackground = UIManager.getColor( "Table.selectionInactiveBackground" );
|
selectionInactiveBackground = UIManager.getColor( "Table.selectionInactiveBackground" );
|
||||||
@@ -86,6 +109,17 @@ public class FlatTableUI
|
|||||||
int rowHeight = FlatUIUtils.getUIInt( "Table.rowHeight", 16 );
|
int rowHeight = FlatUIUtils.getUIInt( "Table.rowHeight", 16 );
|
||||||
if( rowHeight > 0 )
|
if( rowHeight > 0 )
|
||||||
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
|
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
|
||||||
|
|
||||||
|
if( !showGrid ) {
|
||||||
|
oldShowHorizontalLines = table.getShowHorizontalLines();
|
||||||
|
oldShowVerticalLines = table.getShowVerticalLines();
|
||||||
|
table.setShowGrid( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( intercellSpacing != null ) {
|
||||||
|
oldIntercellSpacing = table.getIntercellSpacing();
|
||||||
|
table.setIntercellSpacing( intercellSpacing );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,6 +130,20 @@ public class FlatTableUI
|
|||||||
selectionForeground = null;
|
selectionForeground = null;
|
||||||
selectionInactiveBackground = null;
|
selectionInactiveBackground = null;
|
||||||
selectionInactiveForeground = null;
|
selectionInactiveForeground = null;
|
||||||
|
|
||||||
|
// restore old show grid
|
||||||
|
if( !showGrid ) {
|
||||||
|
if( !table.getShowHorizontalLines() )
|
||||||
|
table.setShowHorizontalLines( oldShowHorizontalLines );
|
||||||
|
if( !table.getShowVerticalLines() )
|
||||||
|
table.setShowVerticalLines( oldShowVerticalLines );
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore old intercell spacing
|
||||||
|
if( intercellSpacing != null ) {
|
||||||
|
if( table.getIntercellSpacing().equals( intercellSpacing ) )
|
||||||
|
table.setIntercellSpacing( oldIntercellSpacing );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -366,6 +366,8 @@ TabbedPane.shadow=@@ComboBox.buttonArrowColor
|
|||||||
#---- Table ----
|
#---- Table ----
|
||||||
|
|
||||||
Table.rowHeight=20
|
Table.rowHeight=20
|
||||||
|
Table.showGrid=false
|
||||||
|
Table.intercellSpacing={dimension}0,0
|
||||||
Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder
|
Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder
|
||||||
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
|
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
|
||||||
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
|
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user