44 |
import java.awt.Font; |
import java.awt.Font; |
45 |
import java.awt.FontMetrics; |
import java.awt.FontMetrics; |
46 |
import java.awt.Graphics; |
import java.awt.Graphics; |
47 |
|
import java.awt.Insets; |
48 |
import java.awt.Point; |
import java.awt.Point; |
49 |
import java.awt.Rectangle; |
import java.awt.Rectangle; |
50 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
63 |
import java.awt.event.MouseMotionListener; |
import java.awt.event.MouseMotionListener; |
64 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
65 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
66 |
|
import java.util.Enumeration; |
67 |
import java.util.Hashtable; |
import java.util.Hashtable; |
68 |
|
|
69 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
98 |
import javax.swing.tree.AbstractLayoutCache; |
import javax.swing.tree.AbstractLayoutCache; |
99 |
import javax.swing.tree.DefaultTreeCellEditor; |
import javax.swing.tree.DefaultTreeCellEditor; |
100 |
import javax.swing.tree.DefaultTreeCellRenderer; |
import javax.swing.tree.DefaultTreeCellRenderer; |
|
import javax.swing.tree.ExpandVetoException; |
|
101 |
import javax.swing.tree.FixedHeightLayoutCache; |
import javax.swing.tree.FixedHeightLayoutCache; |
102 |
import javax.swing.tree.TreeCellEditor; |
import javax.swing.tree.TreeCellEditor; |
103 |
import javax.swing.tree.TreeCellRenderer; |
import javax.swing.tree.TreeCellRenderer; |
175 |
|
|
176 |
/** Size needed to completely display all the nodes. */ |
/** Size needed to completely display all the nodes. */ |
177 |
protected Dimension preferredSize; |
protected Dimension preferredSize; |
178 |
|
|
179 |
|
/** Minimum size needed to completely display all the nodes. */ |
180 |
|
protected Dimension preferredMinSize; |
181 |
|
|
182 |
/** Is the preferredSize valid? */ |
/** Is the preferredSize valid? */ |
183 |
protected boolean validCachedPreferredSize; |
protected boolean validCachedPreferredSize; |
229 |
protected boolean editorHasDifferentSize; |
protected boolean editorHasDifferentSize; |
230 |
|
|
231 |
/** The action listener for the editor's Timer. */ |
/** The action listener for the editor's Timer. */ |
232 |
private Timer editorTimer = new EditorUpdateTimer(); |
Timer editorTimer = new EditorUpdateTimer(); |
233 |
|
|
234 |
/** The new value of the node after editing. */ |
/** The new value of the node after editing. */ |
235 |
private Object newVal; |
Object newVal; |
236 |
|
|
237 |
/** The action bound to KeyStrokes. */ |
/** The action bound to KeyStrokes. */ |
238 |
private TreeAction action; |
TreeAction action; |
239 |
|
|
240 |
/** Boolean to keep track of editing. */ |
/** Boolean to keep track of editing. */ |
241 |
private boolean isEditing; |
boolean isEditing; |
242 |
|
|
243 |
|
/** The bounds of the current cell. */ |
244 |
|
Rectangle bounds; |
245 |
|
|
246 |
/** Listeners */ |
/** Listeners */ |
247 |
private PropertyChangeListener propertyChangeListener; |
private PropertyChangeListener propertyChangeListener; |
|
|
|
248 |
private FocusListener focusListener; |
private FocusListener focusListener; |
|
|
|
249 |
private TreeSelectionListener treeSelectionListener; |
private TreeSelectionListener treeSelectionListener; |
|
|
|
250 |
private MouseInputListener mouseInputListener; |
private MouseInputListener mouseInputListener; |
|
|
|
251 |
private KeyListener keyListener; |
private KeyListener keyListener; |
|
|
|
252 |
private PropertyChangeListener selectionModelPropertyChangeListener; |
private PropertyChangeListener selectionModelPropertyChangeListener; |
|
|
|
253 |
private ComponentListener componentListener; |
private ComponentListener componentListener; |
|
|
|
254 |
private CellEditorListener cellEditorListener; |
private CellEditorListener cellEditorListener; |
|
|
|
255 |
private TreeExpansionListener treeExpansionListener; |
private TreeExpansionListener treeExpansionListener; |
|
|
|
256 |
private TreeModelListener treeModelListener; |
private TreeModelListener treeModelListener; |
257 |
|
|
258 |
/** |
/** |
454 |
protected void setCellRenderer(TreeCellRenderer tcr) |
protected void setCellRenderer(TreeCellRenderer tcr) |
455 |
{ |
{ |
456 |
currentCellRenderer = tcr; |
currentCellRenderer = tcr; |
|
tree.setCellRenderer(tcr); |
|
457 |
updateRenderer(); |
updateRenderer(); |
458 |
} |
} |
459 |
|
|
622 |
{ |
{ |
623 |
Object cell = path.getLastPathComponent(); |
Object cell = path.getLastPathComponent(); |
624 |
|
|
625 |
TreeModel mod = tree.getModel(); |
if (treeModel != null) |
|
if (mod != null) |
|
626 |
{ |
{ |
627 |
Object root = mod.getRoot(); |
Object root = treeModel.getRoot(); |
628 |
if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) |
if (!tree.isRootVisible() && tree.isExpanded(new TreePath(root))) |
629 |
root = getNextNode(root); |
root = getNextNode(root); |
630 |
|
|
631 |
Point loc = getCellLocation(0, 0, tree, mod, cell, root); |
Point loc = getCellLocation(0, 0, tree, treeModel, cell, root); |
632 |
return getCellBounds(loc.x, loc.y, cell); |
return getCellBounds(loc.x, loc.y, cell); |
633 |
} |
} |
634 |
} |
} |
646 |
*/ |
*/ |
647 |
public TreePath getPathForRow(JTree tree, int row) |
public TreePath getPathForRow(JTree tree, int row) |
648 |
{ |
{ |
649 |
TreeModel mod = tree.getModel(); |
if (treeModel != null) |
|
if (mod != null) |
|
650 |
{ |
{ |
651 |
Object node = mod.getRoot(); |
Object node = treeModel.getRoot(); |
652 |
if (!tree.isRootVisible() |
if (!tree.isRootVisible() |
653 |
&& tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) |
&& tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) |
654 |
node = getNextNode(node); |
node = getNextNode(node); |
678 |
*/ |
*/ |
679 |
public int getRowForPath(JTree tree, TreePath path) |
public int getRowForPath(JTree tree, TreePath path) |
680 |
{ |
{ |
681 |
int row = path.getPathCount(); |
int row = 0; |
682 |
if (tree.isVisible(path)) |
Object dest = path.getLastPathComponent(); |
683 |
return row; |
Object curr = treeModel.getRoot(); |
684 |
|
while (curr != null && !curr.equals(dest)) |
|
path = path.getParentPath(); |
|
|
while (row > 0 && !tree.isVisible(path)) |
|
685 |
{ |
{ |
686 |
path = path.getParentPath(); |
++row; |
687 |
row--; |
curr = getNextVisibleNode(curr); |
688 |
} |
} |
689 |
return row; |
return row; |
690 |
} |
} |
698 |
*/ |
*/ |
699 |
public int getRowCount(JTree tree) |
public int getRowCount(JTree tree) |
700 |
{ |
{ |
|
TreeModel mod = tree.getModel(); |
|
701 |
int count = 0; |
int count = 0; |
702 |
if (mod != null) |
if (treeModel != null) |
703 |
{ |
{ |
704 |
Object node = mod.getRoot(); |
Object node = treeModel.getRoot(); |
705 |
if (!tree.isRootVisible() |
if (!tree.isRootVisible() |
706 |
&& tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) |
&& tree.isExpanded(new TreePath((getPathToRoot(node, 0))))) |
707 |
node = getNextNode(node); |
node = getNextNode(node); |
820 |
*/ |
*/ |
821 |
protected void prepareForUIInstall() |
protected void prepareForUIInstall() |
822 |
{ |
{ |
|
// FIXME: not implemented |
|
823 |
} |
} |
824 |
|
|
825 |
/** |
/** |
828 |
*/ |
*/ |
829 |
protected void completeUIInstall() |
protected void completeUIInstall() |
830 |
{ |
{ |
|
// FIXME: not implemented |
|
831 |
} |
} |
832 |
|
|
833 |
/** |
/** |
836 |
*/ |
*/ |
837 |
protected void completeUIUninstall() |
protected void completeUIUninstall() |
838 |
{ |
{ |
|
// FIXME: not implemented |
|
839 |
} |
} |
840 |
|
|
841 |
/** |
/** |
843 |
*/ |
*/ |
844 |
protected void installComponents() |
protected void installComponents() |
845 |
{ |
{ |
846 |
// FIXME: not implemented |
currentCellRenderer = createDefaultCellRenderer(); |
847 |
|
rendererPane = createCellRendererPane(); |
848 |
|
createdRenderer = true; |
849 |
|
setCellRenderer(currentCellRenderer); |
850 |
} |
} |
851 |
|
|
852 |
/** |
/** |
857 |
*/ |
*/ |
858 |
protected AbstractLayoutCache.NodeDimensions createNodeDimensions() |
protected AbstractLayoutCache.NodeDimensions createNodeDimensions() |
859 |
{ |
{ |
860 |
// FIXME: not implemented |
return new NodeDimensionsHandler(); |
|
return null; |
|
861 |
} |
} |
862 |
|
|
863 |
/** |
/** |
1035 |
TreeCellEditor tce = tree.getCellEditor(); |
TreeCellEditor tce = tree.getCellEditor(); |
1036 |
if (tce != null) |
if (tce != null) |
1037 |
tce.removeCellEditorListener(cellEditorListener); |
tce.removeCellEditorListener(cellEditorListener); |
1038 |
TreeModel tm = tree.getModel(); |
if (treeModel != null) |
1039 |
if (tm != null) |
treeModel.removeTreeModelListener(treeModelListener); |
|
tm.removeTreeModelListener(treeModelListener); |
|
1040 |
} |
} |
1041 |
|
|
1042 |
/** |
/** |
1051 |
*/ |
*/ |
1052 |
protected void uninstallComponents() |
protected void uninstallComponents() |
1053 |
{ |
{ |
1054 |
// FIXME: not implemented |
currentCellRenderer = null; |
1055 |
|
rendererPane = null; |
1056 |
|
createdRenderer = false; |
1057 |
|
setCellRenderer(currentCellRenderer); |
1058 |
} |
} |
1059 |
|
|
1060 |
/** |
/** |
1065 |
*/ |
*/ |
1066 |
protected int getVerticalLegBuffer() |
protected int getVerticalLegBuffer() |
1067 |
{ |
{ |
1068 |
// FIXME: not implemented |
return getRowHeight() / 2; |
|
return 0; |
|
1069 |
} |
} |
1070 |
|
|
1071 |
/** |
/** |
1077 |
*/ |
*/ |
1078 |
protected int getHorizontalLegBuffer() |
protected int getHorizontalLegBuffer() |
1079 |
{ |
{ |
1080 |
// FIXME: not implemented |
return rightChildIndent / 2; |
|
return 0; |
|
1081 |
} |
} |
1082 |
|
|
1083 |
/** |
/** |
1084 |
* Make all the nodes that are expanded in JTree expanded in LayoutCache. This |
* Make all the nodes that are expanded in JTree expanded in LayoutCache. This |
1085 |
* invokes update ExpandedDescendants with the root path. |
* invokes updateExpandedDescendants with the root path. |
1086 |
*/ |
*/ |
1087 |
protected void updateLayoutCacheExpandedNodes() |
protected void updateLayoutCacheExpandedNodes() |
1088 |
{ |
{ |
1089 |
// FIXME: not implemented |
if (treeModel != null) |
1090 |
|
updateExpandedDescendants(new TreePath(getPathToRoot(treeModel. |
1091 |
|
getRoot(), 0))); |
1092 |
} |
} |
1093 |
|
|
1094 |
/** |
/** |
1101 |
*/ |
*/ |
1102 |
protected void updateExpandedDescendants(TreePath path) |
protected void updateExpandedDescendants(TreePath path) |
1103 |
{ |
{ |
1104 |
// FIXME: not implemented |
Enumeration expanded = tree.getExpandedDescendants(path); |
1105 |
|
while (expanded.hasMoreElements()) |
1106 |
|
treeState.setExpandedState(((TreePath) expanded.nextElement()), true); |
1107 |
} |
} |
1108 |
|
|
1109 |
/** |
/** |
1123 |
*/ |
*/ |
1124 |
protected void updateDepthOffset() |
protected void updateDepthOffset() |
1125 |
{ |
{ |
1126 |
// FIXME: not implemented |
depthOffset += getVerticalLegBuffer(); |
1127 |
} |
} |
1128 |
|
|
1129 |
/** |
/** |
1143 |
*/ |
*/ |
1144 |
protected void updateRenderer() |
protected void updateRenderer() |
1145 |
{ |
{ |
1146 |
// FIXME: not implemented |
if (tree != null) |
1147 |
|
tree.setCellRenderer(currentCellRenderer); |
1148 |
} |
} |
1149 |
|
|
1150 |
/** |
/** |
1162 |
*/ |
*/ |
1163 |
protected void updateSize() |
protected void updateSize() |
1164 |
{ |
{ |
1165 |
// FIXME: not implemented |
preferredSize = null; |
1166 |
|
updateCachedPreferredSize(); |
1167 |
|
tree.treeDidChange(); |
1168 |
} |
} |
1169 |
|
|
1170 |
/** |
/** |
1204 |
* @param tree |
* @param tree |
1205 |
* is the JTree to install defaults for |
* is the JTree to install defaults for |
1206 |
*/ |
*/ |
1207 |
protected void installDefaults(JTree tree) |
protected void installDefaults() |
1208 |
{ |
{ |
1209 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
1210 |
|
|
1217 |
leftChildIndent = defaults.getInt("Tree.leftChildIndent"); |
leftChildIndent = defaults.getInt("Tree.leftChildIndent"); |
1218 |
setRowHeight(defaults.getInt("Tree.rowHeight")); |
setRowHeight(defaults.getInt("Tree.rowHeight")); |
1219 |
tree.requestFocusInWindow(false); |
tree.requestFocusInWindow(false); |
1220 |
|
tree.setScrollsOnExpand(defaults.getBoolean("Tree.scrollsOnExpand")); |
1221 |
|
setExpandedIcon(defaults.getIcon("Tree.expandedIcon")); |
1222 |
|
setCollapsedIcon(defaults.getIcon("Tree.collapsedIcon")); |
1223 |
} |
} |
1224 |
|
|
1225 |
/** |
/** |
1326 |
*/ |
*/ |
1327 |
public void installUI(JComponent c) |
public void installUI(JComponent c) |
1328 |
{ |
{ |
1329 |
|
prepareForUIInstall(); |
1330 |
super.installUI(c); |
super.installUI(c); |
|
installDefaults((JTree) c); |
|
1331 |
tree = (JTree) c; |
tree = (JTree) c; |
1332 |
|
installDefaults(); |
1333 |
|
|
1334 |
currentCellRenderer = createDefaultCellRenderer(); |
installComponents(); |
|
rendererPane = createCellRendererPane(); |
|
|
createdRenderer = true; |
|
1335 |
|
|
1336 |
setCellEditor(createDefaultCellEditor()); |
setCellEditor(createDefaultCellEditor()); |
1337 |
createdCellEditor = true; |
createdCellEditor = true; |
1355 |
* @param tree |
* @param tree |
1356 |
* to uninstall defaults for |
* to uninstall defaults for |
1357 |
*/ |
*/ |
1358 |
protected void uninstallDefaults(JTree tree) |
protected void uninstallDefaults() |
1359 |
{ |
{ |
1360 |
tree.setFont(null); |
tree.setFont(null); |
1361 |
tree.setForeground(null); |
tree.setForeground(null); |
1370 |
*/ |
*/ |
1371 |
public void uninstallUI(JComponent c) |
public void uninstallUI(JComponent c) |
1372 |
{ |
{ |
1373 |
uninstallDefaults((JTree) c); |
prepareForUIUninstall(); |
1374 |
|
uninstallDefaults(); |
1375 |
uninstallKeyboardActions(); |
uninstallKeyboardActions(); |
1376 |
uninstallListeners(); |
uninstallListeners(); |
1377 |
tree = null; |
tree = null; |
1378 |
|
uninstallComponents(); |
1379 |
completeUIUninstall(); |
completeUIUninstall(); |
1380 |
} |
} |
1381 |
|
|
1396 |
{ |
{ |
1397 |
JTree tree = (JTree) c; |
JTree tree = (JTree) c; |
1398 |
|
|
1399 |
TreeModel mod = tree.getModel(); |
if (treeModel != null) |
|
|
|
|
if (mod != null) |
|
1400 |
{ |
{ |
1401 |
Object root = mod.getRoot(); |
Object root = treeModel.getRoot(); |
1402 |
|
|
1403 |
if (!tree.isRootVisible()) |
if (!tree.isRootVisible()) |
1404 |
tree.expandPath(new TreePath(root)); |
tree.expandPath(new TreePath(root)); |
1405 |
|
|
1406 |
paintRecursive(g, 0, 0, 0, 0, tree, mod, root); |
paintRecursive(g, 0, 0, 0, 0, tree, treeModel, root); |
1407 |
|
|
1408 |
if (hasControlIcons()) |
if (hasControlIcons()) |
1409 |
paintControlIcons(g, 0, 0, 0, 0, tree, mod, root); |
paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, root); |
1410 |
} |
} |
1411 |
} |
} |
1412 |
|
|
1420 |
*/ |
*/ |
1421 |
protected void ensureRowsAreVisible(int beginRow, int endRow) |
protected void ensureRowsAreVisible(int beginRow, int endRow) |
1422 |
{ |
{ |
1423 |
// FIXME: not implemented |
if (beginRow < endRow) |
1424 |
|
{ |
1425 |
|
int temp = endRow; |
1426 |
|
endRow = beginRow; |
1427 |
|
beginRow = temp; |
1428 |
|
} |
1429 |
|
|
1430 |
|
for (int i = beginRow; i < endRow; i++) |
1431 |
|
{ |
1432 |
|
TreePath path = getPathForRow(tree, i); |
1433 |
|
if (!tree.isVisible(path)) |
1434 |
|
tree.makeVisible(path); |
1435 |
|
} |
1436 |
} |
} |
1437 |
|
|
1438 |
/** |
/** |
1485 |
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy) |
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy) |
1486 |
{ |
{ |
1487 |
// FIXME: checkConsistancy not implemented, c not used |
// FIXME: checkConsistancy not implemented, c not used |
|
TreeModel model = tree.getModel(); |
|
1488 |
int maxWidth = 0; |
int maxWidth = 0; |
1489 |
int count = 0; |
int count = 0; |
1490 |
if (model != null) |
if (treeModel != null) |
1491 |
{ |
{ |
1492 |
Object node = model.getRoot(); |
Object node = treeModel.getRoot(); |
1493 |
if (node != null) |
if (node != null) |
1494 |
{ |
{ |
1495 |
maxWidth = (int) (getCellBounds(0, 0, node).getWidth()); |
maxWidth = (int) (getCellBounds(0, 0, node).getWidth()); |
1517 |
*/ |
*/ |
1518 |
public Dimension getMinimumSize(JComponent c) |
public Dimension getMinimumSize(JComponent c) |
1519 |
{ |
{ |
1520 |
// FIXME: not implemented |
Dimension min = getPreferredMinSize(); |
1521 |
return getPreferredSize(c); |
if (min == null) |
1522 |
|
return new Dimension(); |
1523 |
|
return min; |
1524 |
} |
} |
1525 |
|
|
1526 |
/** |
/** |
1533 |
*/ |
*/ |
1534 |
public Dimension getMaximumSize(JComponent c) |
public Dimension getMaximumSize(JComponent c) |
1535 |
{ |
{ |
1536 |
// FIXME: not implemented |
if (c instanceof JTree) |
1537 |
return getPreferredSize(c); |
return ((JTree) c).getPreferredSize(); |
1538 |
|
return new Dimension(); |
1539 |
} |
} |
1540 |
|
|
1541 |
/** |
/** |
1579 |
} |
} |
1580 |
|
|
1581 |
if (messageTree) |
if (messageTree) |
1582 |
tree.getModel().valueForPathChanged(tree.getLeadSelectionPath(), newVal); |
treeModel.valueForPathChanged(tree.getLeadSelectionPath(), newVal); |
1583 |
} |
} |
1584 |
|
|
1585 |
/** |
/** |
1614 |
{ |
{ |
1615 |
editingPath = path; |
editingPath = path; |
1616 |
editingRow = tree.getRowForPath(editingPath); |
editingRow = tree.getRowForPath(editingPath); |
1617 |
|
|
1618 |
Object val = editingPath.getLastPathComponent(); |
Object val = editingPath.getLastPathComponent(); |
1619 |
cellEditor.addCellEditorListener(cellEditorListener); |
cellEditor.addCellEditorListener(cellEditorListener); |
1620 |
stopEditingInCompleteEditing = false; |
stopEditingInCompleteEditing = false; |
1649 |
protected void checkForClickInExpandControl(TreePath path, int mouseX, |
protected void checkForClickInExpandControl(TreePath path, int mouseX, |
1650 |
int mouseY) |
int mouseY) |
1651 |
{ |
{ |
1652 |
// FIXME: not implemented |
if (isLocationInExpandControl(path, mouseX, mouseY)) |
1653 |
|
toggleExpandState(path); |
1654 |
} |
} |
1655 |
|
|
1656 |
/** |
/** |
1671 |
protected boolean isLocationInExpandControl(TreePath path, int mouseX, |
protected boolean isLocationInExpandControl(TreePath path, int mouseX, |
1672 |
int mouseY) |
int mouseY) |
1673 |
{ |
{ |
1674 |
// FIXME: not implemented |
boolean cntlClick = false; |
1675 |
return false; |
int row = getRowForPath(tree, path); |
1676 |
|
|
1677 |
|
if (!isLeaf(row)) |
1678 |
|
{ |
1679 |
|
if (bounds == null) |
1680 |
|
bounds = getPathBounds(tree, path); |
1681 |
|
if (tree.isExpanded(path) && expandedIcon != null) |
1682 |
|
bounds.x -= expandedIcon.getIconWidth() - 4; |
1683 |
|
else if (collapsedIcon != null) |
1684 |
|
bounds.x -= collapsedIcon.getIconWidth() - 4; |
1685 |
|
|
1686 |
|
Icon controlIcon = getCurrentControlIcon(path); |
1687 |
|
if (controlIcon != null && (mouseX < bounds.x) |
1688 |
|
&& (mouseX > (bounds.x - controlIcon.getIconWidth()))) |
1689 |
|
cntlClick = true; |
1690 |
|
} |
1691 |
|
return cntlClick; |
1692 |
} |
} |
1693 |
|
|
1694 |
/** |
/** |
1704 |
*/ |
*/ |
1705 |
protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY) |
protected void handleExpandControlClick(TreePath path, int mouseX, int mouseY) |
1706 |
{ |
{ |
1707 |
// FIXME: not implemented |
toggleExpandState(path); |
1708 |
} |
} |
1709 |
|
|
1710 |
/** |
/** |
1718 |
*/ |
*/ |
1719 |
protected void toggleExpandState(TreePath path) |
protected void toggleExpandState(TreePath path) |
1720 |
{ |
{ |
1721 |
// FIXME: not implemented |
if (tree.isExpanded(path)) |
1722 |
|
tree.collapsePath(path); |
1723 |
|
else |
1724 |
|
tree.expandPath(path); |
1725 |
} |
} |
1726 |
|
|
1727 |
/** |
/** |
1735 |
*/ |
*/ |
1736 |
protected boolean isToggleSelectionEvent(MouseEvent event) |
protected boolean isToggleSelectionEvent(MouseEvent event) |
1737 |
{ |
{ |
1738 |
// FIXME: not implemented |
return (tree.getSelectionModel().getSelectionMode() == |
1739 |
return false; |
TreeSelectionModel.SINGLE_TREE_SELECTION); |
1740 |
} |
} |
1741 |
|
|
1742 |
/** |
/** |
1750 |
*/ |
*/ |
1751 |
protected boolean isMultiSelectEvent(MouseEvent event) |
protected boolean isMultiSelectEvent(MouseEvent event) |
1752 |
{ |
{ |
1753 |
// FIXME: not implemented |
return (tree.getSelectionModel().getSelectionMode() == |
1754 |
return false; |
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION); |
1755 |
} |
} |
1756 |
|
|
1757 |
/** |
/** |
1766 |
*/ |
*/ |
1767 |
protected boolean isToggleEvent(MouseEvent event) |
protected boolean isToggleEvent(MouseEvent event) |
1768 |
{ |
{ |
1769 |
// FIXME: not implemented |
return true; |
|
return false; |
|
1770 |
} |
} |
1771 |
|
|
1772 |
/** |
/** |
1783 |
*/ |
*/ |
1784 |
protected void selectPathForEvent(TreePath path, MouseEvent event) |
protected void selectPathForEvent(TreePath path, MouseEvent event) |
1785 |
{ |
{ |
1786 |
// FIXME: not implemented |
if (isToggleSelectionEvent(event)) |
1787 |
|
{ |
1788 |
|
if (tree.isPathSelected(path)) |
1789 |
|
tree.removeSelectionPath(path); |
1790 |
|
else |
1791 |
|
{ |
1792 |
|
tree.addSelectionPath(path); |
1793 |
|
tree.setAnchorSelectionPath(path); |
1794 |
|
} |
1795 |
|
} |
1796 |
|
else if (isMultiSelectEvent(event)) |
1797 |
|
{ |
1798 |
|
TreePath anchor = tree.getAnchorSelectionPath(); |
1799 |
|
if (anchor != null) |
1800 |
|
{ |
1801 |
|
int aRow = getRowForPath(tree, anchor); |
1802 |
|
tree.addSelectionInterval(aRow, getRowForPath(tree, path)); |
1803 |
|
} |
1804 |
|
else |
1805 |
|
tree.addSelectionPath(path); |
1806 |
|
} |
1807 |
|
else |
1808 |
|
tree.addSelectionPath(path); |
1809 |
} |
} |
1810 |
|
|
1811 |
/** |
/** |
1822 |
return true; |
return true; |
1823 |
|
|
1824 |
Object node = pathForRow.getLastPathComponent(); |
Object node = pathForRow.getLastPathComponent(); |
1825 |
return tree.getModel().isLeaf(node); |
return treeModel.isLeaf(node); |
1826 |
} |
} |
1827 |
|
|
1828 |
/** |
/** |
1858 |
{ |
{ |
1859 |
TreePath[] paths = new TreePath[tree.getRowCount()]; |
TreePath[] paths = new TreePath[tree.getRowCount()]; |
1860 |
|
|
1861 |
Object curr = getNextVisibleNode(tree.getModel().getRoot()); |
Object curr = getNextVisibleNode(treeModel.getRoot()); |
1862 |
int i = 0; |
int i = 0; |
1863 |
while (curr != null && i < paths.length) |
while (curr != null && i < paths.length) |
1864 |
{ |
{ |
1878 |
{ |
{ |
1879 |
Object last = lead.getLastPathComponent(); |
Object last = lead.getLastPathComponent(); |
1880 |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
1881 |
if (!tree.getModel().isLeaf(last)) |
if (!treeModel.isLeaf(last)) |
1882 |
{ |
toggleExpandState(path); |
|
if (tree.isExpanded(path)) |
|
|
tree.collapsePath(path); |
|
|
else |
|
|
tree.expandPath(path); |
|
|
} |
|
1883 |
} |
} |
1884 |
} |
} |
1885 |
else if (e.getActionCommand().equals("clearSelection")) |
else if (e.getActionCommand().equals("clearSelection")) |
2305 |
public void mousePressed(MouseEvent e) |
public void mousePressed(MouseEvent e) |
2306 |
{ |
{ |
2307 |
Point click = e.getPoint(); |
Point click = e.getPoint(); |
|
int row = Math.round(click.y / getRowHeight()); |
|
2308 |
TreePath path = getClosestPathForLocation(tree, click.x, click.y); |
TreePath path = getClosestPathForLocation(tree, click.x, click.y); |
2309 |
|
|
2310 |
if (path != null) |
if (path != null) |
2311 |
{ |
{ |
2312 |
boolean inBounds = false; |
bounds = getPathBounds(tree, path); |
2313 |
boolean cntlClick = false; |
int row = getRowForPath(tree, path); |
2314 |
Rectangle bounds = getPathBounds(tree, path); |
boolean cntlClick = isLocationInExpandControl(path, click.x, click.y); |
2315 |
|
|
2316 |
bounds.x -= rightChildIndent - 4; |
if (isLeaf(row)) |
2317 |
bounds.width += rightChildIndent + 4; |
{ |
2318 |
|
bounds.x -= rightChildIndent - 4; |
2319 |
if (bounds.contains(click.x, click.y)) |
bounds.width += rightChildIndent + 4; |
2320 |
inBounds = true; |
} |
2321 |
else if (hasControlIcons() |
else if (tree.isExpanded(path) && expandedIcon != null) |
2322 |
&& (click.x < (bounds.x - rightChildIndent + 5) && |
bounds.width += expandedIcon.getIconWidth() + 4; |
2323 |
click.x > (bounds.x - rightChildIndent - 5))) |
else if (collapsedIcon != null) |
2324 |
cntlClick = true; |
bounds.width += collapsedIcon.getIconWidth() + 4; |
2325 |
|
|
2326 |
|
boolean inBounds = bounds.contains(click.x, click.y); |
2327 |
if ((inBounds || cntlClick) && tree.isVisible(path)) |
if ((inBounds || cntlClick) && tree.isVisible(path)) |
2328 |
{ |
{ |
2329 |
selectPath(tree, path); |
selectPath(tree, path); |
2330 |
|
if (inBounds && e.getClickCount() == 2 && !isLeaf(row)) |
2331 |
if ((e.getClickCount() == 2 || cntlClick) && !isLeaf(row)) |
toggleExpandState(path); |
2332 |
|
|
2333 |
|
if (cntlClick) |
2334 |
{ |
{ |
2335 |
if (tree.isExpanded(path)) |
handleExpandControlClick(path, click.x, click.y); |
2336 |
tree.collapsePath(path); |
if (cellEditor != null) |
2337 |
else |
cellEditor.cancelCellEditing(); |
|
tree.expandPath(path); |
|
2338 |
} |
} |
2339 |
|
else if (tree.isEditable()) |
|
if (!cntlClick && tree.isEditable()) |
|
2340 |
startEditing(path, e); |
startEditing(path, e); |
2341 |
} |
} |
2342 |
} |
} |
2515 |
/** |
/** |
2516 |
* Constructor |
* Constructor |
2517 |
*/ |
*/ |
2518 |
public TreeCancelEditingAction() |
public TreeCancelEditingAction(String name) |
2519 |
{ |
{ |
2520 |
} |
} |
2521 |
|
|
2941 |
*/ |
*/ |
2942 |
public void actionPerformed(ActionEvent e) |
public void actionPerformed(ActionEvent e) |
2943 |
{ |
{ |
|
TreeModel mod = tree.getModel(); |
|
2944 |
Object last = tree.getLeadSelectionPath().getLastPathComponent(); |
Object last = tree.getLeadSelectionPath().getLastPathComponent(); |
2945 |
|
|
2946 |
if (e.getActionCommand().equals("selectParent")) |
if (e.getActionCommand().equals("selectParent")) |
2947 |
{ |
{ |
2948 |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
2949 |
Object p = getParent(mod.getRoot(), last); |
Object p = getParent(treeModel.getRoot(), last); |
2950 |
|
|
2951 |
if (!mod.isLeaf(last) && tree.isExpanded(path)) |
if (!treeModel.isLeaf(last) && tree.isExpanded(path)) |
2952 |
tree.collapsePath(path); |
tree.collapsePath(path); |
2953 |
else if (p != null) |
else if (p != null) |
2954 |
selectPath(tree, new TreePath(getPathToRoot(p, 0))); |
selectPath(tree, new TreePath(getPathToRoot(p, 0))); |
2957 |
{ |
{ |
2958 |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
TreePath path = new TreePath(getPathToRoot(last, 0)); |
2959 |
|
|
2960 |
if (!mod.isLeaf(last) && tree.isCollapsed(path)) |
if (!treeModel.isLeaf(last) && tree.isCollapsed(path)) |
2961 |
tree.expandPath(path); |
tree.expandPath(path); |
2962 |
else |
else |
2963 |
{ |
{ |
3170 |
{ |
{ |
3171 |
g.setColor(getHashColor()); |
g.setColor(getHashColor()); |
3172 |
heightOfLine = descent + halfHeight; |
heightOfLine = descent + halfHeight; |
3173 |
g.drawLine(indentation + halfWidth, heightOfLine, |
paintHorizontalLine(g, (JComponent) tree, heightOfLine, |
3174 |
indentation + rightChildIndent, heightOfLine); |
indentation + halfWidth, indentation + rightChildIndent); |
3175 |
} |
} |
3176 |
|
|
3177 |
descent = paintRecursive(g, indent, descent, i, depth + 1, |
descent = paintRecursive(g, indent, descent, i, depth + 1, |
3185 |
&& mod.getChildCount(curr) > 0) |
&& mod.getChildCount(curr) > 0) |
3186 |
{ |
{ |
3187 |
g.setColor(getHashColor()); |
g.setColor(getHashColor()); |
3188 |
g.drawLine(indentation + halfWidth, y0, indentation + halfWidth, |
paintVerticalLine(g, (JComponent) tree, indentation + halfWidth, |
3189 |
heightOfLine); |
y0, heightOfLine); |
3190 |
} |
} |
3191 |
|
|
3192 |
return descent; |
return descent; |
3220 |
{ |
{ |
3221 |
int h = descent; |
int h = descent; |
3222 |
int rowHeight = getRowHeight(); |
int rowHeight = getRowHeight(); |
3223 |
Icon ei = UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon"); |
TreePath path = new TreePath(getPathToRoot(node, 0)); |
3224 |
Icon ci = UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon"); |
Icon icon = getCurrentControlIcon(path); |
3225 |
|
|
3226 |
Rectangle clip = g.getClipBounds(); |
Rectangle clip = g.getClipBounds(); |
3227 |
if (indentation > clip.x + clip.width + rightChildIndent |
if (indentation > clip.x + clip.width + rightChildIndent |
3228 |
|| descent > clip.y + clip.height + getRowHeight()) |
|| descent > clip.y + clip.height + getRowHeight()) |
3238 |
int max = 0; |
int max = 0; |
3239 |
if (!mod.isLeaf(node)) |
if (!mod.isLeaf(node)) |
3240 |
max = mod.getChildCount(node); |
max = mod.getChildCount(node); |
|
if (tree.isExpanded(new TreePath(getPathToRoot(node, 0)))) |
|
|
{ |
|
|
if (!node.equals(mod.getRoot())) |
|
|
ei.paintIcon(tree, g, indentation - rightChildIndent - 3, h); |
|
3241 |
|
|
3242 |
|
if (!node.equals(mod.getRoot())) |
3243 |
|
icon.paintIcon(tree, g, indentation - rightChildIndent - 3, h); |
3244 |
|
|
3245 |
|
if (tree.isExpanded(path)) |
3246 |
|
{ |
3247 |
for (int i = 0; i < max; i++) |
for (int i = 0; i < max; i++) |
3248 |
{ |
{ |
3249 |
int indent = indentation + rightChildIndent; |
int indent = indentation + rightChildIndent; |
3254 |
tree, mod, mod.getChild(node, i)); |
tree, mod, mod.getChild(node, i)); |
3255 |
} |
} |
3256 |
} |
} |
|
else if (!node.equals(mod.getRoot())) |
|
|
ci.paintIcon(tree, g, indentation - rightChildIndent - 3, |
|
|
descent - getRowHeight()); |
|
3257 |
} |
} |
3258 |
|
|
3259 |
return descent; |
return descent; |
3260 |
} |
} |
3261 |
|
|
3262 |
/** |
/** |
3263 |
* Returns true if the LookAndFeel implements the control icons Package |
* Returns control icon. It is null if the LookAndFeel does not |
3264 |
* private for use in inner classes. |
* implements the control icons. |
3265 |
|
* Package private for use in inner classes. |
3266 |
|
* |
3267 |
|
* @return control icon if it exists. |
3268 |
|
*/ |
3269 |
|
Icon getCurrentControlIcon(TreePath path) |
3270 |
|
{ |
3271 |
|
if (tree.isExpanded(path)) |
3272 |
|
return UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon"); |
3273 |
|
return UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon"); |
3274 |
|
} |
3275 |
|
|
3276 |
|
/** |
3277 |
|
* Returns true if the LookAndFeel implements the control icons. |
3278 |
|
* Package private for use in inner classes. |
3279 |
* |
* |
3280 |
* @return true if control icons are visible |
* @returns true if there are control icons |
3281 |
*/ |
*/ |
3282 |
boolean hasControlIcons() |
boolean hasControlIcons() |
3283 |
{ |
{ |
3284 |
if (UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon") == null |
if (UIManager.getLookAndFeelDefaults().getIcon("Tree.expandedIcon") != null |
3285 |
|| UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon") == null) |
|| UIManager.getLookAndFeelDefaults().getIcon("Tree.collapsedIcon") |
3286 |
return false; |
!= null) |
3287 |
return true; |
return true; |
3288 |
|
return false; |
3289 |
} |
} |
3290 |
|
|
3291 |
/** |
/** |
3317 |
*/ |
*/ |
3318 |
private Object findNode(Object root, Object node) |
private Object findNode(Object root, Object node) |
3319 |
{ |
{ |
|
TreeModel mod = tree.getModel(); |
|
3320 |
int size = 0; |
int size = 0; |
3321 |
if (!mod.isLeaf(root)) |
if (!treeModel.isLeaf(root)) |
3322 |
size = mod.getChildCount(root); |
size = treeModel.getChildCount(root); |
3323 |
for (int i = 0; i < size; i++) |
for (int i = 0; i < size; i++) |
3324 |
{ |
{ |
3325 |
if (mod.getIndexOfChild(root, node) != -1) |
if (treeModel.getIndexOfChild(root, node) != -1) |
3326 |
return root; |
return root; |
3327 |
|
|
3328 |
Object n = findNode(mod.getChild(root, i), node); |
Object n = findNode(treeModel.getChild(root, i), node); |
3329 |
if (n != null) |
if (n != null) |
3330 |
return n; |
return n; |
3331 |
} |
} |
3409 |
*/ |
*/ |
3410 |
Object getNextNode(Object curr) |
Object getNextNode(Object curr) |
3411 |
{ |
{ |
3412 |
TreeModel mod = tree.getModel(); |
if (!treeModel.isLeaf(curr) && treeModel.getChildCount(curr) > 0) |
3413 |
if (!mod.isLeaf(curr) && mod.getChildCount(curr) > 0) |
return treeModel.getChild(curr, 0); |
|
return mod.getChild(curr, 0); |
|
3414 |
|
|
3415 |
Object node = curr; |
Object node = curr; |
3416 |
Object sibling = null; |
Object sibling = null; |
3418 |
do |
do |
3419 |
{ |
{ |
3420 |
sibling = getNextSibling(node); |
sibling = getNextSibling(node); |
3421 |
node = getParent(mod.getRoot(), node); |
node = getParent(treeModel.getRoot(), node); |
3422 |
} |
} |
3423 |
while (sibling == null && node != null); |
while (sibling == null && node != null); |
3424 |
|
|
3435 |
*/ |
*/ |
3436 |
Object getPreviousNode(Object node) |
Object getPreviousNode(Object node) |
3437 |
{ |
{ |
3438 |
TreeModel mod = tree.getModel(); |
Object parent = getParent(treeModel.getRoot(), node); |
|
Object parent = getParent(mod.getRoot(), node); |
|
3439 |
if (parent == null) |
if (parent == null) |
3440 |
return null; |
return null; |
3441 |
|
|
3445 |
return parent; |
return parent; |
3446 |
|
|
3447 |
int size = 0; |
int size = 0; |
3448 |
if (!mod.isLeaf(sibling)) |
if (!treeModel.isLeaf(sibling)) |
3449 |
size = mod.getChildCount(sibling); |
size = treeModel.getChildCount(sibling); |
3450 |
while (size > 0) |
while (size > 0) |
3451 |
{ |
{ |
3452 |
sibling = mod.getChild(sibling, size - 1); |
sibling = treeModel.getChild(sibling, size - 1); |
3453 |
if (!mod.isLeaf(sibling)) |
if (!treeModel.isLeaf(sibling)) |
3454 |
size = mod.getChildCount(sibling); |
size = treeModel.getChildCount(sibling); |
3455 |
else |
else |
3456 |
size = 0; |
size = 0; |
3457 |
} |
} |
3469 |
*/ |
*/ |
3470 |
Object getNextSibling(Object node) |
Object getNextSibling(Object node) |
3471 |
{ |
{ |
3472 |
TreeModel mod = tree.getModel(); |
Object parent = getParent(treeModel.getRoot(), node); |
|
Object parent = getParent(mod.getRoot(), node); |
|
3473 |
if (parent == null) |
if (parent == null) |
3474 |
return null; |
return null; |
3475 |
|
|
3476 |
int index = mod.getIndexOfChild(parent, node) + 1; |
int index = treeModel.getIndexOfChild(parent, node) + 1; |
3477 |
|
|
3478 |
int size = 0; |
int size = 0; |
3479 |
if (!mod.isLeaf(parent)) |
if (!treeModel.isLeaf(parent)) |
3480 |
size = mod.getChildCount(parent); |
size = treeModel.getChildCount(parent); |
3481 |
if (index == 0 || index >= size) |
if (index == 0 || index >= size) |
3482 |
return null; |
return null; |
3483 |
|
|
3484 |
return mod.getChild(parent, index); |
return treeModel.getChild(parent, index); |
3485 |
} |
} |
3486 |
|
|
3487 |
/** |
/** |
3494 |
*/ |
*/ |
3495 |
Object getPreviousSibling(Object node) |
Object getPreviousSibling(Object node) |
3496 |
{ |
{ |
3497 |
TreeModel mod = tree.getModel(); |
Object parent = getParent(treeModel.getRoot(), node); |
|
Object parent = getParent(mod.getRoot(), node); |
|
3498 |
if (parent == null) |
if (parent == null) |
3499 |
return null; |
return null; |
3500 |
|
|
3501 |
int index = mod.getIndexOfChild(parent, node) - 1; |
int index = treeModel.getIndexOfChild(parent, node) - 1; |
3502 |
|
|
3503 |
int size = 0; |
int size = 0; |
3504 |
if (!mod.isLeaf(parent)) |
if (!treeModel.isLeaf(parent)) |
3505 |
size = mod.getChildCount(parent); |
size = treeModel.getChildCount(parent); |
3506 |
if (index < 0 || index >= size) |
if (index < 0 || index >= size) |
3507 |
return null; |
return null; |
3508 |
|
|
3509 |
return mod.getChild(parent, index); |
return treeModel.getChild(parent, index); |
3510 |
} |
} |
3511 |
|
|
3512 |
/** |
/** |
3522 |
{ |
{ |
3523 |
if (path != null) |
if (path != null) |
3524 |
{ |
{ |
3525 |
if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) |
if (tree.getSelectionModel().getSelectionMode() == |
3526 |
|
TreeSelectionModel.SINGLE_TREE_SELECTION) |
3527 |
{ |
{ |
3528 |
|
tree.getSelectionModel().clearSelection(); |
3529 |
tree.addSelectionPath(path); |
tree.addSelectionPath(path); |
3530 |
tree.setLeadSelectionPath(path); |
tree.setLeadSelectionPath(path); |
3531 |
} |
} |
3532 |
else if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION) |
else if (tree.getSelectionModel().getSelectionMode() == |
3533 |
|
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION) |
3534 |
{ |
{ |
3535 |
// TODO |
// TODO |
3536 |
} |
} |
3537 |
else |
else |
3538 |
{ |
{ |
|
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); |
|
|
|
|
|
tree.getSelectionModel().clearSelection(); |
|
3539 |
tree.addSelectionPath(path); |
tree.addSelectionPath(path); |
3540 |
tree.setLeadSelectionPath(path); |
tree.setLeadSelectionPath(path); |
3541 |
|
tree.getSelectionModel().setSelectionMode |
3542 |
|
(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); |
3543 |
} |
} |
3544 |
} |
} |
3545 |
} |
} |
3556 |
*/ |
*/ |
3557 |
Object[] getPathToRoot(Object node, int depth) |
Object[] getPathToRoot(Object node, int depth) |
3558 |
{ |
{ |
|
TreeModel mod = tree.getModel(); |
|
3559 |
if (node == null) |
if (node == null) |
3560 |
{ |
{ |
3561 |
if (depth == 0) |
if (depth == 0) |
3564 |
return new Object[depth]; |
return new Object[depth]; |
3565 |
} |
} |
3566 |
|
|
3567 |
Object[] path = getPathToRoot(getParent(mod.getRoot(), node), depth + 1); |
Object[] path = getPathToRoot(getParent(treeModel.getRoot(), node), depth + 1); |
3568 |
path[path.length - depth - 1] = node; |
path[path.length - depth - 1] = node; |
3569 |
return path; |
return path; |
3570 |
} |
} |
3583 |
|
|
3584 |
do |
do |
3585 |
{ |
{ |
3586 |
current = getParent(tree.getModel().getRoot(), current); |
current = getParent(treeModel.getRoot(), current); |
3587 |
count++; |
count++; |
3588 |
} |
} |
3589 |
while (current != null); |
while (current != null); |
3652 |
int beginPositionY = y - icon.getIconHeight() / 2; |
int beginPositionY = y - icon.getIconHeight() / 2; |
3653 |
icon.paintIcon(c, g, beginPositionX, beginPositionY); |
icon.paintIcon(c, g, beginPositionX, beginPositionY); |
3654 |
} |
} |
3655 |
|
|
3656 |
|
/** |
3657 |
|
* Draws a dashed horizontal line. |
3658 |
|
* |
3659 |
|
* @param g - the graphics configuration. |
3660 |
|
* @param y - the y location to start drawing at |
3661 |
|
* @param x1 - the x location to start drawing at |
3662 |
|
* @param x2 - the x location to finish drawing at |
3663 |
|
*/ |
3664 |
|
protected void drawDashedHorizontalLine(Graphics g, int y, int x1, int x2) |
3665 |
|
{ |
3666 |
|
for (int i = x1; i < x2; i += 2) |
3667 |
|
g.drawLine(i, y, i + 1, y); |
3668 |
|
} |
3669 |
|
|
3670 |
|
/** |
3671 |
|
* Draws a dashed vertical line. |
3672 |
|
* |
3673 |
|
* @param g - the graphics configuration. |
3674 |
|
* @param x - the x location to start drawing at |
3675 |
|
* @param y1 - the y location to start drawing at |
3676 |
|
* @param y2 - the y location to finish drawing at |
3677 |
|
*/ |
3678 |
|
protected void drawDashedVerticalLine(Graphics g, int x, int y1, int y2) |
3679 |
|
{ |
3680 |
|
for (int i = y1; i < y2; i += 2) |
3681 |
|
g.drawLine(x, i, x, i + 1); |
3682 |
|
} |
3683 |
|
|
3684 |
|
/** |
3685 |
|
* Paints the expand (toggle) part of a row. The receiver should NOT modify |
3686 |
|
* clipBounds, or insets. |
3687 |
|
* |
3688 |
|
* @param g - the graphics configuration |
3689 |
|
* @param clipBounds - |
3690 |
|
* @param insets - |
3691 |
|
* @param bounds - bounds of expand control |
3692 |
|
* @param path - path to draw control for |
3693 |
|
* @param row - row to draw control for |
3694 |
|
* @param isExpanded - is the row expanded |
3695 |
|
* @param hasBeenExpanded - has the row already been expanded |
3696 |
|
* @param isLeaf - is the path a leaf |
3697 |
|
*/ |
3698 |
|
protected void paintExpandControl(Graphics g, Rectangle clipBounds, |
3699 |
|
Insets insets, Rectangle bounds, |
3700 |
|
TreePath path, int row, |
3701 |
|
boolean isExpanded, boolean hasBeenExpanded, |
3702 |
|
boolean isLeaf) |
3703 |
|
{ |
3704 |
|
if (treeModel != null) |
3705 |
|
paintControlIcons(g, 0, 0, 0, 0, tree, treeModel, path.getLastPathComponent()); |
3706 |
|
} |
3707 |
|
|
3708 |
|
/** |
3709 |
|
* Paints the horizontal part of the leg. The receiver should NOT modify |
3710 |
|
* clipBounds, or insets. |
3711 |
|
* NOTE: parentRow can be -1 if the root is not visible. |
3712 |
|
* |
3713 |
|
* @param g - the graphics configuration |
3714 |
|
* @param clipBounds - |
3715 |
|
* @param insets - |
3716 |
|
* @param bounds - bounds of expand control |
3717 |
|
* @param path - path to draw control for |
3718 |
|
* @param row - row to draw control for |
3719 |
|
* @param isExpanded - is the row expanded |
3720 |
|
* @param hasBeenExpanded - has the row already been expanded |
3721 |
|
* @param isLeaf - is the path a leaf |
3722 |
|
*/ |
3723 |
|
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, |
3724 |
|
Insets insets, Rectangle bounds, |
3725 |
|
TreePath path, int row, |
3726 |
|
boolean isExpanded, boolean hasBeenExpanded, |
3727 |
|
boolean isLeaf) |
3728 |
|
{ |
3729 |
|
// FIXME: not implemented |
3730 |
|
} |
3731 |
|
|
3732 |
|
/** |
3733 |
|
* Paints the vertical part of the leg. The receiver should NOT modify |
3734 |
|
* clipBounds, insets. |
3735 |
|
* |
3736 |
|
* @param g - the graphics configuration. |
3737 |
|
* @param clipbounds - |
3738 |
|
* @param insets - |
3739 |
|
* @param path - the path to draw the vertical part for. |
3740 |
|
*/ |
3741 |
|
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, |
3742 |
|
Insets insets, TreePath path) |
3743 |
|
{ |
3744 |
|
// FIXME: not implemented |
3745 |
|
} |
3746 |
|
|
3747 |
|
/** |
3748 |
|
* Paints the renderer part of a row. The receiver should NOT modify clipBounds, |
3749 |
|
* or insets. |
3750 |
|
* |
3751 |
|
* @param g - the graphics configuration |
3752 |
|
* @param clipBounds - |
3753 |
|
* @param insets - |
3754 |
|
* @param bounds - bounds of expand control |
3755 |
|
* @param path - path to draw control for |
3756 |
|
* @param row - row to draw control for |
3757 |
|
* @param isExpanded - is the row expanded |
3758 |
|
* @param hasBeenExpanded - has the row already been expanded |
3759 |
|
* @param isLeaf - is the path a leaf |
3760 |
|
*/ |
3761 |
|
protected void paintRow(Graphics g, Rectangle clipBounds, |
3762 |
|
Insets insets, Rectangle bounds, |
3763 |
|
TreePath path, int row, |
3764 |
|
boolean isExpanded, boolean hasBeenExpanded, |
3765 |
|
boolean isLeaf) |
3766 |
|
{ |
3767 |
|
// FIXME: not implemented. |
3768 |
|
} |
3769 |
|
|
3770 |
|
/** |
3771 |
|
* Prepares for the UI to uninstall. |
3772 |
|
*/ |
3773 |
|
protected void prepareForUIUninstall() |
3774 |
|
{ |
3775 |
|
} |
3776 |
|
|
3777 |
|
/** |
3778 |
|
* Returns true if the expand (toggle) control should be drawn for the |
3779 |
|
* specified row. |
3780 |
|
* |
3781 |
|
* @param path - current path to check for. |
3782 |
|
* @param row - current row to check for. |
3783 |
|
* @param isExpanded - true if the path is expanded |
3784 |
|
* @param hasBeenExpanded - true if the path has been expanded already |
3785 |
|
* @param isLeaf - true if the row is a lead |
3786 |
|
*/ |
3787 |
|
protected boolean shouldPaintExpandControl(TreePath path, int row, |
3788 |
|
boolean isExpanded, |
3789 |
|
boolean hasBeenExpanded, |
3790 |
|
boolean isLeaf) |
3791 |
|
{ |
3792 |
|
// FIXME: not implemented. |
3793 |
|
return false; |
3794 |
|
} |
3795 |
} // BasicTreeUI |
} // BasicTreeUI |