diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/BorderWrapper.java b/core/src/main/java/com/github/weisj/darklaf/components/border/BorderWrapper.java new file mode 100644 index 000000000..3b25d60c9 --- /dev/null +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/BorderWrapper.java @@ -0,0 +1,54 @@ +/* + * 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.border; + +import java.awt.*; + +import javax.swing.border.Border; + +public class BorderWrapper implements Border { + + private final Border border; + + public BorderWrapper(final Border border) { + this.border = border; + } + + @Override + public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, + final int height) { + border.paintBorder(c, g, x, y, width, height); + } + + @Override + public Insets getBorderInsets(final Component c) { + return border.getBorderInsets(c); + } + + @Override + public boolean isBorderOpaque() { + return border.isBorderOpaque(); + } +} diff --git a/core/src/main/java/com/github/weisj/darklaf/components/border/MarginBorderWrapper.java b/core/src/main/java/com/github/weisj/darklaf/components/border/MarginBorderWrapper.java index 51fd26097..8aa2407b4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/components/border/MarginBorderWrapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/components/border/MarginBorderWrapper.java @@ -30,7 +30,7 @@ import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicBorders; -public class MarginBorderWrapper extends CompoundBorder implements UIResource { +public class MarginBorderWrapper extends CompoundBorder { public MarginBorderWrapper(final Border border) { super(border, new BasicBorders.MarginBorder()); @@ -39,7 +39,15 @@ public MarginBorderWrapper(final Border border) { public static void installBorder(final JComponent c) { Border border = c.getBorder(); if (!(border instanceof MarginBorderWrapper)) { - c.setBorder(new MarginBorderWrapper(border)); + c.setBorder(wrapBorder(border)); + } + } + + private static MarginBorderWrapper wrapBorder(final Border border) { + if (border instanceof UIResource) { + return new MarginBorderWrapper.UIBorder(border); + } else { + return new MarginBorderWrapper(border); } } @@ -57,4 +65,11 @@ public static Border getBorder(final JComponent c) { } return border; } + + public static class UIBorder extends MarginBorderWrapper implements UIResource { + + public UIBorder(final Border border) { + super(border); + } + } } 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 9760f24ae..53c1ec62a 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,6 +33,7 @@ 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; @@ -248,8 +249,13 @@ public static void updateColors(final UIDefaults defaults) { listCellInactiveBackgroundSelectedNoFocus = d.getColor("List.inactiveBackgroundSelectedNoFocus"); } - public static void setupTableForeground(final Component comp, final JTable parent, final boolean selected) { - setupForeground(comp, parent, selected, + 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, tableCellForeground, tableCellForegroundSelected, tableCellForegroundNoFocus, tableCellForegroundSelectedNoFocus, tableCellInactiveForeground, tableCellInactiveForegroundSelected, @@ -305,7 +311,11 @@ public static void setupForeground(final Component comp, final JComponent parent public static Color getTableBackground(final Component comp, final JTable parent, final boolean selected, final int row) { boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(parent, DarkTableUI.KEY_ALTERNATE_ROW_COLOR); - return getColor(comp, hasFocus(parent, comp), selected, + boolean sel = selected; + if (parent.getSelectionModel().getLeadSelectionIndex() == row) { + sel = !PropertyUtil.getBooleanProperty(parent, TableConstants.KEY_FULL_ROW_FOCUS_BORDER); + } + return getColor(comp, hasFocus(parent, comp), sel, alt ? tableCellBackgroundAlternative : tableCellBackground, tableCellBackgroundSelected, alt ? tableCellBackgroundNoFocusAlternative : tableCellBackgroundNoFocus, @@ -500,9 +510,13 @@ public static void paintTableEditorBorder(final Graphics g, final Component c, f if (row > CellUtil.getMinRowIndex(table)) g.fillRect(0, 0, width, 1); g.fillRect(0, height - 1, width, 1); } + boolean isWrapper = isInWrapper(c); + ComponentOrientation orientation = table.getComponentOrientation(); if (!table.getShowVerticalLines()) { - if (col > CellUtil.getMinColumnIndex(table)) g.fillRect(0, 0, 1, height); - if (col < CellUtil.getMaxColumnIndex(table)) g.fillRect(width - 1, 0, 1, height); + if ((isWrapper && orientation.isLeftToRight()) + || col > CellUtil.getMinColumnIndex(table)) g.fillRect(0, 0, 1, height); + if ((isWrapper && orientation.isLeftToRight()) + || col < CellUtil.getMaxColumnIndex(table)) g.fillRect(width - 1, 0, 1, height); } else if (isInWrapper(c)) { if (table.getComponentOrientation().isLeftToRight()) { g.fillRect(0, 0, 1, height); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java index 101dee8b1..e41600fbb 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorder.java @@ -28,12 +28,11 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; -import javax.swing.plaf.UIResource; /** * @author Jannis Weis */ -public class DarkCellBorder extends EmptyBorder implements UIResource { +public class DarkCellBorder extends EmptyBorder { public DarkCellBorder() { this(UIManager.getInsets("Cell.borderInsets")); diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorderUIResource.java b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorderUIResource.java new file mode 100644 index 000000000..f795e10e0 --- /dev/null +++ b/core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellBorderUIResource.java @@ -0,0 +1,42 @@ +/* + * 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.ui.cell; + +import java.awt.*; + +import javax.swing.*; +import javax.swing.plaf.UIResource; + +/** + * @author Jannis Weis + */ +public class DarkCellBorderUIResource extends DarkCellBorder implements UIResource { + + public DarkCellBorderUIResource() {} + + public DarkCellBorderUIResource(final Insets insets) { + super(insets); + } +} 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 9aef8ce34..0800cc574 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 @@ -43,7 +43,7 @@ public class DarkCellRendererToggleButton) this::getFileChooser); + detailsTable.putClientProperty(DarkTableUI.KEY_FULL_ROW_FOCUS_BORDER, true); + detailsTable.putClientProperty(DarkTableUI.KEY_FILE_CHOOSER_PARENT, + (Supplier) this::getFileChooser); detailsTable.putClientProperty("JTable.fileNameColumnIndex", COLUMN_FILENAME); Font font = list.getFont(); @@ -284,13 +306,6 @@ protected void editFileName(final int index) { case VIEWTYPE_LIST : editFile = (File) getModel().getElementAt(getRowSorter().convertRowIndexToModel(index)); Rectangle r = list.getCellBounds(index, index); - if (editCell == null) { - editCell = new JTextField(); - editCell.setName("Tree.cellEditor"); - editCell.addActionListener(new EditActionListener()); - editCell.addFocusListener(editorFocusListener); - editCell.setNextFocusableComponent(list); - } list.add(editCell); editCell.setText(chooser.getName(editFile)); ComponentOrientation orientation = list.getComponentOrientation(); @@ -490,4 +505,35 @@ public Component getListCellRendererComponent(final JList list, final Object return comp; } } + + protected TableCellEditor getDetailsTableCellEditor() { + if (tableCellEditor == null) { + tableCellEditor = new DarkTableCellEditorDelegate(new DetailsTableCellEditor()); + } + return tableCellEditor; + } + + protected class DetailsTableCellEditor extends DarkTableCellEditor { + + public DetailsTableCellEditor() { + editorComponent.addFocusListener(editorFocusListener); + editorComponent.addAncestorListener(new AncestorAdapter() { + @Override + public void ancestorAdded(final AncestorEvent event) { + SwingUtilities.invokeLater(() -> { + editorComponent.requestFocus(); + ((JTextComponent) editorComponent).selectAll(); + }); + } + }); + } + + public Component getTableCellEditorComponent(final JTable table, final Object value, + final boolean isSelected, final int row, final int column) { + Object realValue = value instanceof File + ? getFileChooser().getName((File) value) + : value; + return super.getTableCellEditorComponent(table, realValue, isSelected, row, column); + } + } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java index 1f41a7f45..b5e7e485d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java @@ -47,8 +47,6 @@ import sun.awt.shell.ShellFolderColumnInfo; import sun.swing.FilePane; -import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; -import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellEditor; import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellRenderer; import com.github.weisj.darklaf.util.PropertyKey; @@ -269,7 +267,6 @@ protected int getNextMatch(final int startIndex, final int finishIndex) { return -1; } }; - protected DetailsTableCellEditor tableCellEditor; protected Action newFolderAction; protected Handler handler; int lastIndex = -1; @@ -277,8 +274,9 @@ protected int getNextMatch(final int startIndex, final int finishIndex) { JTextField editCell = null; protected final FocusListener editorFocusListener = new FocusAdapter() { public void focusLost(final FocusEvent e) { + // Todo if (!e.isTemporary()) { - applyEdit(); + // applyEdit(); } } }; @@ -627,19 +625,7 @@ protected void updateDetailsColumnModel(final JTable table) { } } - protected DetailsTableCellEditor getDetailsTableCellEditor() { - if (tableCellEditor == null) { - tableCellEditor = new DetailsTableCellEditor(new JTextField() { - { - super.setBorder(new TextTableCellEditorBorder()); - } - - @Override - public void setBorder(final Border border) {} - }); - } - return tableCellEditor; - } + protected abstract TableCellEditor getDetailsTableCellEditor(); public abstract JPanel createDetailsView(); @@ -1398,30 +1384,6 @@ public int compare(final File f1, final File f2) { } } - protected class DetailsTableCellEditor extends DarkTableCellEditor { - public DetailsTableCellEditor(final JTextField tf) { - super(tf); - tf.addFocusListener(editorFocusListener); - } - - public Component getTableCellEditorComponent(final JTable table, final Object value, - final boolean isSelected, final int row, final int column) { - Component comp = super.getTableCellEditorComponent(table, value, - isSelected, row, column); - if (value instanceof File) { - delegate.setValue(getFileChooser().getName((File) value)); - } - if (editorComponent instanceof JTextField) { - SwingUtilities.invokeLater(() -> { - ((JTextField) editorComponent).selectAll(); - editorComponent.requestFocus(); - }); - } - - return comp; - } - } - @SuppressWarnings("serial") // JDK-implementation class public class DetailsTableCellRenderer extends DarkTableCellRenderer { @@ -1551,7 +1513,7 @@ public void run() { } } - class EditActionListener implements ActionListener { + protected class EditActionListener implements ActionListener { public void actionPerformed(final ActionEvent e) { applyEdit(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java index 71565fa70..29572b85e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellBorder.java @@ -24,9 +24,9 @@ */ package com.github.weisj.darklaf.ui.list; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.ui.cell.DarkCellBorderUIResource; /** * @author Jannis Weis */ -public class DarkListCellBorder extends DarkCellBorder {} +public class DarkListCellBorder extends DarkCellBorderUIResource {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java index e6cbf5111..bb66db56a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellFocusBorder.java @@ -29,9 +29,9 @@ import javax.swing.*; import com.github.weisj.darklaf.graphics.PaintUtil; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.ui.cell.DarkCellBorderUIResource; -public class DarkListCellFocusBorder extends DarkCellBorder { +public class DarkListCellFocusBorder extends DarkCellBorderUIResource { protected final Color borderColor; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java index 836250643..5a174e737 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellBorder.java @@ -24,9 +24,9 @@ */ package com.github.weisj.darklaf.ui.table; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.ui.cell.DarkCellBorderUIResource; /** * @author Jannis Weis */ -public class DarkTableCellBorder extends DarkCellBorder {} +public class DarkTableCellBorder extends DarkCellBorderUIResource {} diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java index 936d373f0..7ac2f6664 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellFocusBorder.java @@ -29,13 +29,13 @@ import javax.swing.*; import com.github.weisj.darklaf.graphics.PaintUtil; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.ui.cell.DarkCellBorderUIResource; import com.github.weisj.darklaf.util.PropertyUtil; /** * @author Jannis Weis */ -public class DarkTableCellFocusBorder extends DarkCellBorder { +public class DarkTableCellFocusBorder extends DarkCellBorderUIResource { protected final Color rowBorderColor; protected final Color borderColor; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index be7531a0f..2d218fe25 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -415,7 +415,7 @@ protected void paintCell(final Graphics g, final Rectangle r, final int row, fin } } if (isEditorCell) { - Component component = getCellEditorComponent(); + Component component = table.getEditorComponent(); component.setBounds(x, y, w, h); component.validate(); } else { @@ -436,18 +436,6 @@ protected TableCellRenderer getCellRenderer(final int row, final int column) { return rendererDelegate; } - public Component getCellEditorComponent() { - Component c = table.getEditorComponent(); - if (!(table.getCellEditor() instanceof DarkTableCellEditorDelegate)) { - int row = table.getEditingRow(); - int column = table.getEditingColumn(); - Object value = table.getValueAt(row, column); - c = DarkTableCellEditorDelegate.prepareEditor(c, table, value, - table.isCellSelected(row, column), row, column); - } - return c; - } - public static int adjustDistance(final int distance, final Rectangle rect, final JTable comp) { int dist = distance; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java index 0df0c8b81..d8e30cfc7 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableCellContainer.java @@ -44,7 +44,7 @@ public TableCellContainer(final JTable table, final DarkTableUI ui) { @Override public Rectangle getCellBoundsAt(final Pair position, final boolean isEditing) { return isEditing - ? ui.getCellEditorComponent().getBounds() + ? table.getEditorComponent().getBounds() : table.getCellRect(position.getFirst(), position.getSecond(), false); } @@ -90,6 +90,6 @@ public Component getCellRendererComponent(final Pair position) @Override public Component getCellEditorComponent(final Pair position) { - return ui.getCellEditorComponent(); + return table.getEditorComponent(); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java index bedb4c43c..aa4be2318 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TextTableCellEditorBorder.java @@ -27,17 +27,20 @@ import java.awt.*; import javax.swing.*; +import javax.swing.border.Border; import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.ui.cell.CellUtil; +import com.github.weisj.darklaf.ui.cell.DarkCellBorder; import com.github.weisj.darklaf.util.DarkUIUtil; /** * @author Jannis Weis */ -public class TextTableCellEditorBorder extends DarkTableCellBorder { +public class TextTableCellEditorBorder extends DarkCellBorder { protected final Color borderColor; + private final Border base = new DarkTableCellBorder(); public TextTableCellEditorBorder() { borderColor = UIManager.getColor("TextField.border.enabled"); @@ -56,11 +59,11 @@ public void paintBorder(final Component c, final Graphics g, final int x, final } private JTable getTable(final Component c) { - return DarkUIUtil.getParentOfType(JTable.class, c, 2); + return DarkUIUtil.getParentOfType(JTable.class, c, 3); } @Override public Insets getBorderInsets(final Component c) { - return CellUtil.adjustEditorInsets(super.getBorderInsets(), c, getTable(c)); + return CellUtil.adjustEditorInsets(base.getBorderInsets(c), c, getTable(c)); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java index 626488591..2fd00dbba 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java @@ -44,8 +44,6 @@ import com.github.weisj.darklaf.util.PropertyValue; /** - * @author vincencopalazzo - * @author atarw * @author Jannis Weis */ public class DarkTableCellEditor extends DefaultCellEditor { diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java index f6802e097..db283af19 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorDelegate.java @@ -70,7 +70,7 @@ public Object getCellEditorValue() { @Override public boolean isCellEditable(final EventObject anEvent) { - if (anEvent == null) return super.isCellEditable(anEvent); + if (anEvent == null) return super.isCellEditable(null); JTable table = ((JTable) anEvent.getSource()); if (anEvent instanceof KeyEvent) { if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent, table)) return false; @@ -119,7 +119,7 @@ public static Component prepareEditor(final Component editor, final JTable table .getTableCellRendererComponent(table, value, isSelected, false, row, column); setupEditorComponent(editor, value, renderer); Component comp = applyRendererIcon(editor, renderer); - CellUtil.setupTableBackground(editor, table, false, row); + CellUtil.setupTableBackground(comp, table, false, row); return comp; } @@ -146,13 +146,13 @@ protected static int getHorizontalAlignment(final Component rendererComp) { return -1; } - protected static Component applyRendererIcon(final Component component, final Component rendererComp) { - Component comp = component; - if (rendererComp instanceof JLabel && comp instanceof JComponent) { - Icon icon = ((JLabel) rendererComp).getIcon(); + protected static Component applyRendererIcon(final Component editorComponent, final Component rendererComponent) { + Component comp = editorComponent; + if (rendererComponent instanceof JLabel && comp instanceof JComponent) { + Icon icon = ((JLabel) rendererComponent).getIcon(); if (icon != null) { - iconWrapper.init((JComponent) comp, icon, rendererComp.getComponentOrientation().isLeftToRight()); - iconWrapper.setIconGap(((JLabel) rendererComp).getIconTextGap() - 1); + iconWrapper.init((JComponent) comp, icon, rendererComponent.getComponentOrientation()); + iconWrapper.setIconGap(((JLabel) rendererComponent).getIconTextGap() - 1); comp = iconWrapper; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java index 1cd1ed5d8..5085e7c28 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRendererDelegate.java @@ -60,13 +60,14 @@ public Component getTableCellRendererComponent(final JTable table, final Object Component component = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); boolean isRowFocus = DarkTableCellFocusBorder.isRowFocusBorder(table); - boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) && hasFocus && !isRowFocus; + boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) + && table.getSelectionModel().getLeadSelectionIndex() == row; boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing(); if (component instanceof JComponent) { setupBorderStyle(table, row, column, (JComponent) component, isLeadSelectionCell, isRowFocus); } - CellUtil.setupTableForeground(component, table, paintSelected); + CellUtil.setupTableForeground(component, table, paintSelected, row); CellUtil.setupTableBackground(component, table, paintSelected, row); return component; } @@ -75,10 +76,7 @@ public void setupBorderStyle(final JTable table, final int row, final int column final JComponent component, final boolean isLeadSelectionCell, final boolean isRowFocus) { Border focusBorder = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); - if (isLeadSelectionCell - && table.getSelectionModel().getLeadSelectionIndex() == row - && DarkUIUtil.hasFocus(table) - && !table.isEditing()) { + if (isLeadSelectionCell && !table.isEditing()) { PropertyUtil.installBorder(component, focusBorder); if (isRowFocus) { component.putClientProperty(KEY_FULL_ROW_FOCUS_BORDER, true); @@ -97,7 +95,7 @@ public void setupBorderStyle(final JTable table, final int row, final int column component.putClientProperty(KEY_FULL_ROW_FOCUS_BORDER, false); } } else if (component.getBorder() == focusBorder) { - component.setBorder(null); + component.setBorder(UIManager.getBorder("Table.cellNoFocusBorder")); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java index 3e47f0905..b5e0404bd 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/IconWrapper.java @@ -36,7 +36,7 @@ public class IconWrapper extends JPanel { private int iconGap; protected IconWrapper() { - setLayout(null); + setLayout(new BorderLayout()); label = new JLabel(); label.setIconTextGap(0); add(label); @@ -46,12 +46,14 @@ protected void setIconGap(final int iconGap) { this.iconGap = iconGap; } - protected void init(final JComponent component, final Icon icon, final boolean ltr) { - setComponentOrientation(ltr ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT); + protected void init(final JComponent component, final Icon icon, final ComponentOrientation orientation) { + setComponentOrientation(orientation); if (c != null) { remove(c); } add(component); + setComponentZOrder(component, 0); + setComponentZOrder(label, 1); this.c = component; label.setIcon(icon); } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 73a509525..d905d394b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -166,10 +166,10 @@ protected DefaultTextRenderer createDefaultTextRenderer() { @Override protected void uninstallDefaults() { - super.uninstallDefaults(); uninstalling = true; uninstallBorder(); uninstallPopupMenu(); + super.uninstallDefaults(); } @Override diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java index 9d323e1b1..220344c3a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellBorder.java @@ -31,12 +31,12 @@ import javax.swing.plaf.UIResource; import com.github.weisj.darklaf.graphics.PaintUtil; -import com.github.weisj.darklaf.ui.cell.DarkCellBorder; +import com.github.weisj.darklaf.ui.cell.DarkCellBorderUIResource; /** * @author Jannis Weis */ -public class DarkTreeCellBorder extends DarkCellBorder implements Border, UIResource { +public class DarkTreeCellBorder extends DarkCellBorderUIResource implements Border, UIResource { protected final Color borderColor; protected Insets insets; diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties index 450b673fb..96d0f8eb7 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/ui/fileChooser.properties @@ -29,6 +29,7 @@ FileChooser.newFolderIcon = files/newFolder.svg[themed] FileChooser.upFolderIcon = files/upFolder.svg[themed] FileChooser.homeFolderIcon = files/homeFolder.svg[themed] FileChooser.listViewBorder = com.github.weisj.darklaf.ui.filechooser.DarkFileChooserListViewBorder +FileChooser.listViewBackground = %Cell.background FileChooser.detailsViewIcon = menu/listFiles.svg[themed] FileChooser.detailsViewSelectedIcon = menu/listFilesSelected.svg[themed]