Browse Source

formatting.

Refactored table ui.
pull/170/head
weisj 5 years ago
parent
commit
1e1f02f241
  1. 1
      core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java
  2. 303
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java
  3. 297
      core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java
  4. 1
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderBorder.java
  5. 1
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderCorner.java
  6. 9
      core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java
  7. 1
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkColorTableCellRendererEditor.java
  8. 1
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditor.java
  9. 2
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellEditorToggleButton.java
  10. 2
      core/src/main/java/com/github/weisj/darklaf/ui/table/renderer/DarkTableCellRenderer.java
  11. 1
      core/src/main/java/com/github/weisj/darklaf/ui/text/action/SelectLineAction.java
  12. 1
      core/src/main/java/com/github/weisj/darklaf/ui/text/action/SelectWordAction.java

1
core/src/main/java/com/github/weisj/darklaf/ui/combobox/DarkComboBoxBorder.java

@ -31,7 +31,6 @@ import javax.swing.border.Border;
import javax.swing.plaf.InsetsUIResource;
import javax.swing.plaf.UIResource;
import com.github.weisj.darklaf.graphics.GraphicsContext;
import com.github.weisj.darklaf.graphics.PaintUtil;
import com.github.weisj.darklaf.ui.cell.CellUtil;

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

@ -26,7 +26,7 @@ package com.github.weisj.darklaf.ui.table;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.util.Objects;
import java.util.function.Supplier;
@ -53,7 +53,7 @@ import com.github.weisj.darklaf.util.PropertyUtil;
/**
* @author Jannis Weis
*/
public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
public class DarkTableUI extends DarkTableUIBridge {
public static final String KEY_IS_TABLE_EDITOR = "JComponent.isTableEditor";
public static final String KEY_IS_TABLE_RENDERER = "JComponent.isTableRenderer";
@ -74,42 +74,10 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
public static final String RENDER_TYPE_RADIOBUTTON = "radioButton";
private static final int ROW_HEIGHT_FALLBACK = 22;
private final PropertyChangeListener propertyChangeListener = e -> {
String key = e.getPropertyName();
if (KEY_HORIZONTAL_LINES.equals(key)) {
boolean b = Boolean.TRUE.equals(e.getNewValue());
table.setRowMargin(b ? 1 : 0);
} else if (KEY_VERTICAL_LINES.equals(key)) {
boolean b = Boolean.TRUE.equals(e.getNewValue());
table.getColumnModel().setColumnMargin(b ? 1 : 0);
} else if (PropertyKey.ANCESTOR.equals(key)) {
Object oldVal = e.getOldValue();
Object newVal = e.getNewValue();
if (oldVal instanceof Component) {
Container oldUnwrapped = DarkUIUtil.getUnwrappedParent((Component) oldVal);
LookAndFeel.uninstallBorder((JComponent) oldUnwrapped);
}
if (newVal instanceof Component) {
Container newUnwrapped = DarkUIUtil.getUnwrappedParent((Component) newVal);
if ((newUnwrapped instanceof JScrollPane)) {
LookAndFeel.installBorder((JComponent) newUnwrapped, "Table.scrollPaneBorder");
}
}
checkFocus();
} else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) {
table.doLayout();
table.repaint();
} else if (KEY_ALTERNATE_ROW_COLOR.equals(key)
|| KEY_RENDER_BOOLEAN_AS_CHECKBOX.equals(key)
|| KEY_BOOLEAN_RENDER_TYPE.equals(key)) {
table.repaint();
} else if (PropertyKey.ENABLED.equals(key)) {
DarkUIUtil.repaint(table.getTableHeader());
}
};
protected Color selectionBackgroundNoFocus;
protected Color selectionBackground;
protected Color borderColor;
protected Handler handler;
public static ComponentUI createUI(final JComponent c) {
return new DarkTableUI();
@ -120,54 +88,23 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
}
@Override
public void installUI(final JComponent c) {
super.installUI(c);
protected FocusListener createFocusListener() {
return getHandler();
}
@Override
protected void installListeners() {
super.installListeners();
table.addFocusListener(this);
table.addPropertyChangeListener(propertyChangeListener);
protected KeyListener createKeyListener() {
return getHandler();
}
@Override
protected Handler getHandler() {
if (handler == null) {
handler = new DarkHandler();
handler = new DarkHandler(super.createKeyListener(), super.createFocusListener());
}
return handler;
}
@Override
public void focusGained(final FocusEvent e) {
Color bg = table.getSelectionBackground();
if (bg instanceof UIResource) {
table.setSelectionBackground(selectionBackground);
}
table.repaint();
}
@Override
public void focusLost(final FocusEvent e) {
Color bg = table.getSelectionBackground();
if (bg instanceof UIResource) {
if (table.isEditing()) {
table.setSelectionBackground(table.getBackground());
} else {
table.setSelectionBackground(selectionBackgroundNoFocus);
}
}
table.repaint();
}
@Override
protected void uninstallListeners() {
super.uninstallListeners();
table.removeFocusListener(this);
table.removePropertyChangeListener(propertyChangeListener);
}
@Override
protected void uninstallDefaults() {
super.uninstallDefaults();
@ -175,8 +112,10 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
LookAndFeel.uninstallBorder((JComponent) oldUnwrapped);
}
protected Color getBorderColor() {
return borderColor;
@Override
protected void uninstallListeners() {
super.uninstallListeners();
handler = null;
}
@Override
@ -208,31 +147,12 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
DarkColorTableCellRendererEditor colorRendererEditor = new DarkColorTableCellRendererEditor();
table.setDefaultRenderer(Object.class, cellRenderer);
table.setDefaultRenderer(String.class, cellRenderer);
table.setDefaultRenderer(Integer.class, cellRenderer);
table.setDefaultRenderer(Double.class, cellRenderer);
table.setDefaultRenderer(Float.class, cellRenderer);
table.setDefaultRenderer(Boolean.class, cellRenderer);
table.setDefaultRenderer(Color.class, colorRendererEditor);
table.setDefaultEditor(Object.class, cellEditor);
table.setDefaultEditor(String.class, cellEditor);
table.setDefaultEditor(Integer.class, cellEditor);
table.setDefaultEditor(Double.class, cellEditor);
table.setDefaultEditor(Float.class, cellEditor);
table.setDefaultEditor(Boolean.class, cellEditor);
table.setDefaultEditor(Color.class, colorRendererEditor);
}
protected void checkFocus() {
boolean focus = DarkUIUtil.hasFocus(table);
if (focus) {
focusGained(null);
} else {
focusLost(null);
}
}
@Override
protected void paintGrid(final Graphics g,
final int rMin, final int rMax, final int cMin, final int cMax) {
@ -420,7 +340,7 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
if (table.getShowHorizontalLines()) {
g.setColor(table.getGridColor());
Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true);
rcr.x += distance;
rcr.x += dist;
int x1 = rcr.x;
int y1 = rcr.y;
int x2 = x1 + rcr.width;
@ -463,69 +383,6 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
return false;
}
protected class DarkHandler extends Handler {
protected int lastIndex = -1;
@Override
public void mouseClicked(final MouseEvent e) {
super.mouseClicked(e);
if (isFileList && SwingUtilities.isLeftMouseButton(e)) {
int row = table.rowAtPoint(e.getPoint());
JFileChooser fc = getFileChooser();
if (row < 0 || fc == null) return;
int column = getFileNameColumnIndex();
boolean isSelected = table.getSelectionModel().getLeadSelectionIndex() == row
&& table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == column;
if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1)
&& isSelected && lastIndex == row
&& DarkUIUtil.isOverText(e, row, column, table)) {
startEditing(row, column);
} else {
lastIndex = row;
}
}
}
@Override
public void mousePressed(final MouseEvent e) {
super.mousePressed(e);
if (SwingUtilities.isLeftMouseButton(e)) {
table.repaint();
}
}
protected JFileChooser getFileChooser() {
Object obj = PropertyUtil.getObject(table, DarkTableUI.KEY_FILE_CHOOSER_PARENT, Supplier.class, Object::new)
.get();
return obj instanceof JFileChooser ? (JFileChooser) obj : null;
}
protected Integer getFileNameColumnIndex() {
return PropertyUtil.getInteger(table, DarkTableUI.KEY_FILENAME_COLUMN_INDEX);
}
protected void startEditing(final int row, final int column) {
table.editCellAt(row, column, null);
Component editorComponent = table.getEditorComponent();
if (editorComponent != null && !editorComponent.hasFocus()) {
SwingUtilities2.compositeRequestFocus(editorComponent);
}
}
@Override
protected void maybeStartTimer() {}
@Override
public void actionPerformed(final ActionEvent ae) {}
@Override
public void keyTyped(final KeyEvent e) {
if (ignoreKeyCodeOnEdit(e, table)) return;
super.keyTyped(e);
}
}
@Override
protected void paintCell(final Graphics g, final Rectangle cellRect, final int row, final int column) {
Rectangle bounds = table.getVisibleRect();
@ -605,4 +462,138 @@ public class DarkTableUI extends DarkTableUIBridge implements FocusListener {
}
return dist;
}
protected class DarkHandler extends Handler {
protected int lastIndex = -1;
protected DarkHandler(final KeyListener keyListener, final FocusListener focusListener) {
super(keyListener, focusListener);
}
@Override
public void mouseClicked(final MouseEvent e) {
super.mouseClicked(e);
if (isFileList && SwingUtilities.isLeftMouseButton(e)) {
int row = table.rowAtPoint(e.getPoint());
JFileChooser fc = getFileChooser();
if (row < 0 || fc == null) return;
int column = getFileNameColumnIndex();
boolean isSelected = table.getSelectionModel().getLeadSelectionIndex() == row
&& table.getColumnModel().getSelectionModel().getLeadSelectionIndex() == column;
if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1)
&& isSelected && lastIndex == row
&& DarkUIUtil.isOverText(e, row, column, table)) {
startEditing(row, column);
} else {
lastIndex = row;
}
}
}
@Override
public void mousePressed(final MouseEvent e) {
super.mousePressed(e);
if (SwingUtilities.isLeftMouseButton(e)) {
table.repaint();
}
}
protected JFileChooser getFileChooser() {
Object obj = PropertyUtil.getObject(table, DarkTableUI.KEY_FILE_CHOOSER_PARENT, Supplier.class, Object::new)
.get();
return obj instanceof JFileChooser ? (JFileChooser) obj : null;
}
protected Integer getFileNameColumnIndex() {
return PropertyUtil.getInteger(table, DarkTableUI.KEY_FILENAME_COLUMN_INDEX);
}
protected void startEditing(final int row, final int column) {
table.editCellAt(row, column, null);
Component editorComponent = table.getEditorComponent();
if (editorComponent != null && !editorComponent.hasFocus()) {
SwingUtilities2.compositeRequestFocus(editorComponent);
}
}
@Override
protected void maybeStartTimer() {}
@Override
public void actionPerformed(final ActionEvent ae) {}
@Override
public void keyTyped(final KeyEvent e) {
if (ignoreKeyCodeOnEdit(e, table)) return;
super.keyTyped(e);
}
@Override
public void propertyChange(final PropertyChangeEvent e) {
super.propertyChange(e);
String key = e.getPropertyName();
if (KEY_HORIZONTAL_LINES.equals(key)) {
boolean b = Boolean.TRUE.equals(e.getNewValue());
table.setRowMargin(b ? 1 : 0);
} else if (KEY_VERTICAL_LINES.equals(key)) {
boolean b = Boolean.TRUE.equals(e.getNewValue());
table.getColumnModel().setColumnMargin(b ? 1 : 0);
} else if (PropertyKey.ANCESTOR.equals(key)) {
Object oldVal = e.getOldValue();
Object newVal = e.getNewValue();
if (oldVal instanceof Component) {
Container oldUnwrapped = DarkUIUtil.getUnwrappedParent((Component) oldVal);
LookAndFeel.uninstallBorder((JComponent) oldUnwrapped);
}
if (newVal instanceof Component) {
Container newUnwrapped = DarkUIUtil.getUnwrappedParent((Component) newVal);
if ((newUnwrapped instanceof JScrollPane)) {
LookAndFeel.installBorder((JComponent) newUnwrapped, "Table.scrollPaneBorder");
}
}
checkFocus();
} else if (PropertyKey.COMPONENT_ORIENTATION.equals(key)) {
table.doLayout();
table.repaint();
} else if (KEY_ALTERNATE_ROW_COLOR.equals(key)
|| KEY_RENDER_BOOLEAN_AS_CHECKBOX.equals(key)
|| KEY_BOOLEAN_RENDER_TYPE.equals(key)) {
table.repaint();
} else if (PropertyKey.ENABLED.equals(key)) {
DarkUIUtil.repaint(table.getTableHeader());
}
}
@Override
public void focusGained(final FocusEvent e) {
Color bg = table.getSelectionBackground();
if (bg instanceof UIResource) {
table.setSelectionBackground(selectionBackground);
}
table.repaint();
}
@Override
public void focusLost(final FocusEvent e) {
Color bg = table.getSelectionBackground();
if (bg instanceof UIResource) {
if (table.isEditing()) {
table.setSelectionBackground(table.getBackground());
} else {
table.setSelectionBackground(selectionBackgroundNoFocus);
}
}
table.repaint();
}
protected void checkFocus() {
boolean focus = DarkUIUtil.hasFocus(table);
if (focus) {
focusGained(null);
} else {
focusLost(null);
}
}
}
}

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

@ -36,14 +36,15 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.MouseInputListener;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicTableUI;
import javax.swing.table.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import sun.swing.DefaultLookup;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.ui.DragRecognitionSupport;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil;
/**
@ -60,31 +61,6 @@ public abstract class TableUIBridge extends BasicTableUI {
// Instance Variables
//
/**
* The instance of {@code JTable}.
*/
protected JTable table;
/**
* The instance of {@code CellRendererPane}.
*/
protected CellRendererPane rendererPane;
/**
* {@code KeyListener} that are attached to the {@code JTable}.
*/
protected KeyListener keyListener;
/**
* {@code FocusListener} that are attached to the {@code JTable}.
*/
protected FocusListener focusListener;
/**
* {@code MouseInputListener} that are attached to the {@code JTable}.
*/
protected MouseInputListener mouseInputListener;
/**
* The Handler.
*/
protected Handler handler;
//
// Helper class for keyboard actions
//
@ -161,12 +137,9 @@ public abstract class TableUIBridge extends BasicTableUI {
public void installUI(final JComponent c) {
table = (JTable) c;
super.installUI(c);
table.remove(rendererPane);
rendererPane = new CellRendererPane();
table.add(rendererPane);
installDefaults();
installListeners();
installKeyboardActions();
}
/**
@ -177,45 +150,7 @@ public abstract class TableUIBridge extends BasicTableUI {
* @see #installUI #installUI
*/
protected void installDefaults() {
LookAndFeel.installColorsAndFont(table, "Table.background",
"Table.foreground", "Table.font");
// JTable's original row height is 16. To correctly display the
// contents on Linux we should have set it to 18, Windows 19 and
// Solaris 20. As these values vary so much it's too hard to
// be backward compatable and try to update the row height, we're
// therefor NOT going to adjust the row height based on font. If the
// developer changes the font, it's there responsability to update
// the row height.
LookAndFeel.installProperty(table, PropertyKey.OPAQUE, Boolean.TRUE);
Color sbg = table.getSelectionBackground();
if (sbg == null || sbg instanceof UIResource) {
sbg = UIManager.getColor("Table.selectionBackground");
table.setSelectionBackground(sbg != null ? sbg : UIManager.getColor("textHighlight"));
}
Color sfg = table.getSelectionForeground();
if (sfg == null || sfg instanceof UIResource) {
sfg = UIManager.getColor("Table.selectionForeground");
table.setSelectionForeground(sfg != null ? sfg : UIManager.getColor("textHighlightText"));
}
Color gridColor = table.getGridColor();
if (gridColor == null || gridColor instanceof UIResource) {
gridColor = UIManager.getColor("Table.gridColor");
table.setGridColor(gridColor != null ? gridColor : Color.GRAY);
}
// install the scrollpane border
Container parent = DarkUIUtil.getUnwrappedParent(table); // should be viewport
if (parent != null) {
parent = parent.getParent(); // should be the scrollpane
if (parent instanceof JScrollPane) {
LookAndFeel.installBorder((JScrollPane) parent, "Table.scrollPaneBorder");
}
}
super.installDefaults();
isFileList = PropertyUtil.getBooleanProperty(table, DarkTableUI.KEY_IS_FILE_LIST);
}
@ -223,18 +158,9 @@ public abstract class TableUIBridge extends BasicTableUI {
* Attaches listeners to the JTable.
*/
protected void installListeners() {
focusListener = createFocusListener();
keyListener = createKeyListener();
super.installListeners();
mouseInputListener = createMouseInputListener();
table.addFocusListener(focusListener);
table.addKeyListener(keyListener);
table.addMouseListener(mouseInputListener);
table.addMouseMotionListener(mouseInputListener);
table.addPropertyChangeListener(getHandler());
if (isFileList) {
table.getSelectionModel().addListSelectionListener(getHandler());
}
}
//
@ -243,24 +169,6 @@ public abstract class TableUIBridge extends BasicTableUI {
// Installation
/**
* Creates the focus listener for handling keyboard navigation in the {@code JTable}.
*
* @return the focus listener for handling keyboard navigation in the {@code JTable}
*/
protected FocusListener createFocusListener() {
return getHandler();
}
/**
* Creates the key listener for handling keyboard navigation in the {@code JTable}.
*
* @return the key listener for handling keyboard navigation in the {@code JTable}
*/
protected KeyListener createKeyListener() {
return null;
}
/**
* Creates the mouse listener for the {@code JTable}.
*
@ -271,16 +179,11 @@ public abstract class TableUIBridge extends BasicTableUI {
}
/**
* Gets handler.
* Gets handlerF.
*
* @return the handler
*/
protected Handler getHandler() {
if (handler == null) {
handler = new Handler();
}
return handler;
}
protected abstract Handler getHandler();
/**
* Gets input map.
@ -343,7 +246,6 @@ public abstract class TableUIBridge extends BasicTableUI {
focusListener = null;
keyListener = null;
mouseInputListener = null;
handler = null;
}
/**
@ -628,7 +530,10 @@ public abstract class TableUIBridge extends BasicTableUI {
*/
protected class Handler implements FocusListener, MouseInputListener,
PropertyChangeListener, ListSelectionListener, ActionListener,
DragRecognitionSupport.BeforeDrag {
DragRecognitionSupport.BeforeDrag, KeyListener {
protected final FocusListener focusListener;
protected final KeyListener keyListener;
/**
* The Dispatch component.
@ -683,113 +588,34 @@ public abstract class TableUIBridge extends BasicTableUI {
// Used to delay the start of editing.
protected Timer timer = null;
public void focusGained(final FocusEvent e) {
repaintLeadCell();
}
/**
* Repaint lead cell.
*/
// FocusListener
protected void repaintLeadCell() {
int lr = getAdjustedLead(table, true);
int lc = getAdjustedLead(table, false);
if (lr < 0 || lc < 0) {
return;
protected Handler(final KeyListener keyListener, final FocusListener focusListener) {
this.keyListener = keyListener;
this.focusListener = focusListener;
}
Rectangle dirtyRect = table.getCellRect(lr, lc, false);
table.repaint(dirtyRect);
@Override
public void focusGained(final FocusEvent e) {
if (focusListener != null) focusListener.focusGained(e);
}
@Override
public void focusLost(final FocusEvent e) {
repaintLeadCell();
if (focusListener != null) focusListener.focusLost(e);
}
/**
* Key pressed.
*
* @param e the e
*/
// KeyListener
public void keyPressed(final KeyEvent e) {}
/**
* Key released.
*
* @param e the e
*/
public void keyReleased(final KeyEvent e) {}
/**
* Key typed.
*
* @param e the e
*/
@SuppressWarnings("deprecation")
public void keyTyped(final KeyEvent e) {
KeyStroke keyStroke = KeyStroke.getKeyStroke(e.getKeyChar(),
e.getModifiers());
// We register all actions using ANCESTOR_OF_FOCUSED_COMPONENT
// which means that we might perform the appropriate action
// in the table and then forward it to the editor if the editor
// had focus. Make sure this doesn't happen by checking our
// InputMaps.
InputMap map = table.getInputMap(JComponent.WHEN_FOCUSED);
if (map != null && map.get(keyStroke) != null) {
return;
}
map = table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
if (map != null && map.get(keyStroke) != null) {
return;
}
keyStroke = KeyStroke.getKeyStrokeForEvent(e);
// The AWT seems to generate an unconsumed \r event when
// ENTER (\n) is pressed.
if (e.getKeyChar() == '\r') {
return;
@Override
public void keyPressed(final KeyEvent e) {
if (keyListener != null) keyListener.keyPressed(e);
}
int leadRow = getAdjustedLead(table, true);
int leadColumn = getAdjustedLead(table, false);
if (leadRow != -1 && leadColumn != -1 && !table.isEditing()) {
if (!table.editCellAt(leadRow, leadColumn)) {
return;
@Override
public void keyReleased(final KeyEvent e) {
if (keyListener != null) keyListener.keyReleased(e);
}
}
// Forwarding events this way seems to put the component
// in a state where it believes it has focus. In reality
// the table retains focus - though it is difficult for
// a user to tell, since the caret is visible and flashing.
// Calling table.requestFocus() here, to get the focus back to
// the table, seems to have no effect.
Component editorComp = table.getEditorComponent();
if (table.isEditing() && editorComp != null) {
if (editorComp instanceof JComponent) {
JComponent component = (JComponent) editorComp;
map = component.getInputMap(JComponent.WHEN_FOCUSED);
Object binding = (map != null) ? map.get(keyStroke) : null;
if (binding == null) {
map = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
binding = (map != null) ? map.get(keyStroke) : null;
}
if (binding != null) {
ActionMap am = component.getActionMap();
Action action = (am != null) ? am.get(binding) : null;
if (action != null && SwingUtilities.notifyAction(action, keyStroke, e, component,
e.getModifiers())) {
e.consume();
}
}
}
}
@Override
public void keyTyped(final KeyEvent e) {
if (keyListener != null) keyListener.keyTyped(e);
}
public void mouseClicked(final MouseEvent e) {}
@ -1123,71 +949,8 @@ public abstract class TableUIBridge extends BasicTableUI {
// PropertyChangeListener
public void propertyChange(final PropertyChangeEvent event) {
String changeName = event.getPropertyName();
if (PropertyKey.COMPONENT_ORIENTATION.equals(changeName)) {
InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
SwingUtilities.replaceUIInputMap(table,
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
inputMap);
JTableHeader header = table.getTableHeader();
if (header != null) {
header.setComponentOrientation((ComponentOrientation) event.getNewValue());
}
} else if ("dropLocation".equals(changeName)) {
JTable.DropLocation oldValue = (JTable.DropLocation) event.getOldValue();
repaintDropLocation(oldValue);
repaintDropLocation(table.getDropLocation());
} else if (DarkTableUI.KEY_IS_FILE_LIST.equals(changeName)) {
if (DarkTableUI.KEY_IS_FILE_LIST.equals(changeName)) {
isFileList = PropertyUtil.getBooleanProperty(table, DarkTableUI.KEY_IS_FILE_LIST);
table.revalidate();
table.repaint();
if (isFileList) {
table.getSelectionModel().addListSelectionListener(getHandler());
} else {
table.getSelectionModel().removeListSelectionListener(getHandler());
timer = null;
}
} else if ("selectionModel".equals(changeName)) {
if (isFileList) {
ListSelectionModel old = (ListSelectionModel) event.getOldValue();
old.removeListSelectionListener(getHandler());
table.getSelectionModel().addListSelectionListener(getHandler());
}
}
}
/**
* Repaint drop location.
*
* @param loc the loc
*/
protected void repaintDropLocation(final JTable.DropLocation loc) {
if (loc == null) {
return;
}
if (!loc.isInsertRow() && !loc.isInsertColumn()) {
Rectangle rect = table.getCellRect(loc.getRow(), loc.getColumn(), false);
if (rect != null) {
table.repaint(rect);
}
return;
}
if (loc.isInsertRow()) {
Rectangle rect = extendRect(getHDropLineRect(loc), true);
if (rect != null) {
table.repaint(rect);
}
}
if (loc.isInsertColumn()) {
Rectangle rect = extendRect(getVDropLineRect(loc), false);
if (rect != null) {
table.repaint(rect);
}
}
}
}

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

@ -20,6 +20,7 @@
* 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;

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

@ -20,6 +20,7 @@
* 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;

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

@ -20,6 +20,7 @@
* 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;
@ -50,14 +51,10 @@ public class DarkTableHeaderUI extends BasicTableHeaderUI {
@Override
public void installUI(final JComponent c) {
header = (JTableHeader) c;
super.installUI(c);
header.remove(rendererPane);
rendererPane = createCellRendererPane();
header.add(rendererPane);
installDefaults();
installListeners();
installKeyboardActions();
}
@Override

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

@ -20,6 +20,7 @@
* 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.renderer;

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

@ -20,6 +20,7 @@
* 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.renderer;

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

@ -20,6 +20,7 @@
* 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.renderer;
@ -31,7 +32,6 @@ import javax.swing.table.TableCellEditor;
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;
/**

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

@ -20,6 +20,7 @@
* 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.renderer;
@ -70,7 +71,6 @@ public class DarkTableCellRenderer extends DefaultTableCellRenderer {
boolean isLeadSelectionCell = DarkUIUtil.hasFocus(table) && hasFocus && !isRowFocus;
boolean paintSelected = isSelected && !isLeadSelectionCell && !table.isEditing();
setupBorderStyle(table, row, column, component, isRowFocus);
CellUtil.setupTableForeground(component, table, paintSelected);
CellUtil.setupTableBackground(component, table, paintSelected, row);

1
core/src/main/java/com/github/weisj/darklaf/ui/text/action/SelectLineAction.java

@ -20,6 +20,7 @@
* 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.text.action;

1
core/src/main/java/com/github/weisj/darklaf/ui/text/action/SelectWordAction.java

@ -20,6 +20,7 @@
* 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.text.action;

Loading…
Cancel
Save