mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
TableHeader: support top/bottom/left positioned sort arrow when using Glazed Lists (issue #113)
This commit is contained in:
@@ -6,6 +6,8 @@ FlatLaf Change Log
|
|||||||
- Button and ToggleButton: Support disabled background color (use UI values
|
- Button and ToggleButton: Support disabled background color (use UI values
|
||||||
`Button.disabledBackground` and `ToggleButton.disabledBackground`). (issue
|
`Button.disabledBackground` and `ToggleButton.disabledBackground`). (issue
|
||||||
#112)
|
#112)
|
||||||
|
- TableHeader: Support top/bottom/left positioned sort arrow when using
|
||||||
|
[Glazed Lists](https://github.com/glazedlists/glazedlists). (issue #113)
|
||||||
|
|
||||||
|
|
||||||
## 0.36
|
## 0.36
|
||||||
|
|||||||
@@ -86,26 +86,12 @@ public class FlatTableHeaderUI
|
|||||||
case "top": sortIconPosition = SwingConstants.TOP; break;
|
case "top": sortIconPosition = SwingConstants.TOP; break;
|
||||||
case "bottom": sortIconPosition = SwingConstants.BOTTOM; break;
|
case "bottom": sortIconPosition = SwingConstants.BOTTOM; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use own renderer if necessary
|
|
||||||
if( sortIconPosition != SwingConstants.RIGHT ) {
|
|
||||||
TableCellRenderer defaultRenderer = header.getDefaultRenderer();
|
|
||||||
if( defaultRenderer instanceof UIResource )
|
|
||||||
header.setDefaultRenderer( new FlatTableCellHeaderRenderer( defaultRenderer ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void uninstallDefaults() {
|
protected void uninstallDefaults() {
|
||||||
super.uninstallDefaults();
|
super.uninstallDefaults();
|
||||||
|
|
||||||
// restore default renderer
|
|
||||||
TableCellRenderer defaultRenderer = header.getDefaultRenderer();
|
|
||||||
if( defaultRenderer instanceof FlatTableCellHeaderRenderer ) {
|
|
||||||
((FlatTableCellHeaderRenderer)defaultRenderer).reset();
|
|
||||||
header.setDefaultRenderer( ((FlatTableCellHeaderRenderer)defaultRenderer).delegate );
|
|
||||||
}
|
|
||||||
|
|
||||||
separatorColor = null;
|
separatorColor = null;
|
||||||
bottomSeparatorColor = null;
|
bottomSeparatorColor = null;
|
||||||
}
|
}
|
||||||
@@ -125,8 +111,22 @@ public class FlatTableHeaderUI
|
|||||||
if( paintBorders )
|
if( paintBorders )
|
||||||
paintColumnBorders( g, c );
|
paintColumnBorders( g, c );
|
||||||
|
|
||||||
|
// temporary use own default renderer if necessary
|
||||||
|
FlatTableCellHeaderRenderer sortIconRenderer = null;
|
||||||
|
if( sortIconPosition != SwingConstants.RIGHT ) {
|
||||||
|
sortIconRenderer = new FlatTableCellHeaderRenderer( header.getDefaultRenderer() );
|
||||||
|
header.setDefaultRenderer( sortIconRenderer );
|
||||||
|
}
|
||||||
|
|
||||||
|
// paint header
|
||||||
super.paint( g, c );
|
super.paint( g, c );
|
||||||
|
|
||||||
|
// restore default renderer
|
||||||
|
if( sortIconRenderer != null ) {
|
||||||
|
sortIconRenderer.reset();
|
||||||
|
header.setDefaultRenderer( sortIconRenderer.delegate );
|
||||||
|
}
|
||||||
|
|
||||||
if( paintBorders )
|
if( paintBorders )
|
||||||
paintDraggedColumnBorders( g, c );
|
paintDraggedColumnBorders( g, c );
|
||||||
}
|
}
|
||||||
@@ -257,6 +257,7 @@ public class FlatTableHeaderUI
|
|||||||
{
|
{
|
||||||
private final TableCellRenderer delegate;
|
private final TableCellRenderer delegate;
|
||||||
|
|
||||||
|
private JLabel l;
|
||||||
private int oldHorizontalTextPosition = -1;
|
private int oldHorizontalTextPosition = -1;
|
||||||
private Border origBorder;
|
private Border origBorder;
|
||||||
private Icon sortIcon;
|
private Icon sortIcon;
|
||||||
@@ -273,7 +274,7 @@ public class FlatTableHeaderUI
|
|||||||
if( !(c instanceof JLabel) )
|
if( !(c instanceof JLabel) )
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
JLabel l = (JLabel) c;
|
l = (JLabel) c;
|
||||||
|
|
||||||
if( sortIconPosition == SwingConstants.LEFT ) {
|
if( sortIconPosition == SwingConstants.LEFT ) {
|
||||||
if( oldHorizontalTextPosition < 0 )
|
if( oldHorizontalTextPosition < 0 )
|
||||||
@@ -291,11 +292,8 @@ public class FlatTableHeaderUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
if( sortIconPosition == SwingConstants.LEFT && oldHorizontalTextPosition >= 0 ) {
|
if( l != null && sortIconPosition == SwingConstants.LEFT && oldHorizontalTextPosition >= 0 )
|
||||||
Component c = getTableCellRendererComponent( header.getTable(), "", false, false, -1, 0 );
|
l.setHorizontalTextPosition( oldHorizontalTextPosition );
|
||||||
if( c instanceof JLabel && ((JLabel)c).getHorizontalTextPosition() == SwingConstants.RIGHT )
|
|
||||||
((JLabel)c).setHorizontalTextPosition( oldHorizontalTextPosition );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user