138 |
*/ |
*/ |
139 |
protected int totalChildIndent; |
protected int totalChildIndent; |
140 |
|
|
|
/** Minimum preferred size. */ |
|
|
protected Dimension preferredMinsize; |
|
|
|
|
141 |
/** Index of the row that was last selected. */ |
/** Index of the row that was last selected. */ |
142 |
protected int lastSelectedRow; |
protected int lastSelectedRow; |
143 |
|
|
264 |
*/ |
*/ |
265 |
public BasicTreeUI() |
public BasicTreeUI() |
266 |
{ |
{ |
267 |
|
validCachedPreferredSize = false; |
268 |
drawingCache = new Hashtable(); |
drawingCache = new Hashtable(); |
269 |
nodeDimensions = createNodeDimensions(); |
nodeDimensions = createNodeDimensions(); |
270 |
configureLayoutCache(); |
configureLayoutCache(); |
1165 |
|
|
1166 |
/** |
/** |
1167 |
* Updates the <code>preferredSize</code> instance variable, which is |
* Updates the <code>preferredSize</code> instance variable, which is |
1168 |
* returned from <code>getPreferredSize()</code>. For left to right |
* returned from <code>getPreferredSize()</code>. |
|
* orientations, the size is determined from the current AbstractLayoutCache. |
|
|
* For RTL orientations, the preferred size becomes the width minus the |
|
|
* minimum x position. |
|
1169 |
*/ |
*/ |
1170 |
protected void updateCachedPreferredSize() |
protected void updateCachedPreferredSize() |
1171 |
{ |
{ |
1172 |
// FIXME: not implemented |
int maxWidth = 0; |
1173 |
|
boolean isLeaf = false; |
1174 |
|
if (currentVisiblePath != null) |
1175 |
|
{ |
1176 |
|
Object[] path = currentVisiblePath.getPath(); |
1177 |
|
for (int i = 0; i < path.length; i++) |
1178 |
|
{ |
1179 |
|
TreePath curr = new TreePath(getPathToRoot(path[i], 0)); |
1180 |
|
Rectangle bounds = getPathBounds(tree, |
1181 |
|
curr); |
1182 |
|
if (treeModel != null) |
1183 |
|
isLeaf = treeModel.isLeaf(curr); |
1184 |
|
if (hasControlIcons()) |
1185 |
|
bounds.width += getCurrentControlIcon(curr).getIconWidth(); |
1186 |
|
maxWidth = Math.max(maxWidth, bounds.x + bounds.width); |
1187 |
|
} |
1188 |
|
preferredSize = new Dimension(maxWidth, (getRowHeight() * path.length)); |
1189 |
|
} |
1190 |
|
else preferredSize = new Dimension(0, 0); |
1191 |
|
validCachedPreferredSize = true; |
1192 |
} |
} |
1193 |
|
|
1194 |
/** |
/** |
1199 |
*/ |
*/ |
1200 |
protected void pathWasExpanded(TreePath path) |
protected void pathWasExpanded(TreePath path) |
1201 |
{ |
{ |
1202 |
// FIXME: not implemented |
validCachedPreferredSize = false; |
1203 |
|
tree.revalidate(); |
1204 |
|
tree.repaint(); |
1205 |
} |
} |
1206 |
|
|
1207 |
/** |
/** |
1209 |
*/ |
*/ |
1210 |
protected void pathWasCollapsed(TreePath path) |
protected void pathWasCollapsed(TreePath path) |
1211 |
{ |
{ |
1212 |
// FIXME: not implemented |
validCachedPreferredSize = false; |
1213 |
|
tree.revalidate(); |
1214 |
|
tree.repaint(); |
1215 |
} |
} |
1216 |
|
|
1217 |
/** |
/** |
1218 |
* Install all defaults for the tree. |
* Install all defaults for the tree. |
|
* |
|
|
* @param tree |
|
|
* is the JTree to install defaults for |
|
1219 |
*/ |
*/ |
1220 |
protected void installDefaults() |
protected void installDefaults() |
1221 |
{ |
{ |
1364 |
|
|
1365 |
/** |
/** |
1366 |
* Uninstall the defaults for the tree |
* Uninstall the defaults for the tree |
|
* |
|
|
* @param tree |
|
|
* to uninstall defaults for |
|
1367 |
*/ |
*/ |
1368 |
protected void uninstallDefaults() |
protected void uninstallDefaults() |
1369 |
{ |
{ |
1448 |
*/ |
*/ |
1449 |
public void setPreferredMinSize(Dimension newSize) |
public void setPreferredMinSize(Dimension newSize) |
1450 |
{ |
{ |
1451 |
// FIXME: not implemented |
preferredMinSize = newSize; |
1452 |
} |
} |
1453 |
|
|
1454 |
/** |
/** |
1458 |
*/ |
*/ |
1459 |
public Dimension getPreferredMinSize() |
public Dimension getPreferredMinSize() |
1460 |
{ |
{ |
1461 |
// FIXME: not implemented |
return preferredMinSize; |
|
return null; |
|
1462 |
} |
} |
1463 |
|
|
1464 |
/** |
/** |
1488 |
*/ |
*/ |
1489 |
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy) |
public Dimension getPreferredSize(JComponent c, boolean checkConsistancy) |
1490 |
{ |
{ |
1491 |
// FIXME: checkConsistancy not implemented, c not used |
// FIXME: checkConsistancy not implemented, c not used |
1492 |
int maxWidth = 0; |
if(!validCachedPreferredSize) |
1493 |
boolean isLeaf = false; |
updateCachedPreferredSize(); |
1494 |
if (currentVisiblePath != null) |
return preferredSize; |
|
{ |
|
|
Object[] path = currentVisiblePath.getPath(); |
|
|
for (int i = 0; i < path.length; i++) |
|
|
{ |
|
|
TreePath curr = new TreePath(getPathToRoot(path[i], 0)); |
|
|
Rectangle bounds = getPathBounds(tree, |
|
|
curr); |
|
|
if (treeModel != null) |
|
|
isLeaf = treeModel.isLeaf(curr); |
|
|
if (hasControlIcons()) |
|
|
bounds.width += getCurrentControlIcon(curr).getIconWidth(); |
|
|
maxWidth = Math.max(maxWidth, bounds.x + bounds.width); |
|
|
} |
|
|
return new Dimension(maxWidth, (getRowHeight() * path.length)); |
|
|
} |
|
|
return new Dimension(0, 0); |
|
1495 |
} |
} |
1496 |
|
|
1497 |
/** |
/** |
1615 |
editingComponent.getParent().validate(); |
editingComponent.getParent().validate(); |
1616 |
tree.add(editingComponent.getParent()); |
tree.add(editingComponent.getParent()); |
1617 |
editingComponent.getParent().validate(); |
editingComponent.getParent().validate(); |
1618 |
|
validCachedPreferredSize = false; |
1619 |
tree.revalidate(); |
tree.revalidate(); |
1620 |
((JTextField) editingComponent).requestFocusInWindow(false); |
((JTextField) editingComponent).requestFocusInWindow(false); |
1621 |
editorTimer.start(); |
editorTimer.start(); |
2059 |
isEditing = false; |
isEditing = false; |
2060 |
tree.requestFocusInWindow(false); |
tree.requestFocusInWindow(false); |
2061 |
editorTimer.stop(); |
editorTimer.stop(); |
2062 |
|
validCachedPreferredSize = false; |
2063 |
tree.revalidate(); |
tree.revalidate(); |
2064 |
tree.repaint(); |
tree.repaint(); |
2065 |
} |
} |
2090 |
tree.requestFocusInWindow(false); |
tree.requestFocusInWindow(false); |
2091 |
editorTimer.stop(); |
editorTimer.stop(); |
2092 |
isEditing = false; |
isEditing = false; |
2093 |
|
validCachedPreferredSize = false; |
2094 |
tree.revalidate(); |
tree.revalidate(); |
2095 |
tree.repaint(); |
tree.repaint(); |
2096 |
} |
} |
2547 |
*/ |
*/ |
2548 |
public void treeExpanded(TreeExpansionEvent event) |
public void treeExpanded(TreeExpansionEvent event) |
2549 |
{ |
{ |
2550 |
|
validCachedPreferredSize = false; |
2551 |
tree.revalidate(); |
tree.revalidate(); |
2552 |
tree.repaint(); |
tree.repaint(); |
2553 |
} |
} |
2560 |
*/ |
*/ |
2561 |
public void treeCollapsed(TreeExpansionEvent event) |
public void treeCollapsed(TreeExpansionEvent event) |
2562 |
{ |
{ |
2563 |
|
validCachedPreferredSize = false; |
2564 |
tree.revalidate(); |
tree.revalidate(); |
2565 |
tree.repaint(); |
tree.repaint(); |
2566 |
} |
} |
2756 |
*/ |
*/ |
2757 |
public void treeNodesInserted(TreeModelEvent e) |
public void treeNodesInserted(TreeModelEvent e) |
2758 |
{ |
{ |
2759 |
|
validCachedPreferredSize = false; |
2760 |
tree.revalidate(); |
tree.revalidate(); |
2761 |
tree.repaint(); |
tree.repaint(); |
2762 |
} |
} |
2774 |
*/ |
*/ |
2775 |
public void treeNodesRemoved(TreeModelEvent e) |
public void treeNodesRemoved(TreeModelEvent e) |
2776 |
{ |
{ |
2777 |
|
validCachedPreferredSize = false; |
2778 |
tree.revalidate(); |
tree.revalidate(); |
2779 |
tree.repaint(); |
tree.repaint(); |
2780 |
} |
} |
2791 |
*/ |
*/ |
2792 |
public void treeStructureChanged(TreeModelEvent e) |
public void treeStructureChanged(TreeModelEvent e) |
2793 |
{ |
{ |
2794 |
|
validCachedPreferredSize = false; |
2795 |
tree.revalidate(); |
tree.revalidate(); |
2796 |
tree.repaint(); |
tree.repaint(); |
2797 |
} |
} |
3275 |
* Get previous visible node in the tree. Package private for use in inner |
* Get previous visible node in the tree. Package private for use in inner |
3276 |
* classes. |
* classes. |
3277 |
* |
* |
3278 |
* @param the |
* @param node - |
3279 |
* current node |
* current node |
3280 |
* @return the next visible node in the JTree. Return null if there are no |
* @return the next visible node in the JTree. Return null if there are no |
3281 |
* more. |
* more. |
3298 |
/** |
/** |
3299 |
* Returns the next node in the tree Package private for use in inner classes. |
* Returns the next node in the tree Package private for use in inner classes. |
3300 |
* |
* |
3301 |
* @param the |
* @param curr - |
3302 |
* current node |
* current node |
3303 |
* @return the next node in the tree |
* @return the next node in the tree |
3304 |
*/ |
*/ |
3358 |
* Returns the next sibling in the tree Package private for use in inner |
* Returns the next sibling in the tree Package private for use in inner |
3359 |
* classes. |
* classes. |
3360 |
* |
* |
3361 |
* @param the |
* @param node - |
3362 |
* current node |
* current node |
3363 |
* @return the next sibling in the tree |
* @return the next sibling in the tree |
3364 |
*/ |
*/ |
3383 |
* Returns the previous sibling in the tree Package private for use in inner |
* Returns the previous sibling in the tree Package private for use in inner |
3384 |
* classes. |
* classes. |
3385 |
* |
* |
3386 |
* @param the |
* @param node - |
3387 |
* current node |
* current node |
3388 |
* @return the previous sibling in the tree |
* @return the previous sibling in the tree |
3389 |
*/ |
*/ |
3467 |
/** |
/** |
3468 |
* Returns the level of the node in the tree. |
* Returns the level of the node in the tree. |
3469 |
* |
* |
3470 |
* @param the |
* @param node - |
3471 |
* current node |
* current node |
3472 |
* @return the number of the level |
* @return the number of the level |
3473 |
*/ |
*/ |
3629 |
* clipBounds, insets. |
* clipBounds, insets. |
3630 |
* |
* |
3631 |
* @param g - the graphics configuration. |
* @param g - the graphics configuration. |
3632 |
* @param clipbounds - |
* @param clipBounds - |
3633 |
* @param insets - |
* @param insets - |
3634 |
* @param path - the path to draw the vertical part for. |
* @param path - the path to draw the vertical part for. |
3635 |
*/ |
*/ |
3706 |
boolean hasBeenExpanded, |
boolean hasBeenExpanded, |
3707 |
boolean isLeaf) |
boolean isLeaf) |
3708 |
{ |
{ |
3709 |
// FIXME: not implemented. |
Object node = path.getLastPathComponent(); |
3710 |
|
if (treeModel != null && (!isLeaf && !node.equals(treeModel.getRoot())) && |
3711 |
|
(tree.isRootVisible() || getLevel(node) != 1)) |
3712 |
|
return true; |
3713 |
return false; |
return false; |
3714 |
} |
} |
3715 |
|
|