Browse Source

Streamlined foreground background setup for cells. Enabled status of cell and parent is now respected.

Removed more unused properties.
pull/170/head
weisj 5 years ago
parent
commit
dcf86461ae
  1. 2
      core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java
  2. 3
      core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java
  3. 420
      core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java
  4. 31
      core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererPane.java
  5. 11
      core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java
  6. 4
      core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java
  7. 43
      core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java
  8. 16
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java
  9. 6
      core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java
  10. 1090
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java
  11. 65
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java
  12. 1134
      core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java
  13. 3
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderBorder.java
  14. 3
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderCorner.java
  15. 47
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderRenderer.java
  16. 31
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderRendererPane.java
  17. 260
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java
  18. 3
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkColorTableCellRendererEditor.java
  19. 9
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java
  20. 10
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorToggleButton.java
  21. 12
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRenderer.java
  22. 4
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java
  23. 17
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java
  24. 8
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java
  25. 38
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java
  26. 27
      core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java
  27. 49
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/cell.properties
  28. 4
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties
  29. 49
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties
  30. 87
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties
  31. 29
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties
  32. 4
      core/src/main/resources/com/github/weisj/darklaf/properties/unused.properties
  33. 2
      core/src/test/java/defaults/UIManagerDefaults.java
  34. 6
      core/src/test/java/ui/list/ListDemo.java
  35. 2
      core/src/test/java/ui/table/TableDemo.java
  36. 8
      core/src/test/java/ui/tree/TreeDemo.java
  37. 1
      utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java

2
core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java

@ -40,7 +40,7 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask {
private static final String GLOBAL_PREFIX = "global."; private static final String GLOBAL_PREFIX = "global.";
private static final String MAC_OS_MENU_BAR_KEY = "apple.laf.useScreenMenuBar"; private static final String MAC_OS_MENU_BAR_KEY = "apple.laf.useScreenMenuBar";
private static final String[] UI_PROPERTIES = new String[]{"borders", "button", "checkBox", "colorChooser", private static final String[] UI_PROPERTIES = new String[]{"borders", "button", "cell", "checkBox", "colorChooser",
"comboBox", "fileChooser", "tristate", "comboBox", "fileChooser", "tristate",
"internalFrame", "label", "list", "menu", "menuBar", "internalFrame", "label", "list", "menu", "menuBar",
"menuItem", "numberingPane", "optionPane", "panel", "menuItem", "numberingPane", "optionPane", "panel",

3
core/src/main/java/com/github/weisj/darklaf/task/UtilityDefaultsInitTask.java

@ -30,6 +30,7 @@ import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.icons.AwareIconStyle; import com.github.weisj.darklaf.icons.AwareIconStyle;
import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.cell.CellUtil;
public class UtilityDefaultsInitTask implements DefaultsInitTask { public class UtilityDefaultsInitTask implements DefaultsInitTask {
@Override @Override
@ -54,6 +55,8 @@ public class UtilityDefaultsInitTask implements DefaultsInitTask {
IconLoader.updateAwareStyle(Theme.isDark(currentTheme) ? AwareIconStyle.DARK : AwareIconStyle.LIGHT); IconLoader.updateAwareStyle(Theme.isDark(currentTheme) ? AwareIconStyle.DARK : AwareIconStyle.LIGHT);
IconLoader.updateThemeStatus(currentTheme); IconLoader.updateThemeStatus(currentTheme);
CellUtil.updateColors(defaults);
} }
private float getOpacity(final UIDefaults defaults, final String key) { private float getOpacity(final UIDefaults defaults, final String key) {

420
core/src/main/java/com/github/weisj/darklaf/ui/cell/CellUtil.java

@ -30,7 +30,9 @@ import javax.swing.*;
import javax.swing.plaf.ListUI; import javax.swing.plaf.ListUI;
import com.github.weisj.darklaf.ui.list.DarkListUI; import com.github.weisj.darklaf.ui.list.DarkListUI;
import com.github.weisj.darklaf.ui.table.DarkTableCellEditor; import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellEditor;
import com.github.weisj.darklaf.ui.tree.DarkTreeUI;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
@ -38,55 +40,309 @@ public class CellUtil {
public static final String KEY_SELECTED_CELL_RENDERER = "JComponent.selectedCellRenderer"; public static final String KEY_SELECTED_CELL_RENDERER = "JComponent.selectedCellRenderer";
public static void setupForeground(final Component comp, final JComponent parent, final boolean selected, // Default Colors
final String activeKey, final String inactiveKey) { private static Color cellForeground;
setupForeground(comp, parent, selected, UIManager.getColor(activeKey), inactiveKey); private static Color cellForegroundSelected;
private static Color cellForegroundNoFocus;
private static Color cellForegroundSelectedNoFocus;
private static Color cellInactiveForeground;
private static Color cellInactiveForegroundSelected;
private static Color cellInactiveForegroundNoFocus;
private static Color cellInactiveForegroundSelectedNoFocus;
private static Color cellBackground;
private static Color cellBackgroundAlternative;
private static Color cellBackgroundSelected;
private static Color cellBackgroundNoFocus;
private static Color cellBackgroundNoFocusAlternative;
private static Color cellBackgroundSelectedNoFocus;
private static Color cellInactiveBackground;
private static Color cellInactiveBackgroundAlternative;
private static Color cellInactiveBackgroundSelected;
private static Color cellInactiveBackgroundNoFocus;
private static Color cellInactiveBackgroundNoFocusAlternative;
private static Color cellInactiveBackgroundSelectedNoFocus;
// Table Colors
private static Color tableCellForeground;
private static Color tableCellForegroundSelected;
private static Color tableCellForegroundNoFocus;
private static Color tableCellForegroundSelectedNoFocus;
private static Color tableCellInactiveForeground;
private static Color tableCellInactiveForegroundSelected;
private static Color tableCellInactiveForegroundNoFocus;
private static Color tableCellInactiveForegroundSelectedNoFocus;
private static Color tableCellBackground;
private static Color tableCellBackgroundAlternative;
private static Color tableCellBackgroundSelected;
private static Color tableCellBackgroundNoFocus;
private static Color tableCellBackgroundNoFocusAlternative;
private static Color tableCellBackgroundSelectedNoFocus;
private static Color tableCellInactiveBackground;
private static Color tableCellInactiveBackgroundAlternative;
private static Color tableCellInactiveBackgroundSelected;
private static Color tableCellInactiveBackgroundNoFocus;
private static Color tableCellInactiveBackgroundNoFocusAlternative;
private static Color tableCellInactiveBackgroundSelectedNoFocus;
// Tree Colors
private static Color treeCellForeground;
private static Color treeCellForegroundSelected;
private static Color treeCellForegroundNoFocus;
private static Color treeCellForegroundSelectedNoFocus;
private static Color treeCellInactiveForeground;
private static Color treeCellInactiveForegroundSelected;
private static Color treeCellInactiveForegroundNoFocus;
private static Color treeCellInactiveForegroundSelectedNoFocus;
private static Color treeCellBackground;
private static Color treeCellBackgroundAlternative;
private static Color treeCellBackgroundSelected;
private static Color treeCellBackgroundNoFocus;
private static Color treeCellBackgroundNoFocusAlternative;
private static Color treeCellBackgroundSelectedNoFocus;
private static Color treeCellInactiveBackground;
private static Color treeCellInactiveBackgroundAlternative;
private static Color treeCellInactiveBackgroundSelected;
private static Color treeCellInactiveBackgroundNoFocus;
private static Color treeCellInactiveBackgroundNoFocusAlternative;
private static Color treeCellInactiveBackgroundSelectedNoFocus;
// List Colors
private static Color listCellForeground;
private static Color listCellForegroundSelected;
private static Color listCellForegroundNoFocus;
private static Color listCellForegroundSelectedNoFocus;
private static Color listCellInactiveForeground;
private static Color listCellInactiveForegroundSelected;
private static Color listCellInactiveForegroundNoFocus;
private static Color listCellInactiveForegroundSelectedNoFocus;
private static Color listCellBackground;
private static Color listCellBackgroundAlternative;
private static Color listCellBackgroundSelected;
private static Color listCellBackgroundNoFocus;
private static Color listCellBackgroundNoFocusAlternative;
private static Color listCellBackgroundSelectedNoFocus;
private static Color listCellInactiveBackground;
private static Color listCellInactiveBackgroundAlternative;
private static Color listCellInactiveBackgroundSelected;
private static Color listCellInactiveBackgroundNoFocus;
private static Color listCellInactiveBackgroundNoFocusAlternative;
private static Color listCellInactiveBackgroundSelectedNoFocus;
public static void updateColors(final UIDefaults defaults) {
UIDefaults d = defaults != null ? defaults : UIManager.getDefaults();
// Default colors
cellForeground = d.getColor("Cell.foreground");
cellForegroundSelected = d.getColor("Cell.foregroundSelected");
cellForegroundNoFocus = d.getColor("Cell.foregroundNoFocus");
cellForegroundSelectedNoFocus = d.getColor("Cell.foregroundSelectedNoFocus");
cellInactiveForeground = d.getColor("Cell.inactiveForeground");
cellInactiveForegroundSelected = d.getColor("Cell.inactiveForegroundSelected");
cellInactiveForegroundNoFocus = d.getColor("Cell.inactiveForegroundNoFocus");
cellInactiveForegroundSelectedNoFocus = d.getColor("Cell.inactiveSelectedNoFocus");
cellBackground = d.getColor("Cell.background");
cellBackgroundAlternative = d.getColor("Cell.backgroundAlternative");
cellBackgroundSelected = d.getColor("Cell.backgroundSelected");
cellBackgroundNoFocus = d.getColor("Cell.backgroundNoFocus");
cellBackgroundNoFocusAlternative = d.getColor("Cell.backgroundNoFocusAlternative");
cellBackgroundSelectedNoFocus = d.getColor("Cell.backgroundSelectedNoFocus");
cellInactiveBackground = d.getColor("Cell.inactiveBackground");
cellInactiveBackgroundAlternative = d.getColor("Cell.inactiveBackgroundAlternative");
cellInactiveBackgroundSelected = d.getColor("Cell.inactiveBackgroundSelected");
cellInactiveBackgroundNoFocus = d.getColor("Cell.inactiveBackgroundNoFocus");
cellInactiveBackgroundNoFocusAlternative = d.getColor("Cell.inactiveBackgroundNoFocusAlternative");
cellInactiveBackgroundSelectedNoFocus = d.getColor("Cell.inactiveBackgroundSelectedNoFocus");
// Table colors
tableCellForeground = d.getColor("Table.foreground");
tableCellForegroundSelected = d.getColor("Table.foregroundSelected");
tableCellForegroundNoFocus = d.getColor("Table.foregroundNoFocus");
tableCellForegroundSelectedNoFocus = d.getColor("Table.foregroundSelectedNoFocus");
tableCellInactiveForeground = d.getColor("Table.inactiveForeground");
tableCellInactiveForegroundSelected = d.getColor("Table.inactiveForegroundSelected");
tableCellInactiveForegroundNoFocus = d.getColor("Table.inactiveForegroundNoFocus");
tableCellInactiveForegroundSelectedNoFocus = d.getColor("Table.inactiveSelectedNoFocus");
tableCellBackground = d.getColor("Table.background");
tableCellBackgroundAlternative = d.getColor("Table.backgroundAlternative");
tableCellBackgroundSelected = d.getColor("Table.backgroundSelected");
tableCellBackgroundNoFocus = d.getColor("Table.backgroundNoFocus");
tableCellBackgroundNoFocusAlternative = d.getColor("Table.backgroundNoFocusAlternative");
tableCellBackgroundSelectedNoFocus = d.getColor("Table.backgroundSelectedNoFocus");
tableCellInactiveBackground = d.getColor("Table.inactiveBackground");
tableCellInactiveBackgroundAlternative = d.getColor("Table.inactiveBackgroundAlternative");
tableCellInactiveBackgroundSelected = d.getColor("Table.inactiveBackgroundSelected");
tableCellInactiveBackgroundNoFocus = d.getColor("Table.inactiveBackgroundNoFocus");
tableCellInactiveBackgroundNoFocusAlternative = d.getColor("Table.inactiveBackgroundNoFocusAlternative");
tableCellInactiveBackgroundSelectedNoFocus = d.getColor("Table.inactiveBackgroundSelectedNoFocus");
// Tree colors
treeCellForeground = d.getColor("Tree.foreground");
treeCellForegroundSelected = d.getColor("Tree.foregroundSelected");
treeCellForegroundNoFocus = d.getColor("Tree.foregroundNoFocus");
treeCellForegroundSelectedNoFocus = d.getColor("Tree.foregroundSelectedNoFocus");
treeCellInactiveForeground = d.getColor("Tree.inactiveForeground");
treeCellInactiveForegroundSelected = d.getColor("Tree.inactiveForegroundSelected");
treeCellInactiveForegroundNoFocus = d.getColor("Tree.inactiveForegroundNoFocus");
treeCellInactiveForegroundSelectedNoFocus = d.getColor("Tree.inactiveSelectedNoFocus");
treeCellBackground = d.getColor("Tree.background");
treeCellBackgroundAlternative = d.getColor("Tree.backgroundAlternative");
treeCellBackgroundSelected = d.getColor("Tree.backgroundSelected");
treeCellBackgroundNoFocus = d.getColor("Tree.backgroundNoFocus");
treeCellBackgroundNoFocusAlternative = d.getColor("Tree.backgroundNoFocusAlternative");
treeCellBackgroundSelectedNoFocus = d.getColor("Tree.backgroundSelectedNoFocus");
treeCellInactiveBackground = d.getColor("Tree.inactiveBackground");
treeCellInactiveBackgroundAlternative = d.getColor("Tree.inactiveBackgroundAlternative");
treeCellInactiveBackgroundSelected = d.getColor("Tree.inactiveBackgroundSelected");
treeCellInactiveBackgroundNoFocus = d.getColor("Tree.inactiveBackgroundNoFocus");
treeCellInactiveBackgroundNoFocusAlternative = d.getColor("Tree.inactiveBackgroundNoFocusAlternative");
treeCellInactiveBackgroundSelectedNoFocus = d.getColor("Tree.inactiveBackgroundSelectedNoFocus");
// List colors
listCellForeground = d.getColor("List.foreground");
listCellForegroundSelected = d.getColor("List.foregroundSelected");
listCellForegroundNoFocus = d.getColor("List.foregroundNoFocus");
listCellForegroundSelectedNoFocus = d.getColor("List.foregroundSelectedNoFocus");
listCellInactiveForeground = d.getColor("List.inactiveForeground");
listCellInactiveForegroundSelected = d.getColor("List.inactiveForegroundSelected");
listCellInactiveForegroundNoFocus = d.getColor("List.inactiveForegroundNoFocus");
listCellInactiveForegroundSelectedNoFocus = d.getColor("List.inactiveSelectedNoFocus");
listCellBackground = d.getColor("List.background");
listCellBackgroundAlternative = d.getColor("List.backgroundAlternative");
listCellBackgroundSelected = d.getColor("List.backgroundSelected");
listCellBackgroundNoFocus = d.getColor("List.backgroundNoFocus");
listCellBackgroundNoFocusAlternative = d.getColor("List.backgroundNoFocusAlternative");
listCellBackgroundSelectedNoFocus = d.getColor("List.backgroundSelectedNoFocus");
listCellInactiveBackground = d.getColor("List.inactiveBackground");
listCellInactiveBackgroundAlternative = d.getColor("List.inactiveBackgroundAlternative");
listCellInactiveBackgroundSelected = d.getColor("List.inactiveBackgroundSelected");
listCellInactiveBackgroundNoFocus = d.getColor("List.inactiveBackgroundNoFocus");
listCellInactiveBackgroundNoFocusAlternative = d.getColor("List.inactiveBackgroundNoFocusAlternative");
listCellInactiveBackgroundSelectedNoFocus = d.getColor("List.inactiveBackgroundSelectedNoFocus");
}
public static void setupTableForeground(final Component comp, final JTable parent, final boolean selected) {
setupForeground(comp, parent, selected,
tableCellForeground, tableCellForegroundSelected,
tableCellForegroundNoFocus, tableCellForegroundSelectedNoFocus,
tableCellInactiveForeground, tableCellInactiveForegroundSelected,
tableCellInactiveForegroundNoFocus, tableCellInactiveForegroundSelectedNoFocus);
}
public static void setupTreeForeground(final Component comp, final JTree parent, final boolean selected) {
setupForeground(comp, parent, selected,
treeCellForeground, treeCellForegroundSelected,
treeCellForegroundNoFocus, treeCellForegroundSelectedNoFocus,
treeCellInactiveForeground, treeCellInactiveForegroundSelected,
treeCellInactiveForegroundNoFocus, treeCellInactiveForegroundSelectedNoFocus);
} }
public static void setupForeground(final Component comp, final JTable parent, final boolean selected, public static void setupListForeground(final Component comp, final JList<?> parent, final boolean selected) {
final String inactiveKey) { setupForeground(comp, parent, selected,
setupForeground(comp, parent, selected, parent.getSelectionForeground(), inactiveKey); listCellForeground, listCellForegroundSelected,
listCellForegroundNoFocus, listCellForegroundSelectedNoFocus,
listCellInactiveForeground, listCellInactiveForegroundSelected,
listCellInactiveForegroundNoFocus, listCellInactiveForegroundSelectedNoFocus);
}
public static void setupStandardForeground(final Component comp, final JComponent parent, final boolean selected) {
setupForeground(comp, parent, selected,
cellForeground, cellForegroundSelected,
cellForegroundNoFocus, cellForegroundSelectedNoFocus,
cellInactiveForeground, cellInactiveForegroundSelected,
cellInactiveForegroundNoFocus, cellInactiveForegroundSelectedNoFocus);
} }
public static void setupForeground(final Component comp, final JComponent parent, final boolean selected, public static void setupForeground(final Component comp, final JComponent parent, final boolean selected,
final Color activeColor, final String inactiveKey) { final Color fg, final Color selFg,
if (selected) { final Color fgNoFocus, final Color selFgNoFocus,
if (DarkUIUtil.hasFocus(parent)) { final Color inactiveFg, final Color inactiveSelFg,
comp.setForeground(activeColor); final Color inactiveFgNoFocus, final Color inactiveSelFgNoFocus) {
} else { boolean enabled = comp.isEnabled() && parent.isEnabled();
comp.setForeground(UIManager.getColor(inactiveKey)); boolean focus = hasFocus(parent, comp);
} setupForeground(comp, parent, focus, selected, enabled, fg, selFg, fgNoFocus, selFgNoFocus, inactiveFg,
} else { inactiveSelFg, inactiveFgNoFocus, inactiveSelFgNoFocus);
comp.setForeground(parent.getForeground());
}
setSelectedFlag(comp, selected);
} }
public static void setSelectedFlag(final Component comp, final boolean selected) { public static void setupForeground(final Component comp, final JComponent parent,
if (comp instanceof JComponent) { final boolean focus, final boolean selected, final boolean enabled,
((JComponent) comp).putClientProperty(KEY_SELECTED_CELL_RENDERER, selected); final Color fg, final Color selFg,
final Color fgNoFocus, final Color selFgNoFocus,
final Color inactiveFg, final Color inactiveSelFg,
final Color inactiveFgNoFocus, final Color inactiveSelFgNoFocus) {
Color c = getColor(enabled, selected, focus,
fg, selFg, fgNoFocus, selFgNoFocus, inactiveFg, inactiveSelFg,
inactiveFgNoFocus, inactiveSelFgNoFocus);
if (c != null) {
comp.setForeground(c);
} }
} }
public static void setupBackground(final Component comp, final JTable parent, public static void setupTableBackground(final Component comp, final JTable parent, final boolean selected,
final boolean selected, final int row, final int row) {
final String altBgKey, final String altColorKey, boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(parent, DarkTableUI.KEY_ALTERNATE_ROW_COLOR);
final String noFocusSelectionBgKey) { setupBackground(comp, hasFocus(parent, comp), selected,
setupBackground(comp, parent, selected, row, altBgKey, parent.getBackground(), altColorKey, alt ? tableCellBackgroundAlternative : tableCellBackground,
parent.getSelectionBackground(), noFocusSelectionBgKey); tableCellBackgroundSelected,
alt ? tableCellBackgroundNoFocusAlternative : tableCellBackgroundNoFocus,
tableCellBackgroundSelectedNoFocus,
alt ? tableCellInactiveBackgroundAlternative : tableCellInactiveBackground,
tableCellInactiveBackgroundSelected,
alt ? tableCellInactiveBackgroundNoFocusAlternative : tableCellInactiveBackgroundNoFocus,
tableCellInactiveBackgroundSelectedNoFocus);
} }
public static void setupBackground(final Component comp, final JTable parent, public static void setupTreeBackground(final Component comp, final JTree parent, final boolean selected,
final boolean selected, final int row, final int row) {
final String altBgKey, final String colorKey, final String altColorKey, boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(parent, DarkTreeUI.KEY_ALTERNATE_ROW_COLOR);
final String noFocusSelectionBgKey) { setupBackground(comp, hasFocus(parent, comp), selected,
setupBackground(comp, parent, selected, row, altBgKey, UIManager.getColor(colorKey), alt ? treeCellBackgroundAlternative : treeCellBackground,
altColorKey, parent.getSelectionBackground(), noFocusSelectionBgKey); treeCellBackgroundSelected,
alt ? treeCellBackgroundNoFocusAlternative : treeCellBackgroundNoFocus,
treeCellBackgroundSelectedNoFocus,
alt ? treeCellInactiveBackgroundAlternative : treeCellInactiveBackground,
treeCellInactiveBackgroundSelected,
alt ? treeCellInactiveBackgroundNoFocusAlternative : treeCellInactiveBackgroundNoFocus,
treeCellInactiveBackgroundSelectedNoFocus);
} }
public static void setupBackground(final Component comp, final JList<?> parent, final boolean selected, public static Color getTreeBackground(final JTree tree, final boolean selected, final int row) {
final int index, final String altBgKey, final String altColorKey, boolean alt = row % 2 == 1 && PropertyUtil.getBooleanProperty(tree, DarkTreeUI.KEY_ALTERNATE_ROW_COLOR);
final String noFocusSelectionBgKey) { return getColor(tree.isEnabled(), selected, hasFocus(tree, tree),
alt ? treeCellBackgroundAlternative : treeCellBackground,
treeCellBackgroundSelected,
alt ? treeCellBackgroundNoFocusAlternative : treeCellBackgroundNoFocus,
treeCellBackgroundSelectedNoFocus,
alt ? treeCellInactiveBackgroundAlternative : treeCellInactiveBackground,
treeCellInactiveBackgroundSelected,
alt ? treeCellInactiveBackgroundNoFocusAlternative : treeCellInactiveBackgroundNoFocus,
treeCellInactiveBackgroundSelectedNoFocus);
}
public static void setupListBackground(final Component comp, final JList<?> parent, final boolean selected,
final int index) {
int layout = parent.getLayoutOrientation(); int layout = parent.getLayoutOrientation();
boolean altRow = false; boolean altRow = false;
if (layout == JList.VERTICAL) { if (layout == JList.VERTICAL) {
@ -100,25 +356,85 @@ public class CellUtil {
altRow = false; altRow = false;
} }
} }
setupBackground(comp, parent, selected, altRow ? 1 : 0, altBgKey, parent.getBackground(), boolean alt = altRow && PropertyUtil.getBooleanProperty(parent, DarkListUI.KEY_ALTERNATE_ROW_COLOR);
altColorKey, parent.getSelectionBackground(), noFocusSelectionBgKey); setupBackground(comp, hasFocus(parent, comp), selected,
} alt ? listCellBackgroundAlternative : listCellBackground,
listCellBackgroundSelected,
protected static void setupBackground(final Component comp, final JComponent parent, alt ? listCellBackgroundNoFocusAlternative : listCellBackgroundNoFocus,
final boolean selected, final int row, listCellBackgroundSelectedNoFocus,
final String altBgKey, final Color bgColor, final String altColorKey, alt ? listCellInactiveBackgroundAlternative : listCellInactiveBackground,
final Color selectionBackground, final String noFocusSelectionBgKey) { listCellInactiveBackgroundSelected,
boolean alternativeRow = PropertyUtil.getBooleanProperty(parent, altBgKey); alt ? listCellInactiveBackgroundNoFocusAlternative : listCellInactiveBackgroundNoFocus,
Color alternativeRowColor = UIManager.getColor(altColorKey); listCellInactiveBackgroundSelectedNoFocus);
Color background = alternativeRow && row % 2 == 1 ? alternativeRowColor : bgColor; }
if (selected) {
if (DarkUIUtil.hasFocus(parent)) { public static void setupStandardBackground(final Component comp, final JComponent parent, final boolean selected) {
comp.setBackground(selectionBackground); setupBackground(comp, hasFocus(parent, comp), selected,
cellBackground, cellBackgroundSelected,
cellBackgroundNoFocus, cellBackgroundSelectedNoFocus,
cellInactiveBackground, cellInactiveBackgroundSelected,
cellInactiveBackgroundNoFocus, cellInactiveBackgroundSelectedNoFocus);
}
public static void setupBackground(final Component comp, final boolean focus, final boolean selected,
final Color bg, final Color selBg,
final Color bgNoFocus, final Color selBgNoFocus,
final Color inactiveBg, final Color inactiveSelBg,
final Color inactiveBgNoFocus, final Color inactiveSelBgNoFocus) {
boolean enabled = comp.isEnabled();
Color c = getColor(enabled, selected, focus,
bg, selBg, bgNoFocus, selBgNoFocus, inactiveBg, inactiveSelBg,
inactiveBgNoFocus, inactiveSelBgNoFocus);
if (c != null) {
comp.setBackground(c);
}
}
public static Color getColor(final boolean enabled, final boolean selected, final boolean focus,
final Color color, final Color selColor,
final Color colorNoFocus, final Color selColorNoFocus,
final Color inactiveColor, final Color inactiveSelColor,
final Color inactiveColorNoFocus, final Color inactiveSelColorNoFocus) {
Color c;
if (enabled) {
if (selected) {
if (focus) {
c = selColor;
} else {
c = selColorNoFocus;
}
} else { } else {
comp.setBackground(UIManager.getColor(noFocusSelectionBgKey)); if (focus) {
c = color;
} else {
c = colorNoFocus;
}
} }
} else { } else {
comp.setBackground(background); if (selected) {
if (focus) {
c = inactiveSelColor;
} else {
c = inactiveSelColorNoFocus;
}
} else {
if (focus) {
c = inactiveColor;
} else {
c = inactiveColorNoFocus;
}
}
}
return c;
}
protected static boolean hasFocus(final Component c, final Component comp) {
return comp.hasFocus() || (DarkUIUtil.hasFocus(c) || DarkUIUtil.getParentOfType(JPopupMenu.class, c) != null);
}
public static void setSelectedFlag(final Component comp, final boolean selected) {
if (comp instanceof JComponent) {
((JComponent) comp).putClientProperty(KEY_SELECTED_CELL_RENDERER, selected);
} }
} }

31
core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererPane.java

@ -0,0 +1,31 @@
/*
* 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.*;
public class DarkCellRendererPane extends CellRendererPane {}

11
core/src/main/java/com/github/weisj/darklaf/ui/cell/DarkCellRendererToggleButton.java

@ -32,7 +32,6 @@ import javax.swing.tree.TreeCellRenderer;
import com.github.weisj.darklaf.components.SelectableTreeNode; import com.github.weisj.darklaf.components.SelectableTreeNode;
import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder; import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants;
import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer; import com.github.weisj.darklaf.ui.tree.DarkTreeCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
@ -65,11 +64,8 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
&& focus && !DarkTableCellFocusBorder.isRowFocusBorder(table); && focus && !DarkTableCellFocusBorder.isRowFocusBorder(table);
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing(); boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
CellUtil.setupForeground(toggleButton, table, paintSelected, CellUtil.setupTableForeground(toggleButton, table, paintSelected);
"Table.selectionForeground", "Table.selectionForegroundInactive"); CellUtil.setupTableBackground(toggleButton, table, paintSelected, row);
CellUtil.setupBackground(toggleButton, table, paintSelected, row, DarkTableUI.KEY_ALTERNATE_ROW_COLOR,
"Table.background", "Table.alternateRowBackground",
"Table.selectionNoFocusBackground");
return toggleButton; return toggleButton;
} }
@ -89,8 +85,7 @@ public class DarkCellRendererToggleButton<T extends JToggleButton & CellEditorTo
toggleButton.setHorizontalAlignment(tree.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT); toggleButton.setHorizontalAlignment(tree.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT);
toggleButton.setHasFocus(false); toggleButton.setHasFocus(false);
CellUtil.setupForeground(toggleButton, tree, selected, CellUtil.setupTreeForeground(toggleButton, tree, selected);
"Tree.selectionForeground", "Tree.selectionForegroundInactive");
return toggleButton; return toggleButton;
} }

4
core/src/main/java/com/github/weisj/darklaf/ui/filechooser/DarkFilePaneUIBridge.java

@ -48,9 +48,9 @@ import sun.awt.shell.ShellFolderColumnInfo;
import sun.swing.FilePane; import sun.swing.FilePane;
import com.github.weisj.darklaf.ui.list.DarkListCellRenderer; import com.github.weisj.darklaf.ui.list.DarkListCellRenderer;
import com.github.weisj.darklaf.ui.table.DarkTableCellEditor;
import com.github.weisj.darklaf.ui.table.DarkTableCellRenderer;
import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; 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; import com.github.weisj.darklaf.util.PropertyKey;
/** /**

43
core/src/main/java/com/github/weisj/darklaf/ui/label/DarkLabelUI.java

@ -36,10 +36,8 @@ import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.graphics.GraphicsContext; import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil;
/** /**
* @author Jannis Weis * @author Jannis Weis
@ -49,10 +47,6 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
protected static final DarkLabelUI darkLabelUI = new DarkLabelUI(); protected static final DarkLabelUI darkLabelUI = new DarkLabelUI();
private Color inactiveForeground; private Color inactiveForeground;
private Color cellForegroundNoFocus;
private Color cellInactiveForeground;
private Color cellInactiveForegroundSelectedNoFocus;
private Color cellInactiveForegroundSelected;
protected final Rectangle paintIconR = new Rectangle(); protected final Rectangle paintIconR = new Rectangle();
protected final Rectangle paintTextR = new Rectangle(); protected final Rectangle paintTextR = new Rectangle();
@ -75,10 +69,6 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
super.installDefaults(c); super.installDefaults(c);
LookAndFeel.installProperty(c, PropertyKey.OPAQUE, false); LookAndFeel.installProperty(c, PropertyKey.OPAQUE, false);
inactiveForeground = UIManager.getColor("Label.inactiveForeground"); inactiveForeground = UIManager.getColor("Label.inactiveForeground");
cellForegroundNoFocus = UIManager.getColor("Label.cellForegroundNoFocus");
cellInactiveForeground = UIManager.getColor("Label.cellInactiveForeground");
cellInactiveForegroundSelected = UIManager.getColor("Label.cellInactiveForegroundSelected");
cellInactiveForegroundSelectedNoFocus = UIManager.getColor("Label.cellInactiveForegroundSelectedNoFocus");
} }
@Override @Override
@ -113,44 +103,17 @@ public class DarkLabelUI extends BasicLabelUI implements PropertyChangeListener
protected void paintEnabledText(final JLabel l, final Graphics g, final String s, protected void paintEnabledText(final JLabel l, final Graphics g, final String s,
final int textX, final int textY) { final int textX, final int textY) {
int mnemIndex = l.getDisplayedMnemonicIndex(); int mnemIndex = l.getDisplayedMnemonicIndex();
if (DarkUIUtil.isInCell(l) && !hasFocusInCell(l)) { g.setColor(l.getForeground());
g.setColor(cellForegroundNoFocus);
} else {
g.setColor(l.getForeground());
}
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex, SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemIndex,
textX, textY); textX, textY);
} }
protected boolean hasFocusInCell(final JLabel l) {
return (DarkUIUtil.hasFocus(l)
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTree.class, l))
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JTable.class, l))
|| DarkUIUtil.hasFocus(DarkUIUtil.getParentOfType(JList.class, l))
|| DarkUIUtil.getParentOfType(JPopupMenu.class, l) != null);
}
@Override @Override
protected void paintDisabledText(final JLabel l, final Graphics g, final String s, protected void paintDisabledText(final JLabel l, final Graphics g, final String s,
final int textX, final int textY) { final int textX, final int textY) {
int accChar = l.getDisplayedMnemonicIndex(); int accChar = l.getDisplayedMnemonicIndex();
if (DarkUIUtil.isInCell(l)) { g.setColor(l.getForeground());
boolean selected = PropertyUtil.getBooleanProperty(l, CellUtil.KEY_SELECTED_CELL_RENDERER); if (!DarkUIUtil.isInCell(l)) {
boolean focused = hasFocusInCell(l);
if (focused) {
if (selected) {
g.setColor(cellInactiveForegroundSelected);
} else {
g.setColor(cellInactiveForeground);
}
} else {
if (selected) {
g.setColor(cellInactiveForegroundSelectedNoFocus);
} else {
g.setColor(inactiveForeground);
}
}
} else {
g.setColor(inactiveForeground); g.setColor(inactiveForeground);
} }
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar, SwingUtilities2.drawStringUnderlineCharAt(l, g, s, accChar,

16
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListCellRenderer.java

@ -29,7 +29,6 @@ import java.awt.*;
import javax.swing.*; import javax.swing.*;
import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
public class DarkListCellRenderer extends DefaultListCellRenderer { public class DarkListCellRenderer extends DefaultListCellRenderer {
@ -55,19 +54,8 @@ public class DarkListCellRenderer extends DefaultListCellRenderer {
if (comp == null) { if (comp == null) {
comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
} }
CellUtil.setupBackground(comp, list, isSelected, index, DarkListUI.KEY_ALTERNATE_ROW_COLOR, CellUtil.setupListBackground(comp, list, isSelected, index);
"List.alternateRowBackground", CellUtil.setupListForeground(comp, list, isSelected);
"List.selectionNoFocusBackground");
if (!(isSelected)) {
comp.setForeground(list.getForeground());
} else {
if (DarkUIUtil.hasFocus(list) || DarkUIUtil.getParentOfType(JPopupMenu.class, list) != null) {
comp.setForeground(list.getSelectionForeground());
comp.setBackground(list.getSelectionBackground());
} else {
comp.setForeground(UIManager.getColor("List.selectionForegroundInactive"));
}
}
if (getText().isEmpty()) { if (getText().isEmpty()) {
// Fix cell height for empty string. // Fix cell height for empty string.
setText(" "); setText(" ");

6
core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUI.java

@ -31,6 +31,7 @@ import java.beans.PropertyChangeEvent;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import com.github.weisj.darklaf.ui.cell.DarkCellRendererPane;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
@ -61,9 +62,14 @@ public class DarkListUI extends DarkListUIBridge {
@Override @Override
protected void installDefaults() { protected void installDefaults() {
super.installDefaults(); super.installDefaults();
rendererPane = createCellRendererPane();
PropertyUtil.installBooleanProperty(list, KEY_ALTERNATE_ROW_COLOR, "List.alternateRowColor"); PropertyUtil.installBooleanProperty(list, KEY_ALTERNATE_ROW_COLOR, "List.alternateRowColor");
} }
protected CellRendererPane createCellRendererPane() {
return new DarkCellRendererPane();
}
@Override @Override
protected Handler getHandler() { protected Handler getHandler() {
if (handler == null) { if (handler == null) {

1090
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUIBridge.java

File diff suppressed because it is too large Load Diff

65
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java

@ -42,6 +42,10 @@ import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.components.OverlayScrollPane; import com.github.weisj.darklaf.components.OverlayScrollPane;
import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.ui.cell.DarkCellRendererPane;
import com.github.weisj.darklaf.ui.table.renderer.DarkColorTableCellRendererEditor;
import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellEditor;
import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellRenderer;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
@ -99,10 +103,12 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
|| KEY_RENDER_BOOLEAN_AS_CHECKBOX.equals(key) || KEY_RENDER_BOOLEAN_AS_CHECKBOX.equals(key)
|| KEY_BOOLEAN_RENDER_TYPE.equals(key)) { || KEY_BOOLEAN_RENDER_TYPE.equals(key)) {
table.repaint(); table.repaint();
} else if (PropertyKey.ENABLED.equals(key)) {
DarkUIUtil.repaint(table.getTableHeader());
} }
}; };
protected Color selectionBackgroundNoFocus;
protected Color selectionBackground; protected Color selectionBackground;
protected Color selectionFocusBackground;
protected Color borderColor; protected Color borderColor;
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
@ -116,7 +122,6 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
@Override @Override
public void installUI(final JComponent c) { public void installUI(final JComponent c) {
super.installUI(c); super.installUI(c);
table.setSurrendersFocusOnKeystroke(true);
} }
@Override @Override
@ -138,7 +143,7 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
public void focusGained(final FocusEvent e) { public void focusGained(final FocusEvent e) {
Color bg = table.getSelectionBackground(); Color bg = table.getSelectionBackground();
if (bg instanceof UIResource) { if (bg instanceof UIResource) {
table.setSelectionBackground(selectionFocusBackground); table.setSelectionBackground(selectionBackground);
} }
table.repaint(); table.repaint();
} }
@ -150,7 +155,7 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
if (table.isEditing()) { if (table.isEditing()) {
table.setSelectionBackground(table.getBackground()); table.setSelectionBackground(table.getBackground());
} else { } else {
table.setSelectionBackground(selectionBackground); table.setSelectionBackground(selectionBackgroundNoFocus);
} }
} }
table.repaint(); table.repaint();
@ -170,6 +175,33 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
LookAndFeel.uninstallBorder((JComponent) oldUnwrapped); LookAndFeel.uninstallBorder((JComponent) oldUnwrapped);
} }
protected Color getBorderColor() {
return borderColor;
}
@Override
protected void installDefaults() {
super.installDefaults();
int rowHeight = UIManager.getInt("Table.rowHeight");
if (rowHeight > 0) {
LookAndFeel.installProperty(table, "rowHeight", ROW_HEIGHT_FALLBACK);
}
table.setDefaultEditor(Object.class, new DarkTableCellEditor());
PropertyUtil.installBooleanProperty(table, KEY_RENDER_BOOLEAN_AS_CHECKBOX, "Table.renderBooleanAsCheckBox");
PropertyUtil.installBooleanProperty(table, KEY_ALTERNATE_ROW_COLOR, "Table.alternateRowColor");
PropertyUtil.installProperty(table, KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Table.booleanRenderType"));
setupRendererComponents(table);
borderColor = UIManager.getColor("TableHeader.borderColor");
selectionBackground = UIManager.getColor("Table.backgroundSelected");
selectionBackgroundNoFocus = UIManager.getColor("Table.backgroundSelectedNoFocus");
rendererPane = createCellRendererPane();
table.setSurrendersFocusOnKeystroke(true);
}
protected CellRendererPane createCellRendererPane() {
return new DarkCellRendererPane();
}
protected static void setupRendererComponents(final JTable table) { protected static void setupRendererComponents(final JTable table) {
DarkTableCellRenderer cellRenderer = new DarkTableCellRenderer(); DarkTableCellRenderer cellRenderer = new DarkTableCellRenderer();
DarkTableCellEditor cellEditor = new DarkTableCellEditor(); DarkTableCellEditor cellEditor = new DarkTableCellEditor();
@ -192,27 +224,6 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
table.setDefaultEditor(Color.class, colorRendererEditor); table.setDefaultEditor(Color.class, colorRendererEditor);
} }
protected Color getBorderColor() {
return borderColor;
}
@Override
protected void installDefaults() {
super.installDefaults();
int rowHeight = UIManager.getInt("Table.rowHeight");
if (rowHeight > 0) {
LookAndFeel.installProperty(table, "rowHeight", ROW_HEIGHT_FALLBACK);
}
table.setDefaultEditor(Object.class, new DarkTableCellEditor());
PropertyUtil.installBooleanProperty(table, KEY_RENDER_BOOLEAN_AS_CHECKBOX, "Table.renderBooleanAsCheckBox");
PropertyUtil.installBooleanProperty(table, KEY_ALTERNATE_ROW_COLOR, "Table.alternateRowColor");
PropertyUtil.installProperty(table, KEY_BOOLEAN_RENDER_TYPE, UIManager.getString("Table.booleanRenderType"));
setupRendererComponents(table);
borderColor = UIManager.getColor("TableHeader.borderColor");
selectionFocusBackground = UIManager.getColor("Table.focusSelectionBackground");
selectionBackground = UIManager.getColor("Table.selectionNoFocusBackground");
}
protected void checkFocus() { protected void checkFocus() {
boolean focus = DarkUIUtil.hasFocus(table); boolean focus = DarkUIUtil.hasFocus(table);
if (focus) { if (focus) {
@ -581,8 +592,8 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
} }
} }
protected static int adjustDistance(final int distance, final Rectangle rect, public static int adjustDistance(final int distance, final Rectangle rect,
final JTable comp) { final JTable comp) {
int dist = distance; int dist = distance;
int min = 0; int min = 0;
int max = comp.getX() + comp.getWidth(); int max = comp.getX() + comp.getWidth();

1134
core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java

File diff suppressed because it is too large Load Diff

3
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderBorder.java → core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderBorder.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.header;
import java.awt.*; import java.awt.*;

3
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderCorner.java → core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderCorner.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.header;
import java.awt.*; import java.awt.*;

47
core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderRenderer.java

@ -0,0 +1,47 @@
/*
* 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.table.header;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.TableCellRenderer;
public class DarkTableHeaderRenderer implements TableCellRenderer {
private final TableCellRenderer renderer;
public DarkTableHeaderRenderer(final TableCellRenderer renderer) {
this.renderer = renderer;
}
@Override
public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
final boolean hasFocus, final int row, final int column) {
Component c = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setEnabled(table.isEnabled());
return c;
}
}

31
core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderRendererPane.java

@ -0,0 +1,31 @@
/*
* 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.table.header;
import com.github.weisj.darklaf.ui.cell.DarkCellRendererPane;
public class DarkTableHeaderRendererPane extends DarkCellRendererPane {
}

260
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableHeaderUI.java → core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java

@ -20,28 +20,26 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.header;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.plaf.basic.BasicTableHeaderUI;
import javax.swing.table.TableCellRenderer; import javax.swing.table.*;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import com.github.weisj.darklaf.graphics.GraphicsContext; import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
/** /**
* @author Jannis Weis * @author Jannis Weis
*/ */
public class DarkTableHeaderUI extends DarkTableHeaderUIBridge { public class DarkTableHeaderUI extends BasicTableHeaderUI {
public static final String KEY_IS_HEADER_RENDERER = "JComponent.isHeaderRenderer";
private static final int HEADER_HEIGHT = 26; private static final int HEADER_HEIGHT = 26;
protected Color borderColor; protected Color borderColor;
protected Color background; protected Color background;
@ -52,7 +50,22 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
@Override @Override
public void installUI(final JComponent c) { public void installUI(final JComponent c) {
super.installUI(c); header = (JTableHeader) c;
rendererPane = createCellRendererPane();
header.add(rendererPane);
installDefaults();
installListeners();
installKeyboardActions();
}
@Override
protected void installDefaults() {
super.installDefaults();
background = UIManager.getColor("TableHeader.background");
borderColor = UIManager.getColor("TableHeader.borderColor");
LookAndFeel.installBorder(header, "TableHeader.border");
Dimension dim = header.getPreferredSize(); Dimension dim = header.getPreferredSize();
int headerHeight = UIManager.getInt("TableHeader.height"); int headerHeight = UIManager.getInt("TableHeader.height");
if (headerHeight < 0) { if (headerHeight < 0) {
@ -60,18 +73,19 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
} }
header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, headerHeight))); header.setPreferredSize(new Dimension(dim.width, Math.max(dim.height, headerHeight)));
TableCellRenderer defaultRenderer = header.getDefaultRenderer(); TableCellRenderer defaultRenderer = header.getDefaultRenderer();
if (defaultRenderer != null
&& defaultRenderer.getClass().getName().equals("sun.swing.table.DefaultTableCellHeaderRenderer")) {
defaultRenderer = new DarkTableHeaderRenderer(defaultRenderer);
header.setDefaultRenderer(defaultRenderer);
}
if (defaultRenderer instanceof DefaultTableCellRenderer) { if (defaultRenderer instanceof DefaultTableCellRenderer) {
DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) header.getDefaultRenderer(); DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) defaultRenderer;
renderer.setHorizontalAlignment(SwingConstants.LEADING); renderer.setHorizontalAlignment(SwingConstants.LEADING);
} }
} }
@Override protected CellRendererPane createCellRendererPane() {
protected void installDefaults() { return new DarkTableHeaderRendererPane();
super.installDefaults();
background = UIManager.getColor("TableHeader.background");
borderColor = UIManager.getColor("TableHeader.borderColor");
LookAndFeel.installBorder(header, "TableHeader.border");
} }
@Override @Override
@ -118,83 +132,71 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
g.setColor(borderColor); g.setColor(borderColor);
TableColumn draggedColumn = header.getDraggedColumn(); TableColumn draggedColumn = header.getDraggedColumn();
int columnWidth;
Rectangle cellRect = header.getHeaderRect(ltr ? cMin : cMax); Rectangle cellRect = header.getHeaderRect(ltr ? cMin : cMax);
TableColumn aColumn; paintCells(g, h, ltr, cm, cMin, cMax, borderColor, draggedColumn, cellRect);
// Paint the dragged column if we are dragging.
if (draggedColumn != null) {
paintDraggedArea(g, ltr, cMin, cMax, borderColor, draggedColumn);
}
// Remove all components in the rendererPane.
rendererPane.removeAll();
config.restore();
}
public void paintCells(final Graphics2D g, final int h, final boolean ltr,
final TableColumnModel cm,
final int cMin, final int cMax, final Color borderColor,
final TableColumn draggedColumn, final Rectangle cellRect) {
if (ltr) { if (ltr) {
for (int column = cMin; column <= cMax; column++) { for (int column = cMin; column <= cMax; column++) {
aColumn = cm.getColumn(column); paintSingleCell(g, h, cm, cMax, borderColor, draggedColumn, cellRect, column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth;
if (aColumn != draggedColumn) {
paintCell(g, cellRect, column);
}
cellRect.x += columnWidth;
if (column != cMax) {
g.setColor(borderColor);
g.fillRect(cellRect.x - 1, 0, 1, h);
}
} }
} else { } else {
for (int column = cMax; column >= cMin; column--) { for (int column = cMax; column >= cMin; column--) {
aColumn = cm.getColumn(column); paintSingleCell(g, h, cm, cMin, borderColor, draggedColumn, cellRect, column);
columnWidth = aColumn.getWidth();
cellRect.width = columnWidth;
if (aColumn != draggedColumn) {
paintCell(g, cellRect, column);
}
cellRect.x += columnWidth;
if (column != cMin) {
g.setColor(borderColor);
g.fillRect(cellRect.x - 1, 0, 1, h);
}
} }
} }
}
// Paint the dragged column if we are dragging. public void paintSingleCell(final Graphics2D g, final int h, final TableColumnModel cm,
if (draggedColumn != null) { final int cMax, final Color borderColor,
int draggedColumnIndex = viewIndexForColumn(draggedColumn); final TableColumn draggedColumn,
boolean scrollPaneRtl = isScrollPaneRtl(); final Rectangle cellRect, final int column) {
Rectangle draggedCellRect = header.getHeaderRect(draggedColumnIndex); TableColumn aColumn;
int dist = DarkTableUI.adjustDistance(header.getDraggedDistance(), draggedCellRect, header.getTable()); int columnWidth;
// Draw a gray well in place of the moving column. aColumn = cm.getColumn(column);
g.setColor(header.getParent().getBackground()); columnWidth = aColumn.getWidth();
g.fillRect(draggedCellRect.x, draggedCellRect.y, cellRect.width = columnWidth;
draggedCellRect.width, draggedCellRect.height); if (aColumn != draggedColumn) {
paintCell(g, cellRect, column);
}
cellRect.x += columnWidth;
if (column != cMax) {
g.setColor(borderColor); g.setColor(borderColor);
if (scrollBarVisible()) { g.fillRect(cellRect.x - 1, 0, 1, h);
if (ltr) { }
if (!scrollPaneRtl) { }
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height); public void paintDraggedArea(final Graphics2D g, final boolean ltr,
} else { final int cMin, final int cMax,
if (draggedColumnIndex != cMax) { final Color borderColor, final TableColumn draggedColumn) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y, int draggedColumnIndex = viewIndexForColumn(draggedColumn);
1, draggedCellRect.height); boolean scrollPaneRtl = isScrollPaneRtl();
} else { Rectangle draggedCellRect = header.getHeaderRect(draggedColumnIndex);
g.fillRect(draggedCellRect.x + draggedCellRect.width, draggedCellRect.y, int dist = DarkTableUI.adjustDistance(header.getDraggedDistance(), draggedCellRect, header.getTable());
1, draggedCellRect.height); // Draw a gray well in place of the moving column.
} g.setColor(header.getParent().getBackground());
if (draggedColumnIndex == cMin) { g.fillRect(draggedCellRect.x, draggedCellRect.y,
g.fillRect(draggedCellRect.x, draggedCellRect.y, 1, draggedCellRect.height); draggedCellRect.width, draggedCellRect.height);
} g.setColor(borderColor);
} if (scrollBarVisible()) {
if (ltr) {
if (!scrollPaneRtl) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
} else { } else {
if (!scrollPaneRtl) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
} else {
if (draggedColumnIndex != cMin) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
}
if (draggedColumnIndex == cMax) {
g.fillRect(draggedCellRect.x, draggedCellRect.y, 1, draggedCellRect.height);
}
}
}
} else {
if (ltr) {
if (draggedColumnIndex != cMax) { if (draggedColumnIndex != cMax) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y, g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height); 1, draggedCellRect.height);
@ -202,46 +204,66 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
g.fillRect(draggedCellRect.x + draggedCellRect.width, draggedCellRect.y, g.fillRect(draggedCellRect.x + draggedCellRect.width, draggedCellRect.y,
1, draggedCellRect.height); 1, draggedCellRect.height);
} }
if (draggedColumnIndex == cMin) {
g.fillRect(draggedCellRect.x, draggedCellRect.y, 1, draggedCellRect.height);
}
}
} else {
if (!scrollPaneRtl) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
} else { } else {
if (draggedColumnIndex != cMin) { if (draggedColumnIndex != cMin) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y, g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height); 1, draggedCellRect.height);
} }
if (draggedColumnIndex == cMax) {
g.fillRect(draggedCellRect.x, draggedCellRect.y, 1, draggedCellRect.height);
}
}
}
} else {
if (ltr) {
if (draggedColumnIndex != cMax) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
} else {
g.fillRect(draggedCellRect.x + draggedCellRect.width, draggedCellRect.y,
1, draggedCellRect.height);
}
} else {
if (draggedColumnIndex != cMin) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height);
} }
} }
}
draggedCellRect.x += dist; draggedCellRect.x += dist;
// Fill the background. // Fill the background.
g.setColor(header.getBackground()); g.setColor(header.getBackground());
g.fillRect(draggedCellRect.x, draggedCellRect.y, g.fillRect(draggedCellRect.x, draggedCellRect.y,
draggedCellRect.width, draggedCellRect.height); draggedCellRect.width, draggedCellRect.height);
paintCell(g, draggedCellRect, draggedColumnIndex); paintCell(g, draggedCellRect, draggedColumnIndex);
g.setColor(borderColor); g.setColor(borderColor);
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;
// left // left
if (dist != 0 || !onLeftEdge) { if (dist != 0 || !onLeftEdge) {
g.fillRect(draggedCellRect.x - 1, draggedCellRect.y, 1, draggedCellRect.height); g.fillRect(draggedCellRect.x - 1, draggedCellRect.y, 1, draggedCellRect.height);
} }
// right // right
if (dist != 0 || !onRightEdge) { if (dist != 0 || !onRightEdge) {
g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y, g.fillRect(draggedCellRect.x + draggedCellRect.width - 1, draggedCellRect.y,
1, draggedCellRect.height); 1, draggedCellRect.height);
}
} }
// Remove all components in the rendererPane.
rendererPane.removeAll();
config.restore();
} }
@Override
protected void paintCell(final Graphics g, final Rectangle cellRect, final int columnIndex) { protected void paintCell(final Graphics g, final Rectangle cellRect, final int columnIndex) {
Component component = getHeaderRenderer(columnIndex); Component component = getHeaderCellRenderer(columnIndex);
if (component instanceof JComponent) ((JComponent) component).putClientProperty(KEY_IS_HEADER_RENDERER, true);
rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y, rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y,
cellRect.width, cellRect.height, true); cellRect.width, cellRect.height, true);
} }
@ -275,4 +297,28 @@ public class DarkTableHeaderUI extends DarkTableHeaderUIBridge {
} }
return comp instanceof JScrollPane; return comp instanceof JScrollPane;
} }
protected int viewIndexForColumn(final TableColumn aColumn) {
TableColumnModel cm = header.getColumnModel();
for (int column = 0; column < cm.getColumnCount(); column++) {
if (cm.getColumn(column) == aColumn) {
return column;
}
}
return -1;
}
protected Component getHeaderCellRenderer(final int columnIndex) {
TableColumn aColumn = header.getColumnModel().getColumn(columnIndex);
TableCellRenderer renderer = aColumn.getHeaderRenderer();
if (renderer == null) {
renderer = header.getDefaultRenderer();
}
boolean hasFocus = !header.isPaintingForPrint() && header.hasFocus();
return renderer.getTableCellRendererComponent(header.getTable(),
aColumn.getHeaderValue(),
false, hasFocus,
-1, columnIndex);
}
} }

3
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkColorTableCellRendererEditor.java → core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkColorTableCellRendererEditor.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.renderer;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;

9
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java → core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.renderer;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -44,6 +43,8 @@ import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants;
import com.github.weisj.darklaf.ui.combobox.DarkComboBoxUI; import com.github.weisj.darklaf.ui.combobox.DarkComboBoxUI;
import com.github.weisj.darklaf.ui.spinner.DarkSpinnerUI; import com.github.weisj.darklaf.ui.spinner.DarkSpinnerUI;
import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; import com.github.weisj.darklaf.ui.spinner.SpinnerConstants;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder;
import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.ui.text.DarkTextUI;
import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
@ -241,9 +242,7 @@ public class DarkTableCellEditor extends DefaultCellEditor {
setupEditorComponent(value, rendererComp); setupEditorComponent(value, rendererComp);
comp = applyRendererIcon(comp, rendererComp); comp = applyRendererIcon(comp, rendererComp);
CellUtil.setupBackground(comp, table, false, row, DarkTableUI.KEY_ALTERNATE_ROW_COLOR, CellUtil.setupTableBackground(comp, table, false, row);
"Table.alternateRowBackground",
"Table.selectionNoFocusBackground");
return comp; return comp;
} }

10
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditorToggleButton.java → core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorToggleButton.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.renderer;
import java.awt.*; import java.awt.*;
import java.util.EventObject; import java.util.EventObject;
@ -31,6 +30,8 @@ import javax.swing.*;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
/** /**
@ -61,9 +62,8 @@ public class DarkTableCellEditorToggleButton extends AbstractCellEditor implemen
&& !DarkTableCellFocusBorder.isRowFocusBorder(table); && !DarkTableCellFocusBorder.isRowFocusBorder(table);
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing(); boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
CellUtil.setupForeground(toggleButton, table, paintSelected, "Table.selectionForegroundInactive"); CellUtil.setupTableForeground(toggleButton, table, paintSelected);
CellUtil.setupBackground(toggleButton, table, paintSelected, row, DarkTableUI.KEY_ALTERNATE_ROW_COLOR, CellUtil.setupTableBackground(toggleButton, table, paintSelected, row);
"Table.alternateRowBackground", "Table.selectionNoFocusBackground");
return toggleButton; return toggleButton;
} }

12
core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellRenderer.java → core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRenderer.java

@ -20,9 +20,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*
*/ */
package com.github.weisj.darklaf.ui.table; package com.github.weisj.darklaf.ui.table.renderer;
import java.awt.*; import java.awt.*;
@ -34,6 +33,8 @@ import javax.swing.table.TableColumn;
import com.github.weisj.darklaf.ui.cell.CellUtil; import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton;
import com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder;
import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
@ -69,11 +70,10 @@ public class DarkTableCellRenderer extends DefaultTableCellRenderer {
boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) && hasFocus && !isRowFocus; boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) && hasFocus && !isRowFocus;
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing(); boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
setupBorderStyle(table, row, column, component, isRowFocus); setupBorderStyle(table, row, column, component, isRowFocus);
CellUtil.setupForeground(component, table, paintSelected, "Table.selectionForegroundInactive"); CellUtil.setupTableForeground(component, table, paintSelected);
CellUtil.setupBackground(component, table, paintSelected, row, CellUtil.setupTableBackground(component, table, paintSelected, row);
DarkTableUI.KEY_ALTERNATE_ROW_COLOR, "Table.alternateRowBackground",
"Table.selectionNoFocusBackground");
return component; return component;
} }

4
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -205,7 +205,9 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
} }
if (editor.isOpaque()) { if (editor.isOpaque()) {
if (DarkUIUtil.isInCell(editor)) { if (DarkUIUtil.isInCell(editor)
|| PropertyUtil.getBooleanProperty(editor, KEY_IS_TREE_EDITOR)
|| PropertyUtil.getBooleanProperty(editor, KEY_IS_TABLE_EDITOR)) {
g.setColor(getBackground(editor)); g.setColor(getBackground(editor));
g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); g.fillRect(0, 0, editor.getWidth(), editor.getHeight());
} else if (parent != null && parent.isOpaque()) { } else if (parent != null && parent.isOpaque()) {

17
core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellEditor.java

@ -39,11 +39,11 @@ import javax.swing.event.PopupMenuListener;
import javax.swing.tree.TreeCellEditor; import javax.swing.tree.TreeCellEditor;
import com.github.weisj.darklaf.components.SelectableTreeNode; import com.github.weisj.darklaf.components.SelectableTreeNode;
import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants; import com.github.weisj.darklaf.ui.combobox.ComboBoxConstants;
import com.github.weisj.darklaf.ui.spinner.SpinnerConstants; import com.github.weisj.darklaf.ui.spinner.SpinnerConstants;
import com.github.weisj.darklaf.ui.text.DarkTextUI; import com.github.weisj.darklaf.ui.text.DarkTextUI;
import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants; import com.github.weisj.darklaf.ui.togglebutton.ToggleButtonConstants;
import com.github.weisj.darklaf.util.DarkUIUtil;
/** /**
* @author Jannis Weis * @author Jannis Weis
@ -166,22 +166,15 @@ public class DarkTreeCellEditor extends DefaultCellEditor implements TreeCellEdi
((JToggleButton) editorComponent).setSelected(!(((JToggleButton) editorComponent).isSelected())); ((JToggleButton) editorComponent).setSelected(!(((JToggleButton) editorComponent).isSelected()));
SwingUtilities.invokeLater(tree::stopEditing); SwingUtilities.invokeLater(tree::stopEditing);
} }
editorComponent.setOpaque(false); editorComponent.setOpaque(true);
editorComponent.setComponentOrientation(tree.getComponentOrientation()); editorComponent.setComponentOrientation(tree.getComponentOrientation());
if (DarkUIUtil.hasFocus(tree) || DarkUIUtil.hasFocus(editorComponent)) { CellUtil.setupTreeBackground(editorComponent, tree, false, row);
editorComponent.setForeground(UIManager.getColor("Tree.selectionForeground")); CellUtil.setupTreeForeground(editorComponent, tree, false);
} else {
editorComponent.setForeground(UIManager.getColor("Tree.selectionForegroundInactive"));
}
return editorComponent; return editorComponent;
} }
protected void updateFocus(final FocusEvent e) { protected void updateFocus(final FocusEvent e) {
if (DarkUIUtil.hasFocus(editorComponent, e)) { CellUtil.setupTreeForeground(editorComponent, tree, false);
editorComponent.setForeground(UIManager.getColor("Tree.selectionForeground"));
} else {
editorComponent.setForeground(UIManager.getColor("Tree.selectionForegroundInactive"));
}
} }
@Override @Override

8
core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeCellRenderer.java

@ -74,11 +74,17 @@ public class DarkTreeCellRenderer extends DefaultTreeCellRenderer implements Tre
} }
Component comp; Component comp;
if (parent != null) { if (parent != null) {
if (parent instanceof JLabel) {
((JLabel) parent).setIcon(null);
((JLabel) parent).setDisabledIcon(null);
}
comp = parent.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, isFocused); comp = parent.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, isFocused);
} else { } else {
setIcon(null);
setDisabledIcon(null);
comp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, isFocused); comp = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, isFocused);
} }
CellUtil.setupForeground(comp, tree, sel, getTextSelectionColor(), "Tree.selectionForegroundInactive"); CellUtil.setupTreeForeground(comp, tree, sel);
return comp; return comp;
} }

38
core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java

@ -39,6 +39,8 @@ import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel; import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import com.github.weisj.darklaf.ui.cell.CellUtil;
import com.github.weisj.darklaf.ui.cell.DarkCellRendererPane;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;
import com.github.weisj.darklaf.util.SystemInfo; import com.github.weisj.darklaf.util.SystemInfo;
@ -50,7 +52,6 @@ import com.github.weisj.darklaf.util.SystemInfo;
public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
protected static final String KEY_PREFIX = "JTree."; protected static final String KEY_PREFIX = "JTree.";
public static final String KEY_TREE_TABLE_TREE = KEY_PREFIX + "treeTableTree";
public static final String KEY_ALTERNATE_ROW_COLOR = KEY_PREFIX + "alternateRowColor"; public static final String KEY_ALTERNATE_ROW_COLOR = KEY_PREFIX + "alternateRowColor";
public static final String KEY_RENDER_BOOLEAN_AS_CHECKBOX = KEY_PREFIX + "renderBooleanAsCheckBox"; public static final String KEY_RENDER_BOOLEAN_AS_CHECKBOX = KEY_PREFIX + "renderBooleanAsCheckBox";
public static final String KEY_BOOLEAN_RENDER_TYPE = KEY_PREFIX + "booleanRenderType"; public static final String KEY_BOOLEAN_RENDER_TYPE = KEY_PREFIX + "booleanRenderType";
@ -107,12 +108,9 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
} }
} }
}; };
protected Color alternativeBackground;
protected Color lineColor; protected Color lineColor;
protected Color focusSelectedLineColor; protected Color focusSelectedLineColor;
protected Color selectedLineColor; protected Color selectedLineColor;
protected Color selectionBackground;
protected Color focusSelectionBackground;
protected Icon expandedFocusSelected; protected Icon expandedFocusSelected;
protected Icon expandedSelected; protected Icon expandedSelected;
protected Icon expandedFocus; protected Icon expandedFocus;
@ -121,7 +119,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
protected Icon collapsedSelected; protected Icon collapsedSelected;
protected Icon collapsedFocus; protected Icon collapsedFocus;
protected Icon collapsed; protected Icon collapsed;
private boolean myOldRepaintAllRowValue; private boolean oldRepaintAllRowValue;
public static ComponentUI createUI(final JComponent c) { public static ComponentUI createUI(final JComponent c) {
return new DarkTreeUI(); return new DarkTreeUI();
@ -144,7 +142,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
@Override @Override
protected void completeUIInstall() { protected void completeUIInstall() {
super.completeUIInstall(); super.completeUIInstall();
myOldRepaintAllRowValue = UIManager.getBoolean("Tree.repaintWholeRow"); oldRepaintAllRowValue = UIManager.getBoolean("Tree.repaintWholeRow");
UIManager.put("Tree.repaintWholeRow", true); UIManager.put("Tree.repaintWholeRow", true);
tree.putClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR, tree.putClientProperty(DarkTreeUI.KEY_ALTERNATE_ROW_COLOR,
UIManager.getBoolean("Tree.alternateRowColor")); UIManager.getBoolean("Tree.alternateRowColor"));
@ -153,13 +151,11 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
@Override @Override
protected void installDefaults() { protected void installDefaults() {
super.installDefaults(); super.installDefaults();
rendererPane = createCellRendererPane();
LookAndFeel.installColors(tree, "Tree.background", "Tree.foreground"); LookAndFeel.installColors(tree, "Tree.background", "Tree.foreground");
selectionBackground = UIManager.getColor("Tree.unfocusedSelectionBackground");
focusSelectionBackground = UIManager.getColor("Tree.selectionBackground");
focusSelectedLineColor = UIManager.getColor("Tree.lineFocusSelected"); focusSelectedLineColor = UIManager.getColor("Tree.lineFocusSelected");
selectedLineColor = UIManager.getColor("Tree.lineSelected"); selectedLineColor = UIManager.getColor("Tree.lineSelected");
lineColor = UIManager.getColor("Tree.lineUnselected"); lineColor = UIManager.getColor("Tree.lineUnselected");
alternativeBackground = UIManager.getColor("Tree.alternateRowBackground");
expandedFocusSelected = UIManager.getIcon("Tree.expanded.selected.focused.icon"); expandedFocusSelected = UIManager.getIcon("Tree.expanded.selected.focused.icon");
expandedSelected = UIManager.getIcon("Tree.expanded.selected.unfocused.icon"); expandedSelected = UIManager.getIcon("Tree.expanded.selected.unfocused.icon");
expandedFocus = UIManager.getIcon("Tree.expanded.unselected.focused.icon"); expandedFocus = UIManager.getIcon("Tree.expanded.unselected.focused.icon");
@ -174,6 +170,10 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
LookAndFeel.installProperty(tree, JTree.SHOWS_ROOT_HANDLES_PROPERTY, true); LookAndFeel.installProperty(tree, JTree.SHOWS_ROOT_HANDLES_PROPERTY, true);
} }
protected CellRendererPane createCellRendererPane() {
return new DarkCellRendererPane();
}
@Override @Override
protected void installListeners() { protected void installListeners() {
super.installListeners(); super.installListeners();
@ -361,7 +361,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
@Override @Override
protected void uninstallDefaults() { protected void uninstallDefaults() {
super.uninstallDefaults(); super.uninstallDefaults();
UIManager.put("Tree.repaintWholeRow", myOldRepaintAllRowValue); UIManager.put("Tree.repaintWholeRow", oldRepaintAllRowValue);
} }
@Override @Override
@ -523,7 +523,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
Graphics2D rowGraphics = (Graphics2D) g.create(); Graphics2D rowGraphics = (Graphics2D) g.create();
rowGraphics.setClip(clipBounds); rowGraphics.setClip(clipBounds);
rowGraphics.setColor(getRowBackground(row, selected)); rowGraphics.setColor(CellUtil.getTreeBackground(tree, selected, row));
rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height); rowGraphics.fillRect(xOffset, bounds.y, containerWidth, bounds.height);
rowGraphics.dispose(); rowGraphics.dispose();
@ -538,18 +538,6 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
} }
} }
protected Color getRowBackground(final int row, final boolean selected) {
if (selected) {
boolean isTableTree = PropertyUtil.getBooleanProperty(tree, KEY_TREE_TABLE_TREE);
return getTreeSelectionBackground(hasFocus() || isTableTree || tree.isEditing());
}
if (row % 2 == 1 && PropertyUtil.getBooleanProperty(tree, KEY_ALTERNATE_ROW_COLOR)) {
return alternativeBackground;
} else {
return tree.getBackground();
}
}
protected boolean shouldPaintLines() { protected boolean shouldPaintLines() {
return !STYLE_NONE.equals(getLineStyle()); return !STYLE_NONE.equals(getLineStyle());
} }
@ -581,10 +569,6 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener {
} }
} }
protected Color getTreeSelectionBackground(final boolean focused) {
return focused ? focusSelectionBackground : selectionBackground;
}
protected String getLineStyle() { protected String getLineStyle() {
return PropertyUtil.getString(tree, KEY_LINE_STYLE, ""); return PropertyUtil.getString(tree, KEY_LINE_STYLE, "");
} }

27
core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java

@ -37,7 +37,9 @@ import javax.swing.*;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InsetsUIResource; import javax.swing.plaf.InsetsUIResource;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeCellRenderer;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
@ -45,7 +47,7 @@ import sun.awt.SunToolkit;
import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.ui.cell.CellRenderer; import com.github.weisj.darklaf.ui.cell.CellRenderer;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.ui.table.DarkTableHeaderUI; import com.github.weisj.darklaf.ui.table.header.DarkTableHeaderRendererPane;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
@ -155,13 +157,11 @@ public final class DarkUIUtil {
} }
public static boolean isInCell(final Component c) { public static boolean isInCell(final Component c) {
boolean tableHeaderCell = PropertyUtil.getBooleanProperty(c, DarkTableHeaderUI.KEY_IS_HEADER_RENDERER); if (getParentOfType(DarkTableHeaderRendererPane.class, c) != null) return false;
boolean inCellRenderer = !tableHeaderCell boolean inCellRenderer = getParentOfType(c, CellRendererPane.class, CellEditor.class,
&& (getParentOfType(CellRendererPane.class, c) != null TableCellRenderer.class, TableCellEditor.class,
|| getParentOfType(TableCellRenderer.class, c) != null TreeCellRenderer.class, TreeCellEditor.class,
|| getParentOfType(TreeCellRenderer.class, c) != null ListCellRenderer.class, CellRenderer.class) != null;
|| getParentOfType(CellRenderer.class, c) != null
|| getParentOfType(CellEditor.class, c) != null);
return inCellRenderer && getParentOfType(JComboBox.class, c) == null; return inCellRenderer && getParentOfType(JComboBox.class, c) == null;
} }
@ -175,6 +175,17 @@ public final class DarkUIUtil {
return null; return null;
} }
public static <T> T getParentOfType(final Component c, final Class<? extends T>... classes) {
for (Component eachParent = c; eachParent != null; eachParent = eachParent.getParent()) {
for (Class<? extends T> cls : classes) {
if (cls.isAssignableFrom(eachParent.getClass())) {
return (T) eachParent;
}
}
}
return null;
}
public static Window getWindow(final Component component) { public static Window getWindow(final Component component) {
if (component == null) { if (component == null) {
return null; return null;

49
core/src/main/resources/com/github/weisj/darklaf/properties/ui/cell.properties

@ -0,0 +1,49 @@
#
# 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.
#
#
# suppress inspection "UnusedProperty" for whole file
#
Cell.foreground = %textForeground
Cell.foregroundSelected = %textSelectionForeground
Cell.foregroundNoFocus = %textSelectionForegroundInactive
Cell.foregroundSelectedNoFocus = %textSelectionForegroundInactive
Cell.inactiveForeground = %textForegroundInactive
Cell.inactiveForegroundSelected = %textSelectionForegroundDisabled
Cell.inactiveForegroundNoFocus = %textForegroundInactive
Cell.inactiveSelectedNoFocus = %textForegroundInactive
Cell.background = %backgroundContainer
Cell.backgroundAlternative = %backgroundAlternative
Cell.backgroundSelected = %highlightFillFocus
Cell.backgroundNoFocus = %backgroundContainer
Cell.backgroundNoFocusAlternative = %backgroundAlternative
Cell.backgroundSelectedNoFocus = %highlightFill
Cell.inactiveBackground = %backgroundContainer
Cell.inactiveBackgroundAlternative = %backgroundAlternative
Cell.inactiveBackgroundSelected = %highlightFill
Cell.inactiveBackgroundNoFocus = %backgroundContainer
Cell.inactiveBackgroundNoFocusAlternative = %backgroundAlternative
Cell.inactiveBackgroundSelectedNoFocus = %highlightFill

4
core/src/main/resources/com/github/weisj/darklaf/properties/ui/label.properties

@ -26,7 +26,3 @@
# #
LabelUI = com.github.weisj.darklaf.ui.label.DarkLabelUI LabelUI = com.github.weisj.darklaf.ui.label.DarkLabelUI
Label.inactiveForeground = %textForegroundInactive Label.inactiveForeground = %textForegroundInactive
Label.cellForegroundNoFocus = %textSelectionForegroundInactive
Label.cellInactiveForeground = %textForegroundInactive
Label.cellInactiveForegroundSelected = %textSelectionForegroundDisabled
Label.cellInactiveForegroundSelectedNoFocus = %textForegroundInactive

49
core/src/main/resources/com/github/weisj/darklaf/properties/ui/list.properties

@ -24,17 +24,38 @@
# #
# suppress inspection "UnusedProperty" for whole file # suppress inspection "UnusedProperty" for whole file
# #
ListUI = com.github.weisj.darklaf.ui.list.DarkListUI ListUI = com.github.weisj.darklaf.ui.list.DarkListUI
List.cellRenderer = com.github.weisj.darklaf.ui.list.DarkListCellRenderer List.cellRenderer = com.github.weisj.darklaf.ui.list.DarkListCellRenderer
List.border = com.github.weisj.darklaf.ui.list.DarkListBorder List.border = com.github.weisj.darklaf.ui.list.DarkListBorder
List.noFocusBorder = com.github.weisj.darklaf.ui.list.DarkListBorder List.noFocusBorder = com.github.weisj.darklaf.ui.list.DarkListBorder
List.background = %backgroundContainer List.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.list.DarkListCellFocusBorder
List.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.list.DarkListCellFocusBorder List.focusCellHighlightBorder = com.github.weisj.darklaf.ui.list.DarkListCellBorder
List.focusCellHighlightBorder = com.github.weisj.darklaf.ui.list.DarkListCellBorder List.cellNoFocusBorder = com.github.weisj.darklaf.ui.list.DarkListCellBorder
List.cellNoFocusBorder = com.github.weisj.darklaf.ui.list.DarkListCellBorder List.dropLineColor = %dropForeground
List.dropLineColor = %dropForeground List.focusBorderColor = %borderFocus
List.selectionBackground = %highlightFillFocus
List.selectionNoFocusBackground = %highlightFill List.alternateRowColor = false
List.focusBorderColor = %borderFocus
List.alternateRowBackground = %backgroundAlternative List.background = %Cell.background
List.selectionForegroundInactive = %textSelectionForegroundInactive List.backgroundAlternative = %Cell.backgroundAlternative
List.backgroundSelected = %Cell.backgroundSelected
List.backgroundNoFocus = %Cell.backgroundNoFocus
List.backgroundNoFocusAlternative = %Cell.backgroundNoFocusAlternative
List.backgroundSelectedNoFocus = %Cell.backgroundSelectedNoFocus
List.inactiveBackground = %Cell.inactiveBackground
List.inactiveBackgroundAlternative = %Cell.inactiveBackgroundAlternative
List.inactiveBackgroundSelected = %Cell.inactiveBackgroundSelected
List.inactiveBackgroundNoFocus = %Cell.inactiveBackgroundNoFocus
List.inactiveBackgroundNoFocusAlternative = %Cell.inactiveBackgroundNoFocusAlternative
List.inactiveBackgroundSelectedNoFocus = %Cell.inactiveBackgroundSelectedNoFocus
List.foreground = %Cell.foreground
List.foregroundSelected = %Cell.foregroundSelected
List.foregroundNoFocus = %Cell.foregroundNoFocus
List.foregroundSelectedNoFocus = %Cell.foregroundSelectedNoFocus
List.inactiveForeground = %Cell.inactiveForeground
List.inactiveForegroundSelected = %Cell.inactiveForegroundSelected
List.inactiveForegroundNoFocus = %Cell.inactiveForegroundNoFocus
List.inactiveSelectedNoFocus = %Cell.inactiveSelectedNoFocus

87
core/src/main/resources/com/github/weisj/darklaf/properties/ui/table.properties

@ -24,44 +24,59 @@
# #
# suppress inspection "UnusedProperty" for whole file # suppress inspection "UnusedProperty" for whole file
# #
TableHeaderUI = com.github.weisj.darklaf.ui.table.DarkTableHeaderUI TableHeaderUI = com.github.weisj.darklaf.ui.table.header.DarkTableHeaderUI
TableHeader.cellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder TableHeader.cellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder
TableHeader.focusCellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder TableHeader.focusCellBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder
TableHeader.border = com.github.weisj.darklaf.ui.table.DarkTableHeaderBorder TableHeader.border = com.github.weisj.darklaf.ui.table.header.DarkTableHeaderBorder
TableHeader.background = %backgroundHeader TableHeader.background = %backgroundHeader
TableHeader.focusCellBackground = %backgroundHeader TableHeader.focusCellBackground = %backgroundHeader
TableHeader.borderColor = %border TableHeader.borderColor = %border
TableHeader.height = 26 TableHeader.height = 26
TableUI = com.github.weisj.darklaf.ui.table.DarkTableUI TableUI = com.github.weisj.darklaf.ui.table.DarkTableUI
Table.scrollPaneCornerComponent = com.github.weisj.darklaf.ui.table.DarkTableHeaderCorner Table.scrollPaneCornerComponent = com.github.weisj.darklaf.ui.table.header.DarkTableHeaderCorner
Table.cellNoFocusBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder Table.cellNoFocusBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder
Table.focusCellHighlightBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder Table.focusCellHighlightBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder
Table.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder Table.focusSelectedCellHighlightBorder = com.github.weisj.darklaf.ui.table.DarkTableCellFocusBorder
Table.cellEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder Table.cellEditorBorder = com.github.weisj.darklaf.ui.table.DarkTableCellBorder
Table.scrollPaneBorder = com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder Table.scrollPaneBorder = com.github.weisj.darklaf.ui.table.DarkTableScrollPaneBorder
Table.border = com.github.weisj.darklaf.ui.table.DarkTableBorder Table.border = com.github.weisj.darklaf.ui.table.DarkTableBorder
Table.background = %backgroundContainer Table.focusBorderColor = %borderFocus
Table.focusBorderColor = %borderFocus Table.focusRowBorderColor = %borderFocus
Table.focusRowBorderColor = %borderFocus Table.gridColor = %gridLine
Table.gridColor = %gridLine Table.dropLineColor = %dropForeground
Table.dropLineColor = %dropForeground Table.dropLineShortColor = %dropForeground
Table.dropLineShortColor = %dropForeground
Table.focusSelectionBackground = %highlightFillFocus
Table.focusCellBackground = %backgroundContainer
Table.focusCellForeground = %textForeground
Table.selectionNoFocusBackground = %highlightFill
Table.selectionBackground = %highlightFillFocus
Table.selectionForegroundInactive = %textSelectionForegroundInactive
Table.alternateRowColor = false Table.background = %Cell.background
Table.alternateRowBackground = %backgroundAlternative Table.backgroundAlternative = %Cell.backgroundAlternative
Table.backgroundSelected = %Cell.backgroundSelected
Table.backgroundNoFocus = %Cell.backgroundNoFocus
Table.backgroundNoFocusAlternative = %Cell.backgroundNoFocusAlternative
Table.backgroundSelectedNoFocus = %Cell.backgroundSelectedNoFocus
Table.renderBooleanAsCheckBox = true Table.inactiveBackground = %Cell.inactiveBackground
Table.booleanRenderType = checkBox Table.inactiveBackgroundAlternative = %Cell.inactiveBackgroundAlternative
Table.rowHeight = 22 Table.inactiveBackgroundSelected = %Cell.inactiveBackgroundSelected
Table.inactiveBackgroundNoFocus = %Cell.inactiveBackgroundNoFocus
Table.inactiveBackgroundNoFocusAlternative = %Cell.inactiveBackgroundNoFocusAlternative
Table.inactiveBackgroundSelectedNoFocus = %Cell.inactiveBackgroundSelectedNoFocus
Table.foreground = %Cell.foreground
Table.foregroundSelected = %Cell.foregroundSelected
Table.foregroundNoFocus = %Cell.foregroundNoFocus
Table.foregroundSelectedNoFocus = %Cell.foregroundSelectedNoFocus
Table.inactiveForeground = %Cell.inactiveForeground
Table.inactiveForegroundSelected = %Cell.inactiveForegroundSelected
Table.inactiveForegroundNoFocus = %Cell.inactiveForegroundNoFocus
Table.inactiveSelectedNoFocus = %Cell.inactiveSelectedNoFocus
Table.alternateRowColor = false
Table.renderBooleanAsCheckBox = true
Table.booleanRenderType = checkBox
Table.rowHeight = 22
#Icons #Icons
Table.ascendingSortIcon = menu/up.svg[themed](8,16) Table.ascendingSortIcon = menu/up.svg[themed](8,16)
Table.descendingSortIcon = menu/down.svg[themed](8,16) Table.descendingSortIcon = menu/down.svg[themed](8,16)
Table.naturalSortIcon = empty(8,16) Table.naturalSortIcon = empty(8,16)

29
core/src/main/resources/com/github/weisj/darklaf/properties/ui/tree.properties

@ -28,9 +28,6 @@ TreeUI = com.github.weisj.darklaf.ui.tree.Dark
Tree.editorBorder = com.github.weisj.darklaf.ui.tree.DarkTreeCellBorder Tree.editorBorder = com.github.weisj.darklaf.ui.tree.DarkTreeCellBorder
Tree.editorBorderColor = %widgetBorder Tree.editorBorderColor = %widgetBorder
Tree.rendererFillBackground = false Tree.rendererFillBackground = false
Tree.background = %backgroundContainer
Tree.selectionBackground = %highlightFillFocus
Tree.unfocusedSelectionBackground = %highlightFill
Tree.selectionBorderColor = null Tree.selectionBorderColor = null
Tree.line = %borderFocus Tree.line = %borderFocus
Tree.hash = %borderFocus Tree.hash = %borderFocus
@ -38,15 +35,35 @@ Tree.lineFocusSelected = %borderFocus
Tree.lineSelected = %gridLine Tree.lineSelected = %gridLine
Tree.lineUnselected = %gridLine Tree.lineUnselected = %gridLine
Tree.selectionForegroundInactive = %textSelectionForegroundInactive Tree.background = %Cell.background
Tree.backgroundAlternative = %Cell.backgroundAlternative
Tree.backgroundSelected = %Cell.backgroundSelected
Tree.backgroundNoFocus = %Cell.backgroundNoFocus
Tree.backgroundNoFocusAlternative = %Cell.backgroundNoFocusAlternative
Tree.backgroundSelectedNoFocus = %Cell.backgroundSelectedNoFocus
Tree.inactiveBackground = %Cell.inactiveBackground
Tree.inactiveBackgroundAlternative = %Cell.inactiveBackgroundAlternative
Tree.inactiveBackgroundSelected = %Cell.inactiveBackgroundSelected
Tree.inactiveBackgroundNoFocus = %Cell.inactiveBackgroundNoFocus
Tree.inactiveBackgroundNoFocusAlternative = %Cell.inactiveBackgroundNoFocusAlternative
Tree.inactiveBackgroundSelectedNoFocus = %Cell.inactiveBackgroundSelectedNoFocus
Tree.foreground = %Cell.foreground
Tree.foregroundSelected = %Cell.foregroundSelected
Tree.foregroundNoFocus = %Cell.foregroundNoFocus
Tree.foregroundSelectedNoFocus = %Cell.foregroundSelectedNoFocus
Tree.inactiveForeground = %Cell.inactiveForeground
Tree.inactiveForegroundSelected = %Cell.inactiveForegroundSelected
Tree.inactiveForegroundNoFocus = %Cell.inactiveForegroundNoFocus
Tree.inactiveSelectedNoFocus = %Cell.inactiveSelectedNoFocus
Tree.textBackground = %textBackground Tree.textBackground = %textBackground
Tree.rowHeight = 22 Tree.rowHeight = 22
Tree.dropLineColor = %dropForeground Tree.dropLineColor = %dropForeground
Tree.alternateRowColor = false Tree.alternateRowColor = false
Tree.alternateRowBackground = %backgroundAlternative
Tree.renderBooleanAsCheckBox = true Tree.renderBooleanAsCheckBox = true
Tree.booleanRenderType = checkBox Tree.booleanRenderType = checkBox
Tree.defaultLineStyle = line Tree.defaultLineStyle = line

4
core/src/main/resources/com/github/weisj/darklaf/properties/unused.properties

@ -32,6 +32,7 @@ Button.select = null
Button.toolBarBorderBackground = null Button.toolBarBorderBackground = null
Button.gradient = null Button.gradient = null
Button.rolloverIconType = null Button.rolloverIconType = null
Button.disabledToolBarBorderBackground = null
CheckBox.focus = null CheckBox.focus = null
Checkbox.select = null Checkbox.select = null
@ -116,6 +117,9 @@ ToolBar.highlight = null
ToolBar.light = null ToolBar.light = null
ToolBar.shadow = null ToolBar.shadow = null
Table.focusCellForeground = null
Table.focusCellBackground = null
Label.disabledShadow = null Label.disabledShadow = null
MenuBar.shadow = null MenuBar.shadow = null
MenuBar.gradient = null MenuBar.gradient = null

2
core/src/test/java/defaults/UIManagerDefaults.java

@ -43,7 +43,7 @@ import javax.swing.table.DefaultTableModel;
import ui.ComponentDemo; import ui.ComponentDemo;
import com.github.weisj.darklaf.components.OverlayScrollPane; import com.github.weisj.darklaf.components.OverlayScrollPane;
import com.github.weisj.darklaf.ui.table.DarkColorTableCellRendererEditor; import com.github.weisj.darklaf.ui.table.renderer.DarkColorTableCellRendererEditor;
public class UIManagerDefaults implements ItemListener, ComponentDemo { public class UIManagerDefaults implements ItemListener, ComponentDemo {
private static final String[] COLUMN_NAMES = {"Key", "Value", "Sample"}; private static final String[] COLUMN_NAMES = {"Key", "Value", "Sample"};

6
core/src/test/java/ui/list/ListDemo.java

@ -51,6 +51,12 @@ public final class ListDemo implements ComponentDemo {
DemoPanel panel = new DemoPanel(list, new BorderLayout(), 0); DemoPanel panel = new DemoPanel(list, new BorderLayout(), 0);
JPanel controlPanel = panel.addControls(); JPanel controlPanel = panel.addControls();
controlPanel.add(new JCheckBox("enabled") {
{
setSelected(list.isEnabled());
addActionListener(e -> list.setEnabled(isSelected()));
}
});
controlPanel.add(new JCheckBox(DarkListUI.KEY_ALTERNATE_ROW_COLOR) { controlPanel.add(new JCheckBox(DarkListUI.KEY_ALTERNATE_ROW_COLOR) {
{ {
setSelected(PropertyUtil.getBooleanProperty(list, DarkListUI.KEY_ALTERNATE_ROW_COLOR)); setSelected(PropertyUtil.getBooleanProperty(list, DarkListUI.KEY_ALTERNATE_ROW_COLOR));

2
core/src/test/java/ui/table/TableDemo.java

@ -34,8 +34,8 @@ import javax.swing.table.TableCellEditor;
import ui.ComponentDemo; import ui.ComponentDemo;
import ui.DemoPanel; import ui.DemoPanel;
import com.github.weisj.darklaf.ui.table.DarkTableCellEditor;
import com.github.weisj.darklaf.ui.table.DarkTableUI; import com.github.weisj.darklaf.ui.table.DarkTableUI;
import com.github.weisj.darklaf.ui.table.renderer.DarkTableCellEditor;
import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil; import com.github.weisj.darklaf.util.PropertyUtil;

8
core/src/test/java/ui/tree/TreeDemo.java

@ -73,13 +73,19 @@ public class TreeDemo implements ComponentDemo {
final boolean leaf, final int row, final boolean hasFocus) { final boolean leaf, final int row, final boolean hasFocus) {
Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
hasFocus); hasFocus);
component.setEnabled(value != parent1 && value != child); component.setEnabled(tree.isEnabled() && (value != parent1 && value != child));
return component; return component;
} }
}); });
DemoPanel panel = new DemoPanel(new OverlayScrollPane(tree), new BorderLayout(), 0); DemoPanel panel = new DemoPanel(new OverlayScrollPane(tree), new BorderLayout(), 0);
JPanel controlPanel = panel.addControls(); JPanel controlPanel = panel.addControls();
controlPanel.setLayout(new MigLayout("fillx, wrap 2", "[][grow]")); controlPanel.setLayout(new MigLayout("fillx, wrap 2", "[][grow]"));
controlPanel.add(new JCheckBox(PropertyKey.ENABLED) {
{
setSelected(tree.isEnabled());
addActionListener(e -> tree.setEnabled(isSelected()));
}
});
controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) { controlPanel.add(new JCheckBox(PropertyKey.EDITABLE) {
{ {
setSelected(tree.isEditable()); setSelected(tree.isEditable());

1
utils/src/main/java/com/github/weisj/darklaf/util/PropertyKey.java

@ -36,6 +36,7 @@ public class PropertyKey {
public static final String OPAQUE = "opaque"; public static final String OPAQUE = "opaque";
public static final String ANCESTOR = "ancestor"; public static final String ANCESTOR = "ancestor";
public static final String EDITABLE = "editable"; public static final String EDITABLE = "editable";
public static final String ENABLED = "enabled";
public static final String BACKGROUND = "background"; public static final String BACKGROUND = "background";
public static final String FOREGROUND = "foreground"; public static final String FOREGROUND = "foreground";
public static final String FONT = "font"; public static final String FONT = "font";

Loading…
Cancel
Save