|
|
@ -5,8 +5,14 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package com.fr.design.gui.itree.checkboxtree; |
|
|
|
package com.fr.design.gui.itree.checkboxtree; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import javax.swing.event.TreeSelectionEvent; |
|
|
|
|
|
|
|
import javax.swing.event.TreeSelectionListener; |
|
|
|
|
|
|
|
import javax.swing.text.Position; |
|
|
|
|
|
|
|
import javax.swing.tree.*; |
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyListener; |
|
|
|
import java.awt.event.KeyListener; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
@ -16,19 +22,6 @@ import java.beans.PropertyChangeListener; |
|
|
|
import java.util.Hashtable; |
|
|
|
import java.util.Hashtable; |
|
|
|
import java.util.Vector; |
|
|
|
import java.util.Vector; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
|
|
|
import javax.swing.event.TreeSelectionEvent; |
|
|
|
|
|
|
|
import javax.swing.event.TreeSelectionListener; |
|
|
|
|
|
|
|
import javax.swing.text.DefaultEditorKit; |
|
|
|
|
|
|
|
import javax.swing.text.Position; |
|
|
|
|
|
|
|
import javax.swing.tree.DefaultTreeCellRenderer; |
|
|
|
|
|
|
|
import javax.swing.tree.TreeCellRenderer; |
|
|
|
|
|
|
|
import javax.swing.tree.TreeModel; |
|
|
|
|
|
|
|
import javax.swing.tree.TreeNode; |
|
|
|
|
|
|
|
import javax.swing.tree.TreePath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.gui.icheckbox.UICheckBox; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -90,8 +83,7 @@ public class CheckBoxTree extends JTree { |
|
|
|
public CheckBoxTree(TreeModel newModel) { |
|
|
|
public CheckBoxTree(TreeModel newModel) { |
|
|
|
super(newModel); |
|
|
|
super(newModel); |
|
|
|
InputMap inputMap = this.getInputMap(); |
|
|
|
InputMap inputMap = this.getInputMap(); |
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), |
|
|
|
inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), "selectAll"); |
|
|
|
"selectAll"); |
|
|
|
|
|
|
|
init(); |
|
|
|
init(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -182,8 +174,7 @@ public class CheckBoxTree extends JTree { |
|
|
|
} |
|
|
|
} |
|
|
|
if (_treeCellRenderer == null) { |
|
|
|
if (_treeCellRenderer == null) { |
|
|
|
_treeCellRenderer = createCellRenderer(cellRenderer); |
|
|
|
_treeCellRenderer = createCellRenderer(cellRenderer); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
_treeCellRenderer.setActualTreeRenderer(cellRenderer); |
|
|
|
_treeCellRenderer.setActualTreeRenderer(cellRenderer); |
|
|
|
} |
|
|
|
} |
|
|
|
return _treeCellRenderer; |
|
|
|
return _treeCellRenderer; |
|
|
@ -199,8 +190,7 @@ public class CheckBoxTree extends JTree { |
|
|
|
public TreeCellRenderer getActualCellRenderer() { |
|
|
|
public TreeCellRenderer getActualCellRenderer() { |
|
|
|
if (_treeCellRenderer != null) { |
|
|
|
if (_treeCellRenderer != null) { |
|
|
|
return _treeCellRenderer.getActualTreeRenderer(); |
|
|
|
return _treeCellRenderer.getActualTreeRenderer(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return super.getCellRenderer(); |
|
|
|
return super.getCellRenderer(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -255,8 +245,7 @@ public class CheckBoxTree extends JTree { |
|
|
|
|
|
|
|
|
|
|
|
if (clicksInCheckBox(e, path)) { |
|
|
|
if (clicksInCheckBox(e, path)) { |
|
|
|
return path; |
|
|
|
return path; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -264,13 +253,11 @@ public class CheckBoxTree extends JTree { |
|
|
|
protected boolean clicksInCheckBox(MouseEvent e, TreePath path) { |
|
|
|
protected boolean clicksInCheckBox(MouseEvent e, TreePath path) { |
|
|
|
if (!_tree.isCheckBoxVisible(path)) { |
|
|
|
if (!_tree.isCheckBoxVisible(path)) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
Rectangle bounds = _tree.getPathBounds(path); |
|
|
|
Rectangle bounds = _tree.getPathBounds(path); |
|
|
|
if (_tree.getComponentOrientation().isLeftToRight()) { |
|
|
|
if (_tree.getComponentOrientation().isLeftToRight()) { |
|
|
|
return e.getX() < bounds.x + _hotspot; |
|
|
|
return e.getX() < bounds.x + _hotspot; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
return e.getX() > bounds.x + bounds.width - _hotspot; |
|
|
|
return e.getX() > bounds.x + bounds.width - _hotspot; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -354,8 +341,7 @@ public class CheckBoxTree extends JTree { |
|
|
|
selectionModel.removeSelectionPath(path); |
|
|
|
selectionModel.removeSelectionPath(path); |
|
|
|
else |
|
|
|
else |
|
|
|
selectionModel.addSelectionPath(path); |
|
|
|
selectionModel.addSelectionPath(path); |
|
|
|
} |
|
|
|
} finally { |
|
|
|
finally { |
|
|
|
|
|
|
|
if (!selectionModel.isSingleEventMode()) { |
|
|
|
if (!selectionModel.isSingleEventMode()) { |
|
|
|
selectionModel.setBatchMode(false); |
|
|
|
selectionModel.setBatchMode(false); |
|
|
|
} |
|
|
|
} |
|
|
|