|
|
@ -23,6 +23,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package com.github.weisj.darklaf.ui.tree; |
|
|
|
package com.github.weisj.darklaf.ui.tree; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.weisj.darklaf.util.DarkUIUtil; |
|
|
|
import com.github.weisj.darklaf.util.SystemInfo; |
|
|
|
import com.github.weisj.darklaf.util.SystemInfo; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import javax.swing.*; |
|
|
@ -53,7 +54,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { |
|
|
|
public static final String TREE_TABLE_TREE_KEY = "JTree.treeTableTree"; |
|
|
|
public static final String TREE_TABLE_TREE_KEY = "JTree.treeTableTree"; |
|
|
|
public static final String STRIPED_CLIENT_PROPERTY = "JTree.alternateRowColor"; |
|
|
|
public static final String STRIPED_CLIENT_PROPERTY = "JTree.alternateRowColor"; |
|
|
|
|
|
|
|
|
|
|
|
private final MouseListener mySelectionListener = new MouseAdapter() { |
|
|
|
private final MouseListener selectionListener = new MouseAdapter() { |
|
|
|
boolean handled = false; |
|
|
|
boolean handled = false; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -167,7 +168,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { |
|
|
|
protected void installListeners() { |
|
|
|
protected void installListeners() { |
|
|
|
super.installListeners(); |
|
|
|
super.installListeners(); |
|
|
|
tree.addPropertyChangeListener(this); |
|
|
|
tree.addPropertyChangeListener(this); |
|
|
|
tree.addMouseListener(mySelectionListener); |
|
|
|
tree.addMouseListener(selectionListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -298,18 +299,40 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected FocusListener createFocusListener() { |
|
|
|
protected FocusListener createFocusListener() { |
|
|
|
return new FocusListener() { |
|
|
|
return new FocusListener() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean focused = false; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void focusGained(final FocusEvent e) { |
|
|
|
public void focusGained(final FocusEvent e) { |
|
|
|
tree.repaint(); |
|
|
|
if (!focused) { |
|
|
|
|
|
|
|
tree.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
focused = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void focusLost(final FocusEvent e) { |
|
|
|
public void focusLost(final FocusEvent e) { |
|
|
|
tree.repaint(); |
|
|
|
tree.stopEditing(); |
|
|
|
|
|
|
|
if (!hasFocus()) { |
|
|
|
|
|
|
|
tree.repaint(); |
|
|
|
|
|
|
|
focused = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean hasFocus() { |
|
|
|
|
|
|
|
if (!DarkUIUtil.hasFocus(tree)) { |
|
|
|
|
|
|
|
Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); |
|
|
|
|
|
|
|
boolean treeEditor = owner instanceof JComponent |
|
|
|
|
|
|
|
&& Boolean.TRUE.equals(((JComponent) owner).getClientProperty("JToggleButton.isTreeCellEditor")); |
|
|
|
|
|
|
|
boolean treeRenderer = owner instanceof JComponent |
|
|
|
|
|
|
|
&& Boolean.TRUE.equals(((JComponent) owner).getClientProperty("JToggleButton.isTreeCellRenderer")); |
|
|
|
|
|
|
|
return owner == null || treeEditor || treeRenderer; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected TreeCellEditor createDefaultCellEditor() { |
|
|
|
protected TreeCellEditor createDefaultCellEditor() { |
|
|
|
if (currentCellRenderer != null && (currentCellRenderer instanceof DarkTreeCellRenderer)) { |
|
|
|
if (currentCellRenderer != null && (currentCellRenderer instanceof DarkTreeCellRenderer)) { |
|
|
@ -332,7 +355,7 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void uninstallListeners() { |
|
|
|
protected void uninstallListeners() { |
|
|
|
super.uninstallListeners(); |
|
|
|
super.uninstallListeners(); |
|
|
|
tree.removeMouseListener(mySelectionListener); |
|
|
|
tree.removeMouseListener(selectionListener); |
|
|
|
tree.removePropertyChangeListener(this); |
|
|
|
tree.removePropertyChangeListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|