From 6bab2af14d9bf165787365a1252cf73fc1e4ef89 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 8 Sep 2020 01:04:52 +0200 Subject: [PATCH] Ensure cell backgrounds are consistent between editor and renderer. Add undo/redo icons. Add disabled delete icon. --- .../treetable/TreeTableModelAdapter.java | 5 --- .../treetable/TreeTableSelectionModel.java | 30 ----------------- .../weisj/darklaf/ui/cell/CellUtil.java | 13 ++------ .../ui/cell/DarkCellRendererToggleButton.java | 3 ++ .../ui/combobox/ComboBoxConstants.java | 2 -- .../renderer/DarkTableCellEditorDelegate.java | 2 +- .../DarkTableCellEditorToggleButton.java | 4 +-- .../DarkTableCellRendererDelegate.java | 12 ++++--- .../DarkHighlightPainter.java | 33 +++++++++++-------- .../darklaf/icons/menu/deleteDisabled.svg | 11 +++++++ .../github/weisj/darklaf/icons/menu/redo.svg | 10 ++++++ .../weisj/darklaf/icons/menu/redoDisabled.svg | 10 ++++++ .../github/weisj/darklaf/icons/menu/undo.svg | 10 ++++++ .../weisj/darklaf/icons/menu/undoDisabled.svg | 10 ++++++ .../darklaf/properties/icons/menu.properties | 4 +++ .../darklaf/properties/ui/table.properties | 1 + core/src/test/java/util/ClassFinder.java | 2 +- 17 files changed, 93 insertions(+), 69 deletions(-) delete mode 100644 core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg create mode 100644 core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg diff --git a/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java b/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java index 4821bc54..cdc3ac31 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableModelAdapter.java @@ -63,11 +63,6 @@ public class TreeTableModelAdapter extends AbstractTableModel { }); } - @Override - public void fireTableRowsDeleted(final int firstRow, final int lastRow) { - super.fireTableRowsDeleted(firstRow, lastRow); - } - public int getColumnCount() { return treeTableModel.getColumnCount(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java b/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java deleted file mode 100644 index 89d811c9..00000000 --- a/core/src/main/java/com/github/weisj/darklaf/components/treetable/TreeTableSelectionModel.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020 Jannis Weis - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ -package com.github.weisj.darklaf.components.treetable; - -import javax.swing.*; -import javax.swing.tree.TreeSelectionModel; - -public interface TreeTableSelectionModel extends TreeSelectionModel, ListSelectionModel {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java index 1362ecee..e03806d8 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java @@ -33,7 +33,6 @@ import javax.swing.tree.DefaultTreeCellRenderer; import com.github.weisj.darklaf.graphics.ColorWrapper; import com.github.weisj.darklaf.ui.list.DarkListUI; import com.github.weisj.darklaf.ui.table.DarkTableUI; -import com.github.weisj.darklaf.ui.table.TableConstants; import com.github.weisj.darklaf.ui.table.renderer.IconWrapper; import com.github.weisj.darklaf.ui.tree.DarkTreeUI; import com.github.weisj.darklaf.util.DarkUIUtil; @@ -251,11 +250,7 @@ public class CellUtil { public static void setupTableForeground(final Component comp, final JTable parent, final boolean selected, final int row) { - boolean sel = selected; - if (parent.getSelectionModel().getLeadSelectionIndex() == row) { - sel = !PropertyUtil.getBooleanProperty(parent, TableConstants.KEY_FULL_ROW_FOCUS_BORDER); - } - setupForeground(comp, parent, sel, + setupForeground(comp, parent, selected, tableCellForeground, tableCellForegroundSelected, tableCellForegroundNoFocus, tableCellForegroundSelectedNoFocus, tableCellInactiveForeground, tableCellInactiveForegroundSelected, @@ -312,11 +307,7 @@ public class CellUtil { final boolean selected, final boolean focus, final int row) { boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(parent, DarkTableUI.KEY_ALTERNATE_ROW_COLOR); - boolean sel = selected; - if (parent.getSelectionModel().getLeadSelectionIndex() == row) { - sel = !PropertyUtil.getBooleanProperty(parent, TableConstants.KEY_FULL_ROW_FOCUS_BORDER); - } - return getColor(comp, focus, sel, + return getColor(comp, focus, selected, alt ? tableCellBackgroundAlternative : tableCellBackground, tableCellBackgroundSelected, alt ? tableCellBackgroundNoFocusAlternative : tableCellBackgroundNoFocus, diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java index 911b5fe5..85cebd2d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java @@ -93,6 +93,7 @@ public class DarkCellRendererToggleButton= c.getSelectionStart(); - boolean hasLineBelow = nextLineStart <= c.getSelectionEnd(); + boolean hasLineAbove = previousLineEnd >= selectionStart; + boolean hasLineBelow = nextLineStart <= selectionEnd; boolean previousLineVisible = hasLineAbove && previousLineRect.width > 0 @@ -301,26 +305,26 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai if (extendLines) { // Adjust the line rects for the adjacent lines for correct rounded corner placement. extendLine(c, ins, previousLineRect, - hasLineAbove && previousLineStart >= c.getSelectionStart(), - hasLineAbove && previousLineEnd <= c.getSelectionEnd()); + hasLineAbove && previousLineStart >= selectionStart, + hasLineAbove && previousLineEnd <= selectionEnd); boolean extendNextRight = hasLineBelow && nextLineEnd < c.getDocument().getLength() - && getOffset(c, getPosRect(c, nextLineEnd + 1)) <= c.getSelectionEnd(); + && getOffset(c, getPosRect(c, nextLineEnd + 1)) <= selectionEnd; extendLine(c, ins, nextLineRect, - hasLineBelow && nextLineStart >= c.getSelectionStart(), + hasLineBelow && nextLineStart >= selectionStart, extendNextRight); paintPreviousLine = hasLineAbove - && (previousLineStart == previousLineEnd || previousLineEnd == c.getSelectionStart()); + && (previousLineStart == previousLineEnd || previousLineEnd == selectionStart); previousLineVisible = hasLineAbove; if (nextLineRect.y != posEnd.y) nextLineVisible = hasLineBelow; boolean extendRight = isPaintingPreceding || (hasLineBelow && (endX(layerRect) == endX(currentLineRect))); - extendRight &= offs1 < c.getSelectionEnd(); + extendRight &= offs1 < selectionEnd; boolean extendLeft = isPaintingPreceding || (hasLineAbove && startX(layerRect) == startX(currentLineRect)); - extendLeft &= offs0 > c.getSelectionStart(); + extendLeft &= offs0 > selectionStart; extendLine(c, ins, layerRect, extendLeft, extendRight); extendLine(c, ins, currentLineRect, extendLeft, extendRight); @@ -344,6 +348,9 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai boolean arcBottomRight = nextLineVisible && !roundedBottomRight && rightArcVisible(currentLineRect, nextLineRect); + System.out.println(selectionStart + " " + selectionEnd); + System.out.println(posOffs0 + " " + posOffs1); + layerRect = paintRoundRect(g, context, layerRect, canRoundLeft && roundedTopLeft, canRoundRight && roundedTopRight, @@ -357,8 +364,8 @@ public class DarkHighlightPainter extends DefaultHighlighter.DefaultHighlightPai if (paintPreviousLine && !isPaintingPreceding) { Rectangle prev = paintRoundedLayer(g, c, - Math.max(previousLineStart, c.getSelectionStart()), - Math.min(previousLineEnd, c.getSelectionEnd()), + Math.max(previousLineStart, selectionStart), + Math.min(previousLineEnd, selectionEnd), context, rounded, extendLines, true); convexHull(r, prev); diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg new file mode 100644 index 00000000..b8416d7b --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/deleteDisabled.svg @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg new file mode 100644 index 00000000..9313b3d4 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redo.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg new file mode 100644 index 00000000..0a5ba5b4 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/redoDisabled.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg new file mode 100644 index 00000000..3d809532 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undo.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg new file mode 100644 index 00000000..ddf37555 --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/icons/menu/undoDisabled.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties index 65512986..5b01656b 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/icons/menu.properties @@ -28,6 +28,10 @@ Icons.copy.color = %menuIconEnabled Icons.copyDisabled.color = %menuIconDisabled Icons.cut.color = %menuIconEnabled Icons.cutDisabled.color = %menuIconDisabled +Icons.undo.color = %menuIconEnabled +Icons.undoDisabled.color = %menuIconDisabled +Icons.redo.color = %menuIconEnabled +Icons.redoDisabled.color = %menuIconDisabled Icons.delete.color = %menuIconEnabled Icons.arrowDownSort.color = %menuIconEnabled Icons.groupBy.color = %menuIconEnabled diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties index 15994c63..373fdaeb 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties @@ -41,6 +41,7 @@ Table.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.table.D Table.cellEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder Table.scrollPaneBorder = com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder Table.border = com.github.weisj.darklaf.ui.table.DarkTableBorder +Table.booleanEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder Table.focusBorderColor = %borderFocus Table.focusRowBorderColor = %borderFocus Table.gridColor = %gridLine diff --git a/core/src/test/java/util/ClassFinder.java b/core/src/test/java/util/ClassFinder.java index d65fb825..56c95fad 100644 --- a/core/src/test/java/util/ClassFinder.java +++ b/core/src/test/java/util/ClassFinder.java @@ -43,7 +43,7 @@ public class ClassFinder { .filter(type::isAssignableFrom) .filter(cls -> !cls.isInterface()) .filter(cls -> !Modifier.isAbstract(cls.getModifiers())) - .map(cls -> (Class)cls) + .map(cls -> (Class) cls) .map(ClassFinder::getInstance) .filter(Objects::nonNull) .map(type::cast)