|
|
@ -23,6 +23,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package com.github.weisj.darklaf.ui.table; |
|
|
|
package com.github.weisj.darklaf.ui.table; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.weisj.darklaf.components.OverlayScrollPane; |
|
|
|
import com.github.weisj.darklaf.util.DarkUIUtil; |
|
|
|
import com.github.weisj.darklaf.util.DarkUIUtil; |
|
|
|
import org.jetbrains.annotations.Contract; |
|
|
|
import org.jetbrains.annotations.Contract; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
@ -170,6 +171,7 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
selectionBackground = UIManager.getColor("Table.selectionNoFocusBackground"); |
|
|
|
selectionBackground = UIManager.getColor("Table.selectionNoFocusBackground"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void paintGrid(@NotNull final Graphics g, |
|
|
|
protected void paintGrid(@NotNull final Graphics g, |
|
|
|
final int rMin, final int rMax, final int cMin, final int cMax) { |
|
|
|
final int rMin, final int rMax, final int cMin, final int cMax) { |
|
|
@ -240,11 +242,9 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected boolean scrollBarVisible() { |
|
|
|
protected boolean scrollBarVisible() { |
|
|
|
Container comp = SwingUtilities.getUnwrappedParent(table); |
|
|
|
JScrollPane comp = DarkUIUtil.getParentOfType(JScrollPane.class, table); |
|
|
|
if (comp != null) { |
|
|
|
return comp != null && comp.getVerticalScrollBar().isVisible() |
|
|
|
comp = comp.getParent(); |
|
|
|
&& DarkUIUtil.getParentOfType(OverlayScrollPane.class, table) == null; |
|
|
|
} |
|
|
|
|
|
|
|
return comp instanceof JScrollPane && ((JScrollPane) comp).getVerticalScrollBar().isVisible(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected boolean showVerticalLine(final boolean ltr, final boolean scrollVisible, |
|
|
|
protected boolean showVerticalLine(final boolean ltr, final boolean scrollVisible, |
|
|
@ -336,16 +336,14 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (table.isEditing() && table.getEditingRow() == row && |
|
|
|
if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { |
|
|
|
table.getEditingColumn() == column) { |
|
|
|
|
|
|
|
Component component = table.getEditorComponent(); |
|
|
|
Component component = table.getEditorComponent(); |
|
|
|
component.setBounds(cellRect); |
|
|
|
component.setBounds(r); |
|
|
|
component.validate(); |
|
|
|
component.validate(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
TableCellRenderer renderer = table.getCellRenderer(row, column); |
|
|
|
TableCellRenderer renderer = table.getCellRenderer(row, column); |
|
|
|
Component component = table.prepareRenderer(renderer, row, column); |
|
|
|
Component component = table.prepareRenderer(renderer, row, column); |
|
|
|
rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, |
|
|
|
rendererPane.paintComponent(g, component, table, r.x, r.y, r.width, r.height, true); |
|
|
|
cellRect.width, cellRect.height, true); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -370,31 +368,28 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
parent = par.getParent(); |
|
|
|
parent = par.getParent(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int tableHeight = getPreferredSize(table).height; |
|
|
|
g.setColor(parent.getBackground()); |
|
|
|
g.setColor(parent.getBackground()); |
|
|
|
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, |
|
|
|
g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width - 1, tableHeight); |
|
|
|
vacatedColumnRect.width - 1, vacatedColumnRect.height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move to the where the cell has been dragged.
|
|
|
|
// Move to the where the cell has been dragged.
|
|
|
|
vacatedColumnRect.x += dist; |
|
|
|
vacatedColumnRect.x += dist; |
|
|
|
|
|
|
|
|
|
|
|
boolean scrollVisible = scrollBarVisible(); |
|
|
|
|
|
|
|
boolean drawBottomBorder = !table.getShowHorizontalLines() && !scrollVisible && table.getShowVerticalLines(); |
|
|
|
|
|
|
|
boolean ltr = table.getComponentOrientation().isLeftToRight(); |
|
|
|
boolean ltr = table.getComponentOrientation().isLeftToRight(); |
|
|
|
|
|
|
|
|
|
|
|
// Fill the background.
|
|
|
|
// Fill the background.
|
|
|
|
g.setColor(table.getBackground()); |
|
|
|
g.setColor(table.getBackground()); |
|
|
|
g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, |
|
|
|
g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width, tableHeight); |
|
|
|
vacatedColumnRect.width, vacatedColumnRect.height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Paint the vertical grid lines if necessary.
|
|
|
|
// Paint the vertical grid lines if necessary.
|
|
|
|
if (table.getShowVerticalLines()) { |
|
|
|
if (table.getShowVerticalLines()) { |
|
|
|
g.setColor(table.getGridColor()); |
|
|
|
g.setColor(table.getGridColor()); |
|
|
|
int x1 = vacatedColumnRect.x; |
|
|
|
int x1 = vacatedColumnRect.x; |
|
|
|
int y1 = vacatedColumnRect.y; |
|
|
|
int y1 = 0; |
|
|
|
int x2 = x1 + vacatedColumnRect.width - 1; |
|
|
|
int x2 = x1 + vacatedColumnRect.width - 1; |
|
|
|
int y2 = y1 + vacatedColumnRect.height - 1; |
|
|
|
int y2 = y1 + tableHeight; |
|
|
|
|
|
|
|
|
|
|
|
boolean onLeftEdge = ltr ? draggedColumnIndex == cMin : draggedColumnIndex == cMax; |
|
|
|
boolean onLeftEdge = ltr ? draggedColumnIndex == cMin : draggedColumnIndex == cMax; |
|
|
|
boolean onRightEdge = ltr ? draggedColumnIndex == cMax : draggedColumnIndex == cMin; |
|
|
|
boolean onRightEdge = ltr ? draggedColumnIndex == cMax : draggedColumnIndex == cMin; |
|
|
@ -423,13 +418,13 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
paintCell(g, r, row, draggedColumnIndex); |
|
|
|
paintCell(g, r, row, draggedColumnIndex); |
|
|
|
|
|
|
|
|
|
|
|
// Paint the (lower) horizontal grid line if necessary.
|
|
|
|
// Paint the (lower) horizontal grid line if necessary.
|
|
|
|
if (table.getShowHorizontalLines() || (!scrollVisible && row == rMax)) { |
|
|
|
if (table.getShowHorizontalLines()) { |
|
|
|
g.setColor(table.getGridColor()); |
|
|
|
g.setColor(table.getGridColor()); |
|
|
|
Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true); |
|
|
|
Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true); |
|
|
|
rcr.x += dist; |
|
|
|
rcr.x += distance; |
|
|
|
int x1 = rcr.x - 1; |
|
|
|
int x1 = rcr.x; |
|
|
|
int y1 = rcr.y; |
|
|
|
int y1 = rcr.y; |
|
|
|
int x2 = x1 + rcr.width + 1; |
|
|
|
int x2 = x1 + rcr.width; |
|
|
|
int y2 = y1 + rcr.height - 1; |
|
|
|
int y2 = y1 + rcr.height - 1; |
|
|
|
g.fillRect(x1, y2, x2 - x1, 1); |
|
|
|
g.fillRect(x1, y2, x2 - x1, 1); |
|
|
|
} |
|
|
|
} |
|
|
@ -482,6 +477,14 @@ public class DarkTableUI extends DarkTableUIBridge { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mousePressed(final MouseEvent e) { |
|
|
|
|
|
|
|
super.mousePressed(e); |
|
|
|
|
|
|
|
if (SwingUtilities.isLeftMouseButton(e)) { |
|
|
|
|
|
|
|
table.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected JFileChooser getFileChooser() { |
|
|
|
protected JFileChooser getFileChooser() { |
|
|
|
var obj = table.getClientProperty("JTable.fileChooserParent"); |
|
|
|
var obj = table.getClientProperty("JTable.fileChooserParent"); |
|
|
|
if (obj instanceof Supplier) { |
|
|
|
if (obj instanceof Supplier) { |
|
|
|