summaryrefslogtreecommitdiff
path: root/javax/swing/tree/DefaultTreeModel.java
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-01 21:45:41 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-01 21:45:41 +0000
commit480ccb4bfcc622c1ce320c20ce992188187f7573 (patch)
treeaebfd0e230d0370ec1ac1a9b1a99b478abdc6854 /javax/swing/tree/DefaultTreeModel.java
parent4d80ae24073737202d4c51bf9efd2466fea8696d (diff)
downloadclasspath-480ccb4bfcc622c1ce320c20ce992188187f7573.tar.gz
2006-05-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge HEAD-->generics-branch for the period 2006-04-13 to 2006-05-01.
Diffstat (limited to 'javax/swing/tree/DefaultTreeModel.java')
-rw-r--r--javax/swing/tree/DefaultTreeModel.java68
1 files changed, 55 insertions, 13 deletions
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index e462b1c8b..713343811 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -223,27 +223,60 @@ public class DefaultTreeModel
}
/**
- * Invoke this method if you've modified the TreeNodes upon
- * which this model depends. The model will notify all of its
- * listeners that the model has changed.
+ * <p>
+ * Invoke this method if you've modified the TreeNodes upon which this model
+ * depends. The model will notify all of its listeners that the model has
+ * changed. It will fire the events, necessary to update the layout caches and
+ * repaint the tree. The tree will <i>not</i> be properly refreshed if you
+ * call the JTree.repaint instead.
+ * </p>
+ * <p>
+ * This method will refresh the information about whole tree from the root. If
+ * only part of the tree should be refreshed, it is more effective to call
+ * {@link #reload(TreeNode)}.
+ * </p>
*/
public void reload()
- throws NotImplementedException
{
- // TODO
+ // Need to duplicate the code because the root can formally be
+ // no an instance of the TreeNode.
+ int n = getChildCount(root);
+ int[] childIdx = new int[n];
+ Object[] children = new Object[n];
+
+ for (int i = 0; i < n; i++)
+ {
+ childIdx[i] = i;
+ children[i] = getChild(root, i);
+ }
+
+ fireTreeStructureChanged(this, new Object[] { root }, childIdx, children);
}
/**
- * Invoke this method if you've modified the TreeNodes upon
- * which this model depends. The model will notify all of its
- * listeners that the model has changed.
+ * Invoke this method if you've modified the TreeNodes upon which this model
+ * depends. The model will notify all of its listeners that the model has
+ * changed. It will fire the events, necessary to update the layout caches and
+ * repaint the tree. The tree will <i>not</i> be properly refreshed if you
+ * call the JTree.repaint instead.
*
- * @param node - TODO
+ * @param node - the tree node, from which the tree nodes have changed
+ * (inclusive). If you do not know this node, call {@link #reload()}
+ * instead.
*/
public void reload(TreeNode node)
- throws NotImplementedException
{
- // TODO
+ int n = getChildCount(node);
+ int[] childIdx = new int[n];
+ Object[] children = new Object[n];
+
+ for (int i = 0; i < n; i++)
+ {
+ childIdx[i] = i;
+ children[i] = getChild(node, i);
+ }
+
+ fireTreeStructureChanged(this, getPathToRoot(node), childIdx, children);
}
/**
@@ -392,9 +425,18 @@ public class DefaultTreeModel
* @param node that had its children and grandchildren changed.
*/
public void nodeStructureChanged(TreeNode node)
- throws NotImplementedException
{
- // TODO
+ int n = getChildCount(root);
+ int[] childIdx = new int[n];
+ Object[] children = new Object[n];
+
+ for (int i = 0; i < n; i++)
+ {
+ childIdx[i] = i;
+ children[i] = getChild(root, i);
+ }
+
+ fireTreeStructureChanged(this, new Object[] { root }, childIdx, children);
}
/**