diff options
author | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-04-26 19:34:12 +0000 |
---|---|---|
committer | Audrius Meskauskas <audriusa@Bioinformatics.org> | 2006-04-26 19:34:12 +0000 |
commit | c90aa78a0388d575d5923b76be2addb42fbdcade (patch) | |
tree | 3402019673963c46983bd00de0f0877123189ce7 | |
parent | 9dce860a3de25d8202900b5aab8d6ae242fded7e (diff) | |
download | classpath-c90aa78a0388d575d5923b76be2addb42fbdcade.tar.gz |
2006-04-26 Audrius Meskauskas <AudriusA@Bioinformatics.org
* javax/swing/plaf/basic/BasicTreeUI.java
(TreeAction.actionPerformed):Newly obtain the current lead
path that must stay visible.
(TreeTraverseAction.actionPerformed):Rewritten.
* javax/swing/tree/FixedHeightLayoutCache.java (countRows):
Do not treat root specially. (setModel): Assume the root node
initially expanded.
* javax/swing/tree/VariableHeightLayoutCache.java:(countRows):
Do not treat root specially. (setModel): Assume the root node
initially expanded.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | javax/swing/plaf/basic/BasicTreeUI.java | 35 | ||||
-rw-r--r-- | javax/swing/tree/FixedHeightLayoutCache.java | 4 | ||||
-rw-r--r-- | javax/swing/tree/VariableHeightLayoutCache.java | 6 |
4 files changed, 46 insertions, 12 deletions
@@ -1,3 +1,16 @@ +2006-04-26 Audrius Meskauskas <AudriusA@Bioinformatics.org + + * javax/swing/plaf/basic/BasicTreeUI.java + (TreeAction.actionPerformed):Newly obtain the current lead + path that must stay visible. + (TreeTraverseAction.actionPerformed):Rewritten. + * javax/swing/tree/FixedHeightLayoutCache.java (countRows): + Do not treat root specially. (setModel): Assume the root node + initially expanded. + * javax/swing/tree/VariableHeightLayoutCache.java:(countRows): + Do not treat root specially. (setModel): Assume the root node + initially expanded. + 2006-04-26 Chris Burdess <dog@gnu.org> Fixes PR 27290 diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index d9aeb9d2c..c73e379b7 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -1901,7 +1901,7 @@ public class BasicTreeUI if (tree.isEditing() && ! command.equals("startEditing")) tree.stopEditing(); - tree.scrollPathToVisible(lead); + tree.scrollPathToVisible(tree.getLeadSelectionPath()); } } @@ -3020,21 +3020,38 @@ public class BasicTreeUI if (e.getActionCommand().equals("selectParent")) { - current = current.getParentPath(); if (current == null) return; - selectPath(tree, current); - tree.collapsePath(current); + + if (tree.isExpanded(current)) + { + tree.collapsePath(current); + } + else + { + // If the node is not expanded (also, if it is a leaf node), + // we just select the parent. + TreePath parent = current.getParentPath(); + if (parent != null) + tree.setSelectionPath(parent); + } } else if (e.getActionCommand().equals("selectChild")) { Object node = current.getLastPathComponent(); int nc = treeModel.getChildCount(node); - if (nc > 0) - node = treeModel.getChild(node, 0); - - TreePath path = current.pathByAddingChild(node); - selectPath(tree, path); + if (nc == 0 || treeState.isExpanded(current)) + { + // If the node is leaf or it is already expanded, + // we just select the next row. + int nextRow = tree.getLeadSelectionRow() + 1; + if (nextRow <= tree.getRowCount()) + tree.setSelectionRow(nextRow); + } + else + { + tree.expandPath(current); + } } } diff --git a/javax/swing/tree/FixedHeightLayoutCache.java b/javax/swing/tree/FixedHeightLayoutCache.java index 993f81f23..f26f58dde 100644 --- a/javax/swing/tree/FixedHeightLayoutCache.java +++ b/javax/swing/tree/FixedHeightLayoutCache.java @@ -256,7 +256,7 @@ public class FixedHeightLayoutCache nodes.put(node, nr); // For expanded nodes and for the root node. - if (expanded.contains(node) || parent == null) + if (expanded.contains(node)) { int sc = treeModel.getChildCount(node); int deeper = depth+1; @@ -550,6 +550,8 @@ public class FixedHeightLayoutCache public void setModel(TreeModel newModel) { treeModel = newModel; + // The root node is expanded by default. + expanded.add(treeModel.getRoot()); dirty = true; } diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java index 0e09d259f..eb6463f83 100644 --- a/javax/swing/tree/VariableHeightLayoutCache.java +++ b/javax/swing/tree/VariableHeightLayoutCache.java @@ -254,8 +254,8 @@ public class VariableHeightLayoutCache NodeRecord nr = new NodeRecord(n.intValue(), depth, node, parent); nodes.put(node, nr); - // For expanded nodes and for the root node. - if (expanded.contains(node) || parent == null) + // For expanded nodes + if (expanded.contains(node)) { int sc = treeModel.getChildCount(node); int deeper = depth+1; @@ -548,6 +548,8 @@ public class VariableHeightLayoutCache public void setModel(TreeModel newModel) { treeModel = newModel; + // The root node is expanded by default. + expanded.add(treeModel.getRoot()); dirty = true; } |