Browse Source

Added focus border to table cells.

Fixed some behaviour for color cell editor.
Fixed selection painting when grid is disabled.
pull/1/head
weisj 5 years ago
parent
commit
8aea513da8
  1. 3
      pom.xml
  2. 2
      src/main/java/com/weis/darklaf/LafManager.java
  3. 4
      src/main/java/com/weis/darklaf/components/ColorPipetteBase.java
  4. 4
      src/main/java/com/weis/darklaf/components/DefaultColorPipette.java
  5. 8
      src/main/java/com/weis/darklaf/components/border/MutableLineBorder.java
  6. 2
      src/main/java/com/weis/darklaf/platform/windows/WindowsFrameUtil.java
  7. 2
      src/main/java/com/weis/darklaf/ui/button/DarkToggleButtonUI.java
  8. 2
      src/main/java/com/weis/darklaf/ui/colorchooser/DarkColorChooserPanel.java
  9. 2
      src/main/java/com/weis/darklaf/ui/rootpane/DarkTitlePane.java
  10. 318
      src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java
  11. 17
      src/main/java/com/weis/darklaf/ui/table/DarkColorTableCellRendererEditor.java
  12. 6
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java
  13. 20
      src/main/java/com/weis/darklaf/ui/table/DarkTableCellFocusBorder.java
  14. 18
      src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java
  15. 2
      src/main/java/com/weis/darklaf/ui/text/DarkCaret.java
  16. 2
      src/main/java/com/weis/darklaf/ui/text/DarkTextBorder.java
  17. 5
      src/main/resources/com/weis/darklaf/darcula.properties
  18. 2
      src/main/resources/com/weis/darklaf/icons/java.svg
  19. 24
      src/test/java/DnDTest.java
  20. 5
      src/test/java/UIManagerDefaults.java

3
pom.xml

@ -32,7 +32,6 @@
<artifactId>svg-salamander</artifactId>
<version>[0.1.19,)</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
@ -65,10 +64,10 @@
<version>3.8.0</version>
<configuration>
<compilerArgs>
<!-- <arg>&#45;&#45;enable-preview</arg>-->
<arg>--add-exports=java.desktop/sun.awt=ALL-UNNAMED</arg>
<arg>--add-exports=java.desktop/com.sun.java.swing=ALL-UNNAMED</arg>
<arg>--add-exports=java.desktop/sun.swing=ALL-UNNAMED</arg>
<!-- <arg>-h</arg>-->
</compilerArgs>
</configuration>
</plugin>

2
src/main/java/com/weis/darklaf/LafManager.java

@ -36,7 +36,7 @@ public final class LafManager {
return currentLaf;
}
public static void setLogEnabled(boolean logEnabled) {
public static void setLogEnabled(final boolean logEnabled) {
if (!logEnabled) {
LogManager.getLogManager().reset();
} else {

4
src/main/java/com/weis/darklaf/util/ColorPipetteBase.java → src/main/java/com/weis/darklaf/components/ColorPipetteBase.java

@ -1,8 +1,10 @@
package com.weis.darklaf.util;
package com.weis.darklaf.components;
import com.bulenkov.iconloader.util.SystemInfo;
import com.weis.darklaf.platform.windows.WindowsFrameUtil;
import com.weis.darklaf.ui.colorchooser.ColorListener;
import com.weis.darklaf.ui.colorchooser.ColorPipette;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

4
src/main/java/com/weis/darklaf/util/DefaultColorPipette.java → src/main/java/com/weis/darklaf/components/DefaultColorPipette.java

@ -1,6 +1,8 @@
package com.weis.darklaf.util;
package com.weis.darklaf.components;
import com.weis.darklaf.ui.colorchooser.ColorListener;
import com.weis.darklaf.util.GraphicsUtil;
import com.weis.darklaf.util.TimerUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;

8
src/main/java/com/weis/darklaf/components/border/MutableLineBorder.java

@ -26,10 +26,10 @@ public class MutableLineBorder extends EmptyBorder {
final int width, final int height) {
g.setColor(getColor());
var insets = getBorderInsets();
g.fillRect(0, 0, width - insets.right, insets.top);
g.fillRect(0, insets.top, insets.left, height - insets.top);
g.fillRect(insets.left, height - insets.bottom, width - insets.left, insets.bottom);
g.fillRect(width - insets.right, 0, insets.right, height - insets.bottom);
g.fillRect(x, y, width - insets.right, insets.top);
g.fillRect(x, y + insets.top, insets.left, height - insets.top);
g.fillRect(x + insets.left, y + height - insets.bottom, width - insets.left, insets.bottom);
g.fillRect(x + width - insets.right, y, insets.right, height - insets.bottom);
}
public void setLeft(final int left) {

2
src/main/java/com/weis/darklaf/util/WindowsFrameUtil.java → src/main/java/com/weis/darklaf/platform/windows/WindowsFrameUtil.java

@ -1,4 +1,4 @@
package com.weis.darklaf.util;
package com.weis.darklaf.platform.windows;
import com.sun.jna.LastErrorException;
import com.sun.jna.Native;

2
src/main/java/com/weis/darklaf/ui/button/DarkToggleButtonUI.java

@ -18,7 +18,7 @@ public class DarkToggleButtonUI extends DarkButtonUI {
private static final int SLIDER_HEIGHT = 17;
private static final int SLIDER_WIDTH = 35;
private static Rectangle rect = new Rectangle();
private static final Rectangle rect = new Rectangle();
private final PropertyChangeListener propertyChangeListener = evt -> {
if ("ToggleButton.variant".equals(evt.getPropertyName())) {

2
src/main/java/com/weis/darklaf/ui/colorchooser/DarkColorChooserPanel.java

@ -1,8 +1,8 @@
package com.weis.darklaf.ui.colorchooser;
import com.weis.darklaf.color.DarkColorModel;
import com.weis.darklaf.components.DefaultColorPipette;
import com.weis.darklaf.util.ColorUtil;
import com.weis.darklaf.util.DefaultColorPipette;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

2
src/main/java/com/weis/darklaf/ui/rootpane/DarkTitlePane.java

@ -17,9 +17,9 @@ package com.weis.darklaf.ui.rootpane;
*/
import com.sun.jna.Structure;
import com.weis.darklaf.platform.windows.WindowsFrameUtil;
import com.weis.darklaf.ui.button.DarkButtonUI;
import com.weis.darklaf.util.GraphicsUtil;
import com.weis.darklaf.util.WindowsFrameUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

318
src/main/java/com/weis/darklaf/ui/tabbedpane/DarkTabbedPaneUIBridge.java

File diff suppressed because it is too large Load Diff

17
src/main/java/com/weis/darklaf/ui/table/DarkColorTableCellRendererEditor.java

@ -4,6 +4,8 @@ import javax.swing.*;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.EventObject;
public class DarkColorTableCellRendererEditor extends AbstractCellEditor implements TableCellRenderer, TableCellEditor {
@ -13,11 +15,17 @@ public class DarkColorTableCellRendererEditor extends AbstractCellEditor impleme
public DarkColorTableCellRendererEditor() {
label = new JLabel();
label.setOpaque(true);
}
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value,
final boolean isSelected, final int row, final int column) {
if (!(value instanceof Color)) {
cancelCellEditing();
return table.getCellRenderer(row, column).getTableCellRendererComponent(table, value, isSelected,
true, row, column);
} else {
changeColor((Color) value);
SwingUtilities.invokeLater(() -> {
Color color = JColorChooser.showDialog(table, "Color Chooser", savedColor);
@ -29,6 +37,15 @@ public class DarkColorTableCellRendererEditor extends AbstractCellEditor impleme
});
return label;
}
}
@Override
public boolean isCellEditable(final EventObject anEvent) {
if (anEvent instanceof MouseEvent) {
return ((MouseEvent) anEvent).getClickCount() >= 2;
}
return true;
}
@Override
public Object getCellEditorValue() {

6
src/main/java/com/weis/darklaf/ui/table/DarkTableCellEditor.java

@ -188,11 +188,15 @@ public class DarkTableCellEditor extends DefaultCellEditor {
if (DarkTableCellRenderer.isBooleanRenderingEnabled(table)) {
var p = MouseInfo.getPointerInfo().getLocation();
SwingUtilities.convertPointFromScreen(p, table);
var value = table.getValueAt(table.rowAtPoint(p), table.columnAtPoint(p));
int row = table.rowAtPoint(p);
int col = table.columnAtPoint(p);
if (row >= 0 && row < table.getRowCount() && col >= 0 && col < table.getColumnCount()) {
var value = table.getValueAt(row, col);
if (useBooleanEditor(value, table)) {
return true;
}
}
}
return super.isCellEditable(anEvent);
}
}

20
src/main/java/com/weis/darklaf/ui/table/DarkTableCellFocusBorder.java

@ -0,0 +1,20 @@
package com.weis.darklaf.ui.table;
import com.weis.darklaf.ui.cell.DarkCellBorder;
import javax.swing.*;
import java.awt.*;
public class DarkTableCellFocusBorder extends DarkCellBorder {
@Override
public void paintBorder(final Component c, final Graphics g, final int x, final int y,
final int width, final int height) {
super.paintBorder(c, g, x, y, width, height);
g.setColor(UIManager.getColor("Table.focusBorderColor"));
g.fillRect(0, 0, width - 1, 1);
g.fillRect(0, 1, 1, height - 1);
g.fillRect(1, height - 1, width - 1, 1);
g.fillRect(width - 1, 0, 1, height - 1);
}
}

18
src/main/java/com/weis/darklaf/ui/table/DarkTableUI.java

@ -12,6 +12,7 @@ import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.beans.PropertyChangeListener;
public class DarkTableUI extends DarkTableUIBridge {
@ -39,6 +40,16 @@ public class DarkTableUI extends DarkTableUIBridge {
table.repaint();
}
};
private final PropertyChangeListener propertyChangeListener = e -> {
var key = e.getPropertyName();
if ("showHorizontalLines".equals(key)) {
var b = (boolean) e.getNewValue();
table.setRowMargin(b ? 1 : 0);
} else if ("showVerticalLines".equals(key)) {
var b = (boolean) e.getNewValue();
table.getColumnModel().setColumnMargin(b ? 1 : 0);
}
};
@NotNull
@Contract("_ -> new")
@ -86,12 +97,14 @@ public class DarkTableUI extends DarkTableUIBridge {
protected void installListeners() {
super.installListeners();
table.addFocusListener(focusListener);
table.addPropertyChangeListener(propertyChangeListener);
}
@Override
protected void uninstallListeners() {
super.uninstallListeners();
table.removeFocusListener(focusListener);
table.addPropertyChangeListener(propertyChangeListener);
}
@Override
@ -168,7 +181,10 @@ public class DarkTableUI extends DarkTableUIBridge {
}
if (!table.getShowHorizontalLines() && table.getRowCount() != 0 && !scrollVisible) {
g.setColor(getBorderColor());
int y = table.getHeight() - 1;
var clip = g.getClipBounds();
clip.height += 1;
g.setClip(clip);
int y = table.getHeight();
g.fillRect(0, y, table.getWidth(), 1);
}
}

2
src/main/java/com/weis/darklaf/ui/text/DarkCaret.java

@ -330,6 +330,6 @@ public class DarkCaret extends DefaultCaret implements UIResource {
UNDERLINE_STYLE,
BLOCK_STYLE,
BLOCK_BORDER_STYLE,
THICK_VERTICAL_LINE_STYLE;
THICK_VERTICAL_LINE_STYLE
}
}

2
src/main/java/com/weis/darklaf/ui/text/DarkTextBorder.java

@ -1,9 +1,9 @@
package com.weis.darklaf.ui.text;
import com.bulenkov.darcula.ui.DarculaTextBorder;
import com.weis.darklaf.util.DarkUIUtil;
import com.weis.darklaf.util.GraphicsContext;
import com.weis.darklaf.util.GraphicsUtil;
import com.weis.darklaf.util.DarkUIUtil;
import org.jetbrains.annotations.Contract;
import javax.swing.*;

5
src/main/resources/com/weis/darklaf/darcula.properties

@ -190,11 +190,12 @@ TableHeader.borderColor = 333638
TableUI = com.weis.darklaf.ui.table.DarkTableUI
Table.scrollPaneCornerComponent = com.weis.darklaf.ui.table.DarkTableHeaderCorner
Table.cellNoFocusBorder = com.weis.darklaf.ui.table.DarkTableCellBorder
Table.focusCellHighlightBorder = com.weis.darklaf.ui.table.DarkTableCellBorder
Table.focusSelectedCellHighlightBorder = com.weis.darklaf.ui.table.DarkTableCellBorder
Table.focusCellHighlightBorder = com.weis.darklaf.ui.table.DarkTableCellFocusBorder
Table.focusSelectedCellHighlightBorder = com.weis.darklaf.ui.table.DarkTableCellFocusBorder
Table.cellEditorBorder = com.weis.darklaf.ui.table.DarkTableCellBorder
Table.scrollPaneBorder = com.weis.darklaf.ui.table.DarkTableBorder
Table.background = 3c3f41
Table.focusBorderColor = 79C0FF
Table.gridColor = 4F5152
Table.dropLineColor = 4F5152
Table.focusSelectionBackground = 4b6eaf

2
src/main/resources/com/weis/darklaf/icons/java.svg

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 511.998 511.998" style="enable-background:new 0 0 511.998 511.998;" xml:space="preserve">
<g>
<path style="fill:#DB380E;" d="M253.464,94.869c-23.658,16.639-50.471,35.498-64.838,66.699

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

24
src/test/java/DnDTest.java

@ -42,17 +42,16 @@ public class DnDTest extends JFrame {
setLocationRelativeTo(null);
}
private class DragMouseAdapter extends MouseAdapter {
public static void main(final String[] args) {
public void mousePressed(MouseEvent e) {
EventQueue.invokeLater(() -> {
var c = (JComponent) e.getSource();
var handler = c.getTransferHandler();
handler.exportAsDrag(c, e, TransferHandler.COPY);
}
var ex = new DnDTest();
ex.setVisible(true);
});
}
private void createLayout(JComponent... arg) {
private void createLayout(final JComponent... arg) {
var pane = getContentPane();
var gl = new GroupLayout(pane);
@ -85,12 +84,13 @@ public class DnDTest extends JFrame {
pack();
}
public static void main(String[] args) {
private class DragMouseAdapter extends MouseAdapter {
EventQueue.invokeLater(() -> {
public void mousePressed(final MouseEvent e) {
var ex = new DnDTest();
ex.setVisible(true);
});
var c = (JComponent) e.getSource();
var handler = c.getTransferHandler();
handler.exportAsDrag(c, e, TransferHandler.COPY);
}
}
}

5
src/test/java/UIManagerDefaults.java

@ -32,14 +32,10 @@ import java.util.Vector;
public class UIManagerDefaults implements ItemListener {
private static final String[] COLUMN_NAMES = {"Key", "Value", "Sample"};
@Nullable
private static String selectedItem;
@NotNull
private final JComponent contentPane;
@NotNull
private final TreeMap<String, TreeMap<String, Object>> items;
@NotNull
private final HashMap<String, DefaultTableModel> models;
private JMenuBar menuBar;
private JComboBox<String> comboBox;
@ -154,6 +150,7 @@ public class UIManagerDefaults implements ItemListener {
final DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, 0);
table = new JTable(model);
table.setAutoCreateColumnsFromModel(false);
table.setShowHorizontalLines(false);
table.getColumnModel().getColumn(0).setPreferredWidth(250);
table.getColumnModel().getColumn(1).setPreferredWidth(500);
table.getColumnModel().getColumn(2).setPreferredWidth(100);

Loading…
Cancel
Save