diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-05-18 17:29:21 +0000 |
commit | 4f9533c7722fa07511a94d005227961f4a4dec23 (patch) | |
tree | 9f9c470de62ee62fba1331a396450d728d2b1fad /libjava/classpath/javax/swing/tree/DefaultTreeModel.java | |
parent | eaec4980e139903ae9b274d1abcf3a13946603a8 (diff) | |
download | gcc-4f9533c7722fa07511a94d005227961f4a4dec23.tar.gz |
Imported GNU Classpath 0.90
Imported GNU Classpath 0.90
* scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.
* sources.am: Regenerated.
* gcj/javaprims.h: Regenerated.
* Makefile.in: Regenerated.
* gcj/Makefile.in: Regenerated.
* include/Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* gnu/java/lang/VMInstrumentationImpl.java: New override.
* gnu/java/net/local/LocalSocketImpl.java: Likewise.
* gnu/classpath/jdwp/VMMethod.java: Likewise.
* gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
interface.
* java/lang/Thread.java: Add UncaughtExceptionHandler.
* java/lang/reflect/Method.java: Implements GenericDeclaration and
isSynthetic(),
* java/lang/reflect/Field.java: Likewise.
* java/lang/reflect/Constructor.java
* java/lang/Class.java: Implements Type, GenericDeclaration,
getSimpleName() and getEnclosing*() methods.
* java/lang/Class.h: Add new public methods.
* java/lang/Math.java: Add signum(), ulp() and log10().
* java/lang/natMath.cc (log10): New function.
* java/security/VMSecureRandom.java: New override.
* java/util/logging/Logger.java: Updated to latest classpath
version.
* java/util/logging/LogManager.java: New override.
From-SVN: r113887
Diffstat (limited to 'libjava/classpath/javax/swing/tree/DefaultTreeModel.java')
-rw-r--r-- | libjava/classpath/javax/swing/tree/DefaultTreeModel.java | 89 |
1 files changed, 69 insertions, 20 deletions
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java index 818f548a78d..c1ca679d006 100644 --- a/libjava/classpath/javax/swing/tree/DefaultTreeModel.java +++ b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing.tree; +import gnu.classpath.NotImplementedException; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -46,7 +48,6 @@ import java.util.EventListener; import javax.swing.event.EventListenerList; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; -import javax.swing.tree.DefaultMutableTreeNode; /** * DefaultTreeModel @@ -74,26 +75,29 @@ public class DefaultTreeModel protected boolean asksAllowsChildren; /** - * Constructor DefaultTreeModel + * Constructor DefaultTreeModel where any node can have children. * * @param root the tree root. */ public DefaultTreeModel(TreeNode root) { - if (root == null) - root = new DefaultMutableTreeNode(); - setRoot(root); + this (root, false); } /** - * Constructor DefaultTreeModel + * Create the DefaultTreeModel that may check if the nodes can have + * children or not. * - * @param root the tree root. - * @param asksAllowsChildren TODO + * @param aRoot the tree root. + * @param asksAllowsChildren if true, each node is asked if it can have + * children. If false, the model does not care about this, supposing, that + * any node can have children. */ - public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren) + public DefaultTreeModel(TreeNode aRoot, boolean asksAllowsChildren) { - setRoot(root); + if (aRoot == null) + aRoot = new DefaultMutableTreeNode(); + this.root = aRoot; this.asksAllowsChildren = asksAllowsChildren; } @@ -222,25 +226,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() { - // 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) { - // 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); } /** @@ -390,7 +429,17 @@ public class DefaultTreeModel */ public void nodeStructureChanged(TreeNode node) { - // 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); } /** |