summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/tree
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/tree')
-rw-r--r--libjava/classpath/javax/swing/tree/AbstractLayoutCache.java409
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java1112
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java516
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java591
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultTreeModel.java455
-rw-r--r--libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java754
-rw-r--r--libjava/classpath/javax/swing/tree/ExpandVetoException.java83
-rw-r--r--libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java244
-rw-r--r--libjava/classpath/javax/swing/tree/MutableTreeNode.java104
-rw-r--r--libjava/classpath/javax/swing/tree/RowMapper.java54
-rw-r--r--libjava/classpath/javax/swing/tree/TreeCellEditor.java65
-rw-r--r--libjava/classpath/javax/swing/tree/TreeCellRenderer.java67
-rw-r--r--libjava/classpath/javax/swing/tree/TreeModel.java109
-rw-r--r--libjava/classpath/javax/swing/tree/TreeNode.java99
-rw-r--r--libjava/classpath/javax/swing/tree/TreePath.java299
-rw-r--r--libjava/classpath/javax/swing/tree/TreeSelectionModel.java84
-rw-r--r--libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java253
-rw-r--r--libjava/classpath/javax/swing/tree/package.html47
18 files changed, 5345 insertions, 0 deletions
diff --git a/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java b/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java
new file mode 100644
index 00000000000..9f8e9da5984
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/AbstractLayoutCache.java
@@ -0,0 +1,409 @@
+/* AbstractLayoutCache.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.awt.Rectangle;
+import java.util.Enumeration;
+
+import javax.swing.event.TreeModelEvent;
+
+/**
+ * class AbstractLayoutCache
+ *
+ * @author Andrew Selkirk
+ */
+public abstract class AbstractLayoutCache
+ implements RowMapper
+{
+ /**
+ * class NodeDimensions
+ */
+ public abstract static class NodeDimensions
+ {
+ /**
+ * Creates <code>NodeDimensions</code> object.
+ */
+ public NodeDimensions()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * getNodeDimensions
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ * @return Rectangle
+ */
+ public abstract Rectangle getNodeDimensions(Object value0, int value1,
+ int value2, boolean value3, Rectangle value4);
+ }
+
+ /**
+ * nodeDimensions
+ */
+ protected NodeDimensions nodeDimensions;
+
+ /**
+ * treeModel
+ */
+ protected TreeModel treeModel;
+
+ /**
+ * treeSelectionModel
+ */
+ protected TreeSelectionModel treeSelectionModel;
+
+ /**
+ * rootVisible
+ */
+ protected boolean rootVisible;
+
+ /**
+ * rowHeight
+ */
+ protected int rowHeight;
+
+ /**
+ * Constructor AbstractLayoutCache
+ */
+ public AbstractLayoutCache()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * setNodeDimensions
+ *
+ * @param dimensions TODO
+ */
+ public void setNodeDimensions(NodeDimensions dimensions)
+ {
+ nodeDimensions = dimensions;
+ }
+
+ /**
+ * getNodeDimensions
+ *
+ * @return NodeDimensions
+ */
+ public NodeDimensions getNodeDimensions()
+ {
+ return nodeDimensions;
+ }
+
+ /**
+ * getNodeDimensions
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ *
+ * @return Rectangle
+ */
+ protected Rectangle getNodeDimensions(Object value, int row, int depth,
+ boolean expanded, Rectangle bounds)
+ {
+ if (bounds == null)
+ return new Rectangle();
+ return null;
+ // TODO
+ }
+
+ /**
+ * Sets the model that provides the tree data.
+ *
+ * @param the model
+ */
+ public void setModel(TreeModel model)
+ {
+ treeModel = model;
+ }
+
+ /**
+ * Returns the model that provides the tree data.
+ *
+ * @return the model
+ */
+ public TreeModel getModel()
+ {
+ return treeModel;
+ }
+
+ /**
+ * setRootVisible
+ *
+ * @param visible <code>true</code> if root should be visible,
+ * <code>false</code> otherwise
+ */
+ public void setRootVisible(boolean visible)
+ {
+ rootVisible = visible;
+ }
+
+ /**
+ * isRootVisible
+ *
+ * @return <code>true</code> if root is visible,
+ * <code>false</code> otherwise
+ */
+ public boolean isRootVisible()
+ {
+ return rootVisible;
+ }
+
+ /**
+ * setRowHeight
+ *
+ * @param height the row height
+ */
+ public void setRowHeight(int height)
+ {
+ rowHeight = height;
+ }
+
+ /**
+ * getRowHeight
+ *
+ * @return the row height
+ */
+ public int getRowHeight()
+ {
+ return rowHeight;
+ }
+
+ /**
+ * setSelectionModel
+ *
+ * @param model the model
+ */
+ public void setSelectionModel(TreeSelectionModel model)
+ {
+ treeSelectionModel = model;
+ }
+
+ /**
+ * getSelectionModel
+ *
+ * @return the model
+ */
+ public TreeSelectionModel getSelectionModel()
+ {
+ return treeSelectionModel;
+ }
+
+ /**
+ * getPreferredHeight
+ *
+ * @return int
+ */
+ public int getPreferredHeight()
+ {
+ return 0; // TODO
+ }
+
+ /**
+ * getPreferredWidth
+ *
+ * @param value0 TODO
+ *
+ * @return int
+ */
+ public int getPreferredWidth(Rectangle value0)
+ {
+ return 0; // TODO
+ }
+
+ /**
+ * isExpanded
+ *
+ * @param value0 TODO
+ *
+ * @return boolean
+ */
+ public abstract boolean isExpanded(TreePath value0);
+
+ /**
+ * getBounds
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ *
+ * @return Rectangle
+ */
+ public abstract Rectangle getBounds(TreePath value0, Rectangle value1);
+
+ /**
+ * getPathForRow
+ *
+ * @param row the row
+ *
+ * @return the tree path
+ */
+ public abstract TreePath getPathForRow(int row);
+
+ /**
+ * getRowForPath
+ *
+ * @param path the tree path
+ *
+ * @return the row
+ */
+ public abstract int getRowForPath(TreePath path);
+
+ /**
+ * getPathClosestTo
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ *
+ * @return the tree path
+ */
+ public abstract TreePath getPathClosestTo(int value0, int value1);
+
+ /**
+ * getVisiblePathsFrom
+ *
+ * @param path the tree path
+ *
+ * @return Enumeration
+ */
+ public abstract Enumeration getVisiblePathsFrom(TreePath path);
+
+ /**
+ * getVisibleChildCount
+ *
+ * @param path the tree path
+ *
+ * @return int
+ */
+ public abstract int getVisibleChildCount(TreePath value0);
+
+ /**
+ * setExpandedState
+ *
+ * @param value0 TODO
+ *
+ * @param value1 TODO
+ */
+ public abstract void setExpandedState(TreePath value0, boolean value1);
+
+ /**
+ * getExpandedState
+ *
+ * @param path the tree path
+ *
+ * @return boolean
+ */
+ public abstract boolean getExpandedState(TreePath path);
+
+ /**
+ * getRowCount
+ *
+ * @return the number of rows
+ */
+ public abstract int getRowCount();
+
+ /**
+ * invalidateSizes
+ */
+ public abstract void invalidateSizes();
+
+ /**
+ * invalidatePathBounds
+ *
+ * @param path the tree path
+ */
+ public abstract void invalidatePathBounds(TreePath path);
+
+ /**
+ * treeNodesChanged
+ *
+ * @param event the event to send
+ */
+ public abstract void treeNodesChanged(TreeModelEvent event);
+
+ /**
+ * treeNodesInserted
+ *
+ * @param event the event to send
+ */
+ public abstract void treeNodesInserted(TreeModelEvent event);
+
+ /**
+ * treeNodesRemoved
+ *
+ * @param event the event to send
+ */
+ public abstract void treeNodesRemoved(TreeModelEvent event);
+
+ /**
+ * treeStructureChanged
+ *
+ * @param event the event to send
+ */
+ public abstract void treeStructureChanged(TreeModelEvent event);
+
+ /**
+ * getRowsForPaths
+ *
+ * @param paths the tree paths
+ *
+ * @return an array of rows
+ */
+ public int[] getRowsForPaths(TreePath[] paths)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * isFixedRowHeight
+ *
+ * @return boolean
+ */
+ protected boolean isFixedRowHeight()
+ {
+ return false; // TODO
+ }
+}
diff --git a/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
new file mode 100644
index 00000000000..e709e2a0449
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/DefaultMutableTreeNode.java
@@ -0,0 +1,1112 @@
+/* DefaultMutableTreeNode.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import gnu.java.util.EmptyEnumeration;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.NoSuchElementException;
+import java.util.Stack;
+import java.util.Vector;
+
+
+/**
+ * DefaultMutableTreeNode
+ *
+ * @author Andrew Selkirk
+ * @author Robert Schuster (robertschuster@fsfe.org)
+ */
+public class DefaultMutableTreeNode
+ implements Cloneable, MutableTreeNode, Serializable
+{
+ private static final long serialVersionUID = -4298474751201349152L;
+
+ /**
+ * EMPTY_ENUMERATION
+ */
+ public static final Enumeration EMPTY_ENUMERATION =
+ EmptyEnumeration.getInstance();
+
+ /**
+ * parent
+ */
+ protected MutableTreeNode parent;
+
+ /**
+ * children
+ */
+ protected Vector children = new Vector();
+
+ /**
+ * userObject
+ */
+ protected transient Object userObject;
+
+ /**
+ * allowsChildren
+ */
+ protected boolean allowsChildren;
+
+ /**
+ * Creates a <code>DefaultMutableTreeNode</code> object.
+ * This node allows to add child nodes.
+ */
+ public DefaultMutableTreeNode()
+ {
+ this(null, true);
+ }
+
+ /**
+ * Creates a <code>DefaultMutableTreeNode</code> object with the given
+ * user object attached to it. This node allows to add child nodes.
+ *
+ * @param userObject the user object
+ */
+ public DefaultMutableTreeNode(Object userObject)
+ {
+ this(userObject, true);
+ }
+
+ /**
+ * Creates a <code>DefaultMutableTreeNode</code> object with the given
+ * user object attached to it.
+ *
+ * @param userObject the user object
+ * @param allowsChildren <code>true</code> if the code allows to add child
+ * nodes, <code>false</code> otherwise
+ */
+ public DefaultMutableTreeNode(Object userObject, boolean allowsChildren)
+ {
+ this.userObject = userObject;
+ this.allowsChildren = allowsChildren;
+ }
+
+ /**
+ * clone
+ *
+ * @return Object
+ */
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ // TODO: Do we need to do more here ?
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // This never happens.
+ return null;
+ }
+ }
+
+ /**
+ * Returns a string representation of this node
+ *
+ * @return a human-readable String representing this node
+ */
+ public String toString()
+ {
+ if (userObject == null)
+ return null;
+
+ return userObject.toString();
+ }
+
+ /**
+ * Adds a new child node to this node.
+ *
+ * @param child the child node
+ *
+ * @throws IllegalArgumentException if <code>child</code> is null
+ * @throws IllegalStateException if the node does not allow children
+ */
+ public void add(MutableTreeNode child)
+ {
+ if (child == null)
+ throw new IllegalArgumentException();
+
+ if (! allowsChildren)
+ throw new IllegalStateException();
+
+ children.add(child);
+ child.setParent(this);
+ }
+
+ /**
+ * Returns the parent node of this node.
+ *
+ * @return the parent node
+ */
+ public TreeNode getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Removes the child with the given index from this node
+ *
+ * @param index the index
+ */
+ public void remove(int index)
+ {
+ children.remove(index);
+ }
+
+ /**
+ * Removes the given child from this node.
+ *
+ * @param node the child node
+ */
+ public void remove(MutableTreeNode node)
+ {
+ children.remove(node);
+ }
+
+ /**
+ * writeObject
+ *
+ * @param stream the output stream
+ *
+ * @exception IOException If an error occurs
+ */
+ private void writeObject(ObjectOutputStream stream)
+ throws IOException
+ {
+ // TODO: Implement me.
+ }
+
+ /**
+ * readObject
+ *
+ * @param stream the input stream
+ *
+ * @exception IOException If an error occurs
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException
+ {
+ // TODO: Implement me.
+ }
+
+ /**
+ * Inserts given child node at the given index.
+ *
+ * @param node the child node
+ * @param index the index.
+ */
+ public void insert(MutableTreeNode node, int index)
+ {
+ children.insertElementAt(node, index);
+ }
+
+ /**
+ * Returns a path to this node from the root.
+ *
+ * @return an array of tree nodes
+ */
+ public TreeNode[] getPath()
+ {
+ return getPathToRoot(this, 0);
+ }
+
+ /**
+ * Returns an enumeration containing all children of this node.
+ * <code>EMPTY_ENUMERATION</code> is returned if this node has no children.
+ *
+ * @return an enumeration of tree nodes
+ */
+ public Enumeration children()
+ {
+ if (children.size() == 0)
+ return EMPTY_ENUMERATION;
+
+ return children.elements();
+ }
+
+ /**
+ * Set the parent node for this node.
+ *
+ * @param node the parent node
+ */
+ public void setParent(MutableTreeNode node)
+ {
+ parent = node;
+ }
+
+ /**
+ * Returns the child node at a given index.
+ *
+ * @param index the index
+ *
+ * @return the child node
+ */
+ public TreeNode getChildAt(int index)
+ {
+ return (TreeNode) children.elementAt(index);
+ }
+
+ /**
+ * Returns the number of children of this node.
+ *
+ * @return the number of children
+ */
+ public int getChildCount()
+ {
+ return children.size();
+ }
+
+ /**
+ * Returns the child index for a given node.
+ *
+ * @param node this node
+ *
+ * @return the index
+ */
+ public int getIndex(TreeNode node)
+ {
+ return children.indexOf(node);
+ }
+
+ /**
+ * setAllowsChildren
+ *
+ * @param allowsChildren TODO
+ */
+ public void setAllowsChildren(boolean allowsChildren)
+ {
+ this.allowsChildren = allowsChildren;
+ }
+
+ /**
+ * getAllowsChildren
+ *
+ * @return boolean
+ */
+ public boolean getAllowsChildren()
+ {
+ return allowsChildren;
+ }
+
+ /**
+ * Sets the user object for this node
+ *
+ * @param userObject the user object
+ */
+ public void setUserObject(Object userObject)
+ {
+ this.userObject = userObject;
+ }
+
+ /**
+ * Returns the user object attached to this node. <code>null</code> is
+ * returned when no user object is set.
+ *
+ * @return the user object
+ */
+ public Object getUserObject()
+ {
+ return userObject;
+ }
+
+ /**
+ * Removes this node from its parent.
+ */
+ public void removeFromParent()
+ {
+ parent.remove(this);
+ parent = null;
+ }
+
+ /**
+ * Removes all child nodes from this node.
+ */
+ public void removeAllChildren()
+ {
+ children.removeAllElements();
+ }
+
+ /**
+ * isNodeAncestor
+ *
+ * @param node TODO
+ *
+ * @return boolean
+ */
+ public boolean isNodeAncestor(TreeNode node)
+ {
+ if (node == null)
+ return false;
+
+ TreeNode current = this;
+
+ while (current != null
+ && current != node)
+ current = current.getParent();
+
+ return current == node;
+ }
+
+ /**
+ * isNodeDescendant
+ *
+ * @param node TODO
+ *
+ * @return boolean
+ */
+ public boolean isNodeDescendant(DefaultMutableTreeNode node)
+ {
+ if (node == null)
+ return false;
+
+ TreeNode current = node;
+
+ while (current != null
+ && current != this)
+ current = current.getParent();
+
+ return current == this;
+ }
+
+ /**
+ * getSharedAncestor
+ *
+ * @param node TODO
+ *
+ * @return TreeNode
+ */
+ public TreeNode getSharedAncestor(DefaultMutableTreeNode node)
+ {
+ TreeNode current = this;
+ ArrayList list = new ArrayList();
+
+ while (current != null)
+ {
+ list.add(current);
+ current = current.getParent();
+ }
+
+ current = node;
+
+ while (current != null)
+ {
+ if (list.contains(current))
+ return current;
+
+ current = current.getParent();
+ }
+
+ return null;
+ }
+
+ /**
+ * isNodeRelated
+ *
+ * @param node TODO
+ *
+ * @return boolean
+ */
+ public boolean isNodeRelated(DefaultMutableTreeNode node)
+ {
+ if (node == null)
+ return false;
+
+ return node.getRoot() == getRoot();
+ }
+
+ /**
+ * getDepth
+ *
+ * @return int
+ */
+ public int getDepth()
+ {
+ if ((! allowsChildren)
+ || children.size() == 0)
+ return 0;
+
+ Stack stack = new Stack();
+ stack.push(new Integer(0));
+ TreeNode node = getChildAt(0);
+ int depth = 0;
+ int current = 1;
+
+ while (! stack.empty())
+ {
+ if (node.getChildCount() != 0)
+ {
+ node = node.getChildAt(0);
+ stack.push(new Integer(0));
+ current++;
+ }
+ else
+ {
+ if (current > depth)
+ depth = current;
+
+ int size;
+ int index;
+
+ do
+ {
+ node = node.getParent();
+ size = node.getChildCount();
+ index = ((Integer) stack.pop()).intValue() + 1;
+ current--;
+ }
+ while (index >= size
+ && node != this);
+
+ if (index < size)
+ {
+ node = node.getChildAt(index);
+ stack.push(new Integer(index));
+ current++;
+ }
+ }
+ }
+
+ return depth;
+ }
+
+ /**
+ * getLevel
+ *
+ * @return int
+ */
+ public int getLevel()
+ {
+ int count = -1;
+ TreeNode current = this;
+
+ do
+ {
+ current = current.getParent();
+ count++;
+ }
+ while (current != null);
+
+ return count;
+ }
+
+ /**
+ * getPathToRoot
+ *
+ * @param node TODO
+ * @param depth TODO
+ *
+ * @return TreeNode[]
+ */
+ protected TreeNode[] getPathToRoot(TreeNode node, int depth)
+ {
+ if (node == null)
+ {
+ if (depth == 0)
+ return null;
+
+ return new TreeNode[depth];
+ }
+
+ TreeNode[] path = getPathToRoot(node.getParent(), depth + 1);
+ path[path.length - depth - 1] = node;
+ return path;
+ }
+
+ /**
+ * getUserObjectPath
+ *
+ * @return Object[]
+ */
+ public Object[] getUserObjectPath()
+ {
+ TreeNode[] path = getPathToRoot(this, 0);
+ Object[] object = new Object[path.length];
+
+ for (int index = 0; index < path.length; ++index)
+ object[index] = ((DefaultMutableTreeNode) path[index]).getUserObject();
+
+ return object;
+ }
+
+ /**
+ * Returns the root node by iterating the parents of this node.
+ *
+ * @return the root node
+ */
+ public TreeNode getRoot()
+ {
+ TreeNode current = this;
+ TreeNode check = current.getParent();
+
+ while (check != null)
+ {
+ current = check;
+ check = current.getParent();
+ }
+
+ return current;
+ }
+
+ /**
+ * Tells whether this node is the root node or not.
+ *
+ * @return <code>true</code> if this is the root node,
+ * <code>false</code>otherwise
+ */
+ public boolean isRoot()
+ {
+ return parent == null;
+ }
+
+ /**
+ * getNextNode
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getNextNode()
+ {
+ // Return first child.
+ if (getChildCount() != 0)
+ return (DefaultMutableTreeNode) getChildAt(0);
+
+ // Return next sibling (if needed the sibling of some parent).
+ DefaultMutableTreeNode node = this;
+ DefaultMutableTreeNode sibling;
+
+ do
+ {
+ sibling = node.getNextSibling();
+ node = (DefaultMutableTreeNode) node.getParent();
+ }
+ while (sibling == null &&
+ node != null);
+
+ // Return sibling.
+ return sibling;
+ }
+
+ /**
+ * getPreviousNode
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getPreviousNode()
+ {
+ // Return null if no parent.
+ if (parent == null)
+ return null;
+
+ DefaultMutableTreeNode sibling = getPreviousSibling();
+
+ // Return parent if no sibling.
+ if (sibling == null)
+ return (DefaultMutableTreeNode) parent;
+
+ // Return last leaf of sibling.
+ if (sibling.getChildCount() != 0)
+ return sibling.getLastLeaf();
+
+ // Return sibling.
+ return sibling;
+ }
+
+ /**
+ * preorderEnumeration
+ *
+ * @return Enumeration
+ */
+ public Enumeration preorderEnumeration()
+ {
+ return new PreorderEnumeration(this);
+ }
+
+ /**
+ * postorderEnumeration
+ *
+ * @return Enumeration
+ */
+ public Enumeration postorderEnumeration()
+ {
+ return new PostorderEnumeration(this);
+ }
+
+ /**
+ * breadthFirstEnumeration
+ *
+ * @return Enumeration
+ */
+ public Enumeration breadthFirstEnumeration()
+ {
+ return new BreadthFirstEnumeration(this);
+ }
+
+ /**
+ * depthFirstEnumeration
+ *
+ * @return Enumeration
+ */
+ public Enumeration depthFirstEnumeration()
+ {
+ return postorderEnumeration();
+ }
+
+ /**
+ * pathFromAncestorEnumeration
+ *
+ * @param node TODO
+ *
+ * @return Enumeration
+ */
+ public Enumeration pathFromAncestorEnumeration(TreeNode node)
+ {
+ if (node == null)
+ throw new IllegalArgumentException();
+
+ TreeNode parent = this;
+ Vector nodes = new Vector();
+ nodes.add(this);
+
+ while (parent != node && parent != null)
+ {
+ parent = parent.getParent();
+ nodes.add(0, parent);
+ }
+
+ if (parent != node)
+ throw new IllegalArgumentException();
+
+ return nodes.elements();
+ }
+
+ /**
+ * isNodeChild
+ *
+ * @param node TODO
+ *
+ * @return boolean
+ */
+ public boolean isNodeChild(TreeNode node)
+ {
+ if (node == null)
+ return false;
+
+ return node.getParent() == this;
+ }
+
+ /**
+ * getFirstChild
+ *
+ * @return TreeNode
+ */
+ public TreeNode getFirstChild()
+ {
+ return (TreeNode) children.firstElement();
+ }
+
+ /**
+ * getLastChild
+ *
+ * @return TreeNode
+ */
+ public TreeNode getLastChild()
+ {
+ return (TreeNode) children.lastElement();
+ }
+
+ /**
+ * getChildAfter
+ *
+ * @param node TODO
+ *
+ * @return TreeNode
+ */
+ public TreeNode getChildAfter(TreeNode node)
+ {
+ if (node == null
+ || node.getParent() != this)
+ throw new IllegalArgumentException();
+
+ int index = getIndex(node) + 1;
+
+ if (index == getChildCount())
+ return null;
+
+ return getChildAt(index);
+ }
+
+ /**
+ * getChildBefore
+ *
+ * @param node TODO
+ *
+ * @return TreeNode
+ */
+ public TreeNode getChildBefore(TreeNode node)
+ {
+ if (node == null
+ || node.getParent() != this)
+ throw new IllegalArgumentException();
+
+ int index = getIndex(node) - 1;
+
+ if (index < 0)
+ return null;
+
+ return getChildAt(index);
+ }
+
+ /**
+ * isNodeSibling
+ *
+ * @param node TODO
+ *
+ * @return boolean
+ */
+ public boolean isNodeSibling(TreeNode node)
+ {
+ if (node == null)
+ return false;
+
+ return (node.getParent() == getParent()
+ && getParent() != null);
+ }
+
+ /**
+ * getSiblingCount
+ *
+ * @return int
+ */
+ public int getSiblingCount()
+ {
+ if (parent == null)
+ return 1;
+
+ return parent.getChildCount();
+ }
+
+ /**
+ * getNextSibling
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getNextSibling()
+ {
+ if (parent == null)
+ return null;
+
+ int index = parent.getIndex(this) + 1;
+
+ if (index == parent.getChildCount())
+ return null;
+
+ return (DefaultMutableTreeNode) parent.getChildAt(index);
+ }
+
+ /**
+ * getPreviousSibling
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getPreviousSibling()
+ {
+ if (parent == null)
+ return null;
+
+ int index = parent.getIndex(this) - 1;
+
+ if (index < 0)
+ return null;
+
+ return (DefaultMutableTreeNode) parent.getChildAt(index);
+ }
+
+ /**
+ * isLeaf
+ *
+ * @return boolean
+ */
+ public boolean isLeaf()
+ {
+ return children.size() == 0;
+ }
+
+ /**
+ * getFirstLeaf
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getFirstLeaf()
+ {
+ TreeNode current = this;
+
+ while (current.getChildCount() > 0)
+ current = current.getChildAt(0);
+
+ return (DefaultMutableTreeNode) current;
+ }
+
+ /**
+ * getLastLeaf
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getLastLeaf()
+ {
+ TreeNode current = this;
+ int size = current.getChildCount();
+
+ while (size > 0)
+ {
+ current = current.getChildAt(size - 1);
+ size = current.getChildCount();
+ }
+
+ return (DefaultMutableTreeNode) current;
+ }
+
+ /**
+ * getNextLeaf
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getNextLeaf()
+ {
+ if (parent == null)
+ return null;
+
+ // TODO: Fix implementation.
+ return null;
+ //return parent.getChildAfter(this);
+ }
+
+ /**
+ * getPreviousLeaf
+ *
+ * @return DefaultMutableTreeNode
+ */
+ public DefaultMutableTreeNode getPreviousLeaf()
+ {
+ if (parent == null)
+ return null;
+
+ // TODO: Fix implementation.
+ return null;
+ //return parent.getChildBefore(this);
+ }
+
+ /**
+ * getLeafCount
+ *
+ * @return int
+ */
+ public int getLeafCount()
+ {
+ int count = 0;
+ Enumeration e = depthFirstEnumeration();
+
+ while (e.hasMoreElements())
+ {
+ TreeNode current = (TreeNode) e.nextElement();
+
+ if (current.isLeaf())
+ count++;
+ }
+
+ return count;
+ }
+
+ /** Provides an enumeration of a tree in breadth-first traversal
+ * order.
+ */
+ static class BreadthFirstEnumeration implements Enumeration
+ {
+
+ LinkedList queue = new LinkedList();
+
+ BreadthFirstEnumeration(TreeNode node)
+ {
+ queue.add(node);
+ }
+
+ public boolean hasMoreElements()
+ {
+ return !queue.isEmpty();
+ }
+
+ public Object nextElement()
+ {
+ if(queue.isEmpty())
+ throw new NoSuchElementException("No more elements left.");
+
+ TreeNode node = (TreeNode) queue.removeFirst();
+
+ Enumeration children = node.children();
+ while (children.hasMoreElements())
+ queue.add(children.nextElement());
+
+ return node;
+ }
+ }
+
+ /** Provides an enumeration of a tree traversing it
+ * preordered.
+ */
+ static class PreorderEnumeration implements Enumeration
+ {
+ TreeNode next;
+
+ Stack childrenEnums = new Stack();
+
+ PreorderEnumeration(TreeNode node)
+ {
+ next = node;
+ childrenEnums.push(node.children());
+ }
+
+ public boolean hasMoreElements()
+ {
+ return next != null;
+ }
+
+ public Object nextElement()
+ {
+ if( next == null )
+ throw new NoSuchElementException("No more elements left.");
+
+ Object current = next;
+
+ Enumeration children = (Enumeration) childrenEnums.peek();
+
+ // Retrieves the next element.
+ next = traverse(children);
+
+ return current;
+ }
+
+ private TreeNode traverse(Enumeration children)
+ {
+ // If more children are available step down.
+ if( children.hasMoreElements() )
+ {
+ TreeNode child = (TreeNode) children.nextElement();
+ childrenEnums.push(child.children());
+
+ return child;
+ }
+
+ // If no children are left, we return to a higher level.
+ childrenEnums.pop();
+
+ // If there are no more levels left, there is no next
+ // element to return.
+ if ( childrenEnums.isEmpty() )
+ return null;
+ else
+ {
+ return traverse((Enumeration) childrenEnums.peek());
+ }
+ }
+ }
+
+ /** Provides an enumeration of a tree traversing it
+ * postordered (= depth-first).
+ */
+ static class PostorderEnumeration implements Enumeration
+ {
+
+ Stack nodes = new Stack();
+ Stack childrenEnums = new Stack();
+
+ PostorderEnumeration(TreeNode node)
+ {
+ nodes.push(node);
+ childrenEnums.push(node.children());
+ }
+
+ public boolean hasMoreElements()
+ {
+ return !nodes.isEmpty();
+ }
+
+ public Object nextElement()
+ {
+ if( nodes.isEmpty() )
+ throw new NoSuchElementException("No more elements left!");
+
+ Enumeration children = (Enumeration) childrenEnums.peek();
+
+ return traverse(children);
+ }
+
+ private Object traverse(Enumeration children)
+ {
+ if ( children.hasMoreElements() )
+ {
+ TreeNode node = (TreeNode) children.nextElement();
+ nodes.push(node);
+
+ Enumeration newChildren = node.children();
+ childrenEnums.push(newChildren);
+
+ return traverse(newChildren);
+ }
+ else
+ {
+ childrenEnums.pop();
+
+ // Returns the node whose children
+ // have all been visited. (= postorder)
+ Object next = nodes.peek();
+ nodes.pop();
+
+ return next;
+ }
+ }
+
+ }
+
+}
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java b/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
new file mode 100644
index 00000000000..e509d2c18e0
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeCellEditor.java
@@ -0,0 +1,516 @@
+/* DefaultTreeCellEditor.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.EventObject;
+
+import javax.swing.Icon;
+import javax.swing.JTextField;
+import javax.swing.JTree;
+import javax.swing.border.Border;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.EventListenerList;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+
+/**
+ * DefaultTreeCellEditor
+ * @author Andrew Selkirk
+ */
+public class DefaultTreeCellEditor
+ implements ActionListener, TreeCellEditor, TreeSelectionListener
+{
+ /**
+ * EditorContainer
+ */
+ public class EditorContainer extends Container
+ {
+ /**
+ * Creates an <code>EditorContainer</code> object.
+ */
+ public EditorContainer()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * This method only exists for API compatibility and is useless as it does
+ * nothing. It got probably introduced by accident.
+ */
+ public void EditorContainer()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * getPreferredSize
+ * @return Dimension
+ */
+ public Dimension getPreferredSize()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * paint
+ * @param value0 TODO
+ */
+ public void paint(Graphics value0)
+ {
+ // TODO
+ }
+
+ /**
+ * doLayout
+ */
+ public void doLayout()
+ {
+ // TODO
+ }
+ }
+
+ /**
+ * DefaultTextField
+ */
+ public class DefaultTextField extends JTextField
+ {
+ /**
+ * border
+ */
+ protected Border border;
+
+ /**
+ * Creates a <code>DefaultTextField</code> object.
+ *
+ * @param border the border to use
+ */
+ public DefaultTextField(Border border)
+ {
+ this.border = border;
+ }
+
+ /**
+ * getFont
+ * @return Font
+ */
+ public Font getFont()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Returns the border of the text field.
+ *
+ * @return the border
+ */
+ public Border getBorder()
+ {
+ return border;
+ }
+
+ /**
+ * getPreferredSize
+ * @return Dimension
+ */
+ public Dimension getPreferredSize()
+ {
+ return null; // TODO
+ }
+ }
+
+ private EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * realEditor
+ */
+ protected TreeCellEditor realEditor;
+
+ /**
+ * renderer
+ */
+ protected DefaultTreeCellRenderer renderer;
+
+ /**
+ * editingContainer
+ */
+ protected Container editingContainer;
+
+ /**
+ * editingComponent
+ */
+ protected transient Component editingComponent;
+
+ /**
+ * canEdit
+ */
+ protected boolean canEdit;
+
+ /**
+ * offset
+ */
+ protected transient int offset;
+
+ /**
+ * tree
+ */
+ protected transient JTree tree;
+
+ /**
+ * lastPath
+ */
+ protected transient TreePath lastPath;
+
+ /**
+ * timer
+ */
+ protected transient javax.swing.Timer timer; // TODO
+
+ /**
+ * lastRow
+ */
+ protected transient int lastRow;
+
+ /**
+ * borderSelectionColor
+ */
+ protected Color borderSelectionColor;
+
+ /**
+ * editingIcon
+ */
+ protected transient Icon editingIcon;
+
+ /**
+ * font
+ */
+ protected Font font;
+
+ /**
+ * Constructor DefaultTreeCellEditor
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1)
+ {
+ // TODO
+ }
+
+ /**
+ * Constructor DefaultTreeCellEditor
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public DefaultTreeCellEditor(JTree value0, DefaultTreeCellRenderer value1,
+ TreeCellEditor value2)
+ {
+ // TODO
+ }
+
+ /**
+ * writeObject
+ * @param value0 TODO
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream value0) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0)
+ throws IOException, ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * setBorderSelectionColor
+ * @param value0 TODO
+ */
+ public void setBorderSelectionColor(Color value0)
+ {
+ // TODO
+ }
+
+ /**
+ * getBorderSelectionColor
+ * @return Color
+ */
+ public Color getBorderSelectionColor()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * setFont
+ * @param value0 TODO
+ */
+ public void setFont(Font value0)
+ {
+ // TODO
+ }
+
+ /**
+ * getFont
+ * @return Font
+ */
+ public Font getFont()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getTreeCellEditorComponent
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ * @param value5 TODO
+ * @return Component
+ */
+ public Component getTreeCellEditorComponent(JTree value0, Object value1,
+ boolean value2, boolean value3,
+ boolean value4, int value5)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getCellEditorValue
+ * @return Object
+ */
+ public Object getCellEditorValue()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * isCellEditable
+ * @param value0 TODO
+ * @return boolean
+ */
+ public boolean isCellEditable(EventObject value0)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * shouldSelectCell
+ * @param value0 TODO
+ * @return boolean
+ */
+ public boolean shouldSelectCell(EventObject value0)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * stopCellEditing
+ * @return boolean
+ */
+ public boolean stopCellEditing()
+ {
+ return false; // TODO
+ }
+
+ /**
+ * cancelCellEditing
+ */
+ public void cancelCellEditing()
+ {
+ // TODO
+ }
+
+ /**
+ * Adds a <code>CellEditorListener</code> object to this editor.
+ *
+ * @param listener the listener to add
+ */
+ public void addCellEditorListener(CellEditorListener listener)
+ {
+ listenerList.add(CellEditorListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>CellEditorListener</code> object.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeCellEditorListener(CellEditorListener listener)
+ {
+ listenerList.remove(CellEditorListener.class, listener);
+ }
+
+ /**
+ * Returns all added <code>CellEditorListener</code> objects to this editor.
+ *
+ * @return an array of listeners
+ *
+ * @since 1.4
+ */
+ public CellEditorListener[] getCellEditorListeners()
+ {
+ return (CellEditorListener[]) listenerList.getListeners(CellEditorListener.class);
+ }
+
+ /**
+ * valueChanged
+ * @param value0 TODO
+ */
+ public void valueChanged(TreeSelectionEvent value0)
+ {
+ // TODO
+ }
+
+ /**
+ * actionPerformed
+ * @param value0 TODO
+ */
+ public void actionPerformed(ActionEvent value0)
+ {
+ // TODO
+ }
+
+ /**
+ * setTree
+ * @param value0 TODO
+ */
+ protected void setTree(JTree value0)
+ {
+ // TODO
+ }
+
+ /**
+ * shouldStartEditingTimer
+ * @param value0 TODO
+ * @return boolean
+ */
+ protected boolean shouldStartEditingTimer(EventObject value0)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * startEditingTimer
+ */
+ protected void startEditingTimer()
+ {
+ // TODO
+ }
+
+ /**
+ * canEditImmediately
+ * @param value0 TODO
+ * @return boolean
+ */
+ protected boolean canEditImmediately(EventObject value0)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * inHitRegion
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return boolean
+ */
+ protected boolean inHitRegion(int value0, int value1)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * determineOffset
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ * @param value5 TODO
+ */
+ protected void determineOffset(JTree value0, Object value1, boolean value2,
+ boolean value3, boolean value4, int value5)
+ {
+ // TODO
+ }
+
+ /**
+ * prepareForEditing
+ */
+ protected void prepareForEditing()
+ {
+ // TODO
+ }
+
+ /**
+ * createContainer
+ * @return Container
+ */
+ protected Container createContainer()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * createTreeCellEditor
+ * @return TreeCellEditor
+ */
+ protected TreeCellEditor createTreeCellEditor()
+ {
+ return null; // TODO
+ }
+}
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java b/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
new file mode 100644
index 00000000000..db69c605554
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -0,0 +1,591 @@
+/* DefaultTreeCellRenderer.java
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JTree;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.plaf.UIResource;
+
+/**
+ * DefaultTreeCellRenderer
+ *
+ * @author Andrew Selkirk
+ */
+public class DefaultTreeCellRenderer
+ extends JLabel
+ implements TreeCellRenderer
+{
+ // -------------------------------------------------------------
+ // Variables --------------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * selected
+ */
+ protected boolean selected;
+
+ /**
+ * hasFocus
+ */
+ protected boolean hasFocus;
+
+ /**
+ * drawsFocusBorderAroundIcon
+ */
+ private boolean drawsFocusBorderAroundIcon;
+
+ /**
+ * closedIcon
+ */
+ protected transient Icon closedIcon;
+
+ /**
+ * leafIcon
+ */
+ protected transient Icon leafIcon;
+
+ /**
+ * openIcon
+ */
+ protected transient Icon openIcon;
+
+ /**
+ * textSelectionColor
+ */
+ protected Color textSelectionColor;
+
+ /**
+ * textNonSelectionColor
+ */
+ protected Color textNonSelectionColor;
+
+ /**
+ * backgroundSelectionColor
+ */
+ protected Color backgroundSelectionColor;
+
+ /**
+ * backgroundNonSelectionColor
+ */
+ protected Color backgroundNonSelectionColor;
+
+ /**
+ * borderSelectionColor
+ */
+ protected Color borderSelectionColor;
+
+
+ // -------------------------------------------------------------
+ // Initialization ---------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * Constructor DefaultTreeCellRenderer
+ */
+ public DefaultTreeCellRenderer()
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ setLeafIcon(getDefaultLeafIcon());
+ setOpenIcon(getDefaultOpenIcon());
+ setClosedIcon(getDefaultClosedIcon());
+
+ setTextNonSelectionColor(defaults.getColor("Tree.textForeground"));
+ setTextSelectionColor(defaults.getColor("Tree.selectionForeground"));
+ setBackgroundNonSelectionColor(defaults
+ .getColor("Tree.nonSelectionBackground"));
+ setBackgroundSelectionColor(defaults
+ .getColor("Tree.selectionBackground"));
+ setBorderSelectionColor(defaults
+ .getColor("Tree.selectionBorderColor"));
+ }
+
+ // -------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * getDefaultOpenIcon
+ *
+ * @returns Icon
+ */
+ public Icon getDefaultOpenIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
+ }
+
+ /**
+ * getDefaultClosedIcon
+ *
+ * @returns Icon
+ */
+ public Icon getDefaultClosedIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
+ }
+
+ /**
+ * getDefaultLeafIcon
+ *
+ * @returns Icon
+ */
+ public Icon getDefaultLeafIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
+ }
+
+ /**
+ * setOpenIcon
+ *
+ * @param value0 TODO
+ */
+ public void setOpenIcon(Icon i)
+ {
+ openIcon = i;
+ }
+
+ /**
+ * getOpenIcon
+ *
+ * @returns Icon
+ */
+ public Icon getOpenIcon()
+ {
+ return openIcon;
+ }
+
+ /**
+ * setClosedIcon
+ *
+ * @param value0 TODO
+ */
+ public void setClosedIcon(Icon i)
+ {
+ closedIcon = i;
+ }
+
+ /**
+ * getClosedIcon
+ *
+ * @returns Icon
+ */
+ public Icon getClosedIcon()
+ {
+ return closedIcon;
+ }
+
+ /**
+ * setLeafIcon
+ *
+ * @param value0 TODO
+ */
+ public void setLeafIcon(Icon i)
+ {
+ leafIcon = i;
+ }
+
+ /**
+ * getLeafIcon
+ *
+ * @returns Icon
+ */
+ public Icon getLeafIcon()
+ {
+ return leafIcon;
+ }
+
+ /**
+ * setTextSelectionColor
+ *
+ * @param value0 TODO
+ */
+ public void setTextSelectionColor(Color c)
+ {
+ textSelectionColor = c;
+ }
+
+ /**
+ * getTextSelectionColor
+ *
+ * @returns Color
+ */
+ public Color getTextSelectionColor()
+ {
+ return textSelectionColor;
+ }
+
+ /**
+ * setTextNonSelectionColor
+ *
+ * @param value0 TODO
+ */
+ public void setTextNonSelectionColor(Color c)
+ {
+ textNonSelectionColor = c;
+ }
+
+ /**
+ * getTextNonSelectionColor
+ *
+ * @returns Color
+ */
+ public Color getTextNonSelectionColor()
+ {
+ return textNonSelectionColor;
+ }
+
+ /**
+ * setBackgroundSelectionColor
+ *
+ * @param value0 TODO
+ */
+ public void setBackgroundSelectionColor(Color c)
+ {
+ backgroundSelectionColor = c;
+ }
+
+ /**
+ * getBackgroundSelectionColor
+ *
+ * @returns Color
+ */
+ public Color getBackgroundSelectionColor()
+ {
+ return backgroundSelectionColor;
+ }
+
+ /**
+ * setBackgroundNonSelectionColor
+ *
+ * @param value0 TODO
+ */
+ public void setBackgroundNonSelectionColor(Color c)
+ {
+ backgroundNonSelectionColor = c;
+ }
+
+ /**
+ * getBackgroundNonSelectionColor
+ *
+ * @returns Color
+ */
+ public Color getBackgroundNonSelectionColor()
+ {
+ return backgroundNonSelectionColor;
+ }
+
+ /**
+ * setBorderSelectionColor
+ *
+ * @param value0 TODO
+ */
+ public void setBorderSelectionColor(Color c)
+ {
+ borderSelectionColor = c;
+ }
+
+ /**
+ * getBorderSelectionColor
+ *
+ * @returns Color
+ */
+ public Color getBorderSelectionColor()
+ {
+ return borderSelectionColor;
+ }
+
+ /**
+ * setFont
+ *
+ * @param value0 TODO
+ */
+ public void setFont(Font f)
+ {
+ if (f != null && f instanceof UIResource)
+ f = null;
+ super.setFont(f);
+ }
+
+ /**
+ * setBackground
+ *
+ * @param value0 TODO
+ */
+ public void setBackground(Color c)
+ {
+ if (c != null && c instanceof UIResource)
+ c = null;
+ super.setBackground(c);
+ }
+
+ /**
+ * getTreeCellRendererComponent
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ * @param value5 TODO
+ * @param value6 TODO
+ * @returns Component
+ */
+ public Component getTreeCellRendererComponent(JTree tree, Object val,
+ boolean selected, boolean expanded, boolean leaf, int row,
+ boolean hasFocus)
+ {
+ if (val instanceof Icon)
+ setIcon((Icon) val);
+ else
+ {
+ setText(val.toString());
+ setIcon(null);
+ this.selected = selected;
+ this.hasFocus = hasFocus;
+ setHorizontalAlignment(LEFT);
+ setOpaque(true);
+ setVerticalAlignment(TOP);
+ setEnabled(true);
+ super.setFont(UIManager.getLookAndFeelDefaults().getFont("Tree.font"));
+ }
+
+ if (selected)
+ {
+ super.setBackground(getBackgroundSelectionColor());
+ setForeground(getTextSelectionColor());
+ }
+ else
+ {
+ super.setBackground(getBackgroundNonSelectionColor());
+ setForeground(getTextNonSelectionColor());
+ }
+
+ return this;
+ }
+
+ /**
+ * getFont
+ *
+ * @return the current Font
+ */
+ public Font getFont()
+ {
+ return super.getFont();
+ }
+
+ /**
+ * paint
+ *
+ * @param value0 TODO
+ */
+ public void paint(Graphics g)
+ {
+ super.paint(g);
+ }
+
+ /**
+ * getPreferredSize
+ *
+ * @returns Dimension
+ */
+ public Dimension getPreferredSize()
+ {
+ return null; // TODO
+ } // getPreferredSize()
+
+ /**
+ * validate
+ */
+ public void validate()
+ {
+ // Overridden for performance reasons.
+ } // validate()
+
+ /**
+ * revalidate
+ */
+ public void revalidate()
+ {
+ // Overridden for performance reasons.
+ } // revalidate()
+
+ /**
+ * repaint
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ * @param value3 TODO
+ * @param value4 TODO
+ */
+ public void repaint(long value0, int value1, int value2, int value3,
+ int value4)
+ {
+ // Overridden for performance reasons.
+ } // repaint()
+
+ /**
+ * repaint
+ *
+ * @param value0 TODO
+ */
+ public void repaint(Rectangle value0)
+ {
+ // Overridden for performance reasons.
+ } // repaint()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ protected void firePropertyChange(String value0, Object value1,
+ Object value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, byte value1, byte value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, char value1, char value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, short value1, short value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, int value1, int value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, long value1, long value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, float value1, float value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, double value1, double value2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+ /**
+ * firePropertyChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void firePropertyChange(String value0, boolean v1, boolean v2)
+ {
+ // Overridden for performance reasons.
+ } // firePropertyChange()
+
+} // DefaultTreeCellRenderer
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java
new file mode 100644
index 00000000000..3278ffadc77
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeModel.java
@@ -0,0 +1,455 @@
+/* DefaultTreeModel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+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
+ * @author Andrew Selkirk
+ */
+public class DefaultTreeModel
+ implements Serializable, TreeModel
+{
+ static final long serialVersionUID = -2621068368932566998L;
+
+ /**
+ * root
+ */
+ protected TreeNode root = null;
+
+ /**
+ * listenerList
+ */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * asksAllowsChildren
+ */
+ protected boolean asksAllowsChildren;
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param value0 TODO
+ */
+ public DefaultTreeModel(TreeNode root)
+ {
+ if (root == null)
+ root = new DefaultMutableTreeNode();
+ setRoot(root);
+ }
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
+ {
+ setRoot(root);
+ this.asksAllowsChildren = asksAllowsChildren;
+ }
+
+ /**
+ * writeObject
+ * @param value0 TODO
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream value0) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0) throws IOException,
+ ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * asksAllowsChildren
+ * @return boolean
+ */
+ public boolean asksAllowsChildren()
+ {
+ return asksAllowsChildren;
+ }
+
+ /**
+ * setAsksAllowsChildren
+ * @param value0 TODO
+ */
+ public void setAsksAllowsChildren(boolean value)
+ {
+ asksAllowsChildren = value; // TODO
+ }
+
+ /**
+ * setRoot
+ * @param value0 TODO
+ */
+ public void setRoot(TreeNode root)
+ {
+ // Sanity Check
+ if (root == null)
+ {
+ throw new IllegalArgumentException("null root");
+ }
+ // Set new root
+ this.root = root;
+
+ // TODO
+ }
+
+ /**
+ * getRoot
+ * @return Object
+ */
+ public Object getRoot()
+ {
+ return root;
+ }
+
+ /**
+ * getIndexOfChild
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return int
+ */
+ public int getIndexOfChild(Object parent, Object child)
+ {
+ return 0; // TODO
+ }
+
+ /**
+ * getChild
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return Object
+ */
+ public Object getChild(Object node, int idx)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildAt(idx);
+ else
+ return null;
+ }
+
+ /**
+ * getChildCount
+ * @param value0 TODO
+ * @return int
+ */
+ public int getChildCount(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildCount();
+ else
+ return 0;
+ }
+
+ /**
+ * isLeaf
+ * @param value0 TODO
+ * @return boolean
+ */
+ public boolean isLeaf(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).isLeaf();
+ else
+ return true;
+ }
+
+ /**
+ * reload
+ */
+ public void reload()
+ {
+ // TODO
+ }
+
+ /**
+ * reload
+ * @param value0 TODO
+ */
+ public void reload(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * valueForPathChanged
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void valueForPathChanged(TreePath value0, Object value1)
+ {
+ // TODO
+ }
+
+ /**
+ * insertNodeInto
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void insertNodeInto(MutableTreeNode value0, MutableTreeNode value1,
+ int value2)
+ {
+ // TODO
+ }
+
+ /**
+ * removeNodeFromParent
+ * @param value0 TODO
+ */
+ public void removeNodeFromParent(MutableTreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeChanged
+ * @param value0 TODO
+ */
+ public void nodeChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereInserted
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesWereInserted(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesWereRemoved
+ * @param value0 TODO
+ * @param value1 TODO
+ * @param value2 TODO
+ */
+ public void nodesWereRemoved(TreeNode value0, int[] value1, Object[] value2)
+ {
+ // TODO
+ }
+
+ /**
+ * nodesChanged
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void nodesChanged(TreeNode value0, int[] value1)
+ {
+ // TODO
+ }
+
+ /**
+ * nodeStructureChanged
+ * @param value0 TODO
+ */
+ public void nodeStructureChanged(TreeNode value0)
+ {
+ // TODO
+ }
+
+ /**
+ * getPathToRoot
+ * @param value0 TODO
+ * @return TreeNode[]
+ */
+ public TreeNode[] getPathToRoot(TreeNode value0)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * getPathToRoot
+ * @param value0 TODO
+ * @param value1 TODO
+ * @return TreeNode[]
+ */
+ protected TreeNode[] getPathToRoot(TreeNode value0, int value1)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Registers a listere to the model.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.add(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Removes a listener from the model.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeModelListener(TreeModelListener listener)
+ {
+ listenerList.remove(TreeModelListener.class, listener);
+ }
+
+ /**
+ * Returns all registered <code>TreeModelListener</code> listeners.
+ *
+ * @return an array of listeners.
+ *
+ * @since 1.4
+ */
+ public TreeModelListener[] getTreeModelListeners()
+ {
+ return (TreeModelListener[]) listenerList
+ .getListeners(TreeModelListener.class);
+ }
+
+ /**
+ * fireTreeNodesChanged
+ *
+ * @param source the node being changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the changed elements
+ * @param children the changed elements
+ */
+ protected void fireTreeNodesChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesChanged(event);
+ }
+
+ /**
+ * fireTreeNodesInserted
+ *
+ * @param source the node where new nodes got inserted
+ * @param path the path to the root node
+ * @param childIndices the indices of the new elements
+ * @param children the new elements
+ */
+ protected void fireTreeNodesInserted(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesInserted(event);
+ }
+
+ /**
+ * fireTreeNodesRemoved
+ *
+ * @param source the node where nodes got removed-
+ * @param path the path to the root node
+ * @param childIndices the indices of the removed elements
+ * @param children the removed elements
+ */
+ protected void fireTreeNodesRemoved(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeNodesRemoved(event);
+ }
+
+ /**
+ * fireTreeStructureChanged
+ *
+ * @param source the node where the model has changed
+ * @param path the path to the root node
+ * @param childIndices the indices of the affected elements
+ * @param children the affected elements
+ */
+ protected void fireTreeStructureChanged(Object source, Object[] path,
+ int[] childIndices, Object[] children)
+ {
+ TreeModelEvent event = new TreeModelEvent(source, path, childIndices,
+ children);
+ TreeModelListener[] listeners = getTreeModelListeners();
+
+ for (int i = listeners.length - 1; i >= 0; --i)
+ listeners[i].treeStructureChanged(event);
+ }
+
+ /**
+ * Returns the registered listeners of a given type.
+ *
+ * @param listenerType the listener type to return
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
+}
diff --git a/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
new file mode 100644
index 00000000000..de27dad04f9
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -0,0 +1,754 @@
+/* DefaultTreeSelectionModel.java
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.EventListener;
+import java.util.Vector;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.EventListenerList;
+import javax.swing.event.SwingPropertyChangeSupport;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+
+/**
+ * DefaultTreeSelectionModel
+ *
+ * @author Andrew Selkirk
+ */
+public class DefaultTreeSelectionModel
+ implements Cloneable, Serializable, TreeSelectionModel
+{
+ static final long serialVersionUID = 3288129636638950196L;
+
+ /**
+ * SELECTION_MODE_PROPERTY
+ */
+ public static final String SELECTION_MODE_PROPERTY = "selectionMode";
+
+ /**
+ * Our Swing property change support.
+ */
+ protected SwingPropertyChangeSupport changeSupport;
+
+ /**
+ * The current selection.
+ */
+ protected TreePath[] selection;
+
+ /**
+ * Our TreeSelectionListeners.
+ */
+ protected EventListenerList listenerList;
+
+ /**
+ * The current RowMapper.
+ */
+ protected transient RowMapper rowMapper;
+
+ /**
+ * The current listSelectionModel.
+ */
+ protected DefaultListSelectionModel listSelectionModel;
+
+ /**
+ * The current selection mode.
+ */
+ protected int selectionMode;
+
+ /**
+ * The path that has been added last.
+ */
+ protected TreePath leadPath;
+
+ /**
+ * The index of the last added path.
+ */
+ protected int leadIndex;
+
+ /**
+ * The row of the last added path according to the RowMapper.
+ */
+ protected int leadRow;
+
+ /**
+ * Constructs a new DefaultTreeSelectionModel.
+ */
+ public DefaultTreeSelectionModel()
+ {
+ setSelectionMode(DISCONTIGUOUS_TREE_SELECTION);
+ listenerList = new EventListenerList();
+ }
+
+ /**
+ * Creates a clone of this DefaultTreeSelectionModel with the same
+ * selection.
+ *
+ * @exception CloneNotSupportedException should not be thrown here
+ *
+ * @return a clone of this DefaultTreeSelectionModel
+ */
+ public Object clone() throws CloneNotSupportedException
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Returns a string that shows this object's properties.
+ *
+ * @return a string that shows this object's properties
+ */
+ public String toString()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * writeObject
+ *
+ * @param value0 TODO
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream value0) throws IOException
+ {
+ // TODO
+ }
+
+ /**
+ * readObject
+ *
+ * @param value0 TODO
+ * @exception IOException TODO
+ * @exception ClassNotFoundException TODO
+ */
+ private void readObject(ObjectInputStream value0) throws IOException,
+ ClassNotFoundException
+ {
+ // TODO
+ }
+
+ /**
+ * Sets the RowMapper that should be used to map between paths and their
+ * rows.
+ *
+ * @param rowMapper the RowMapper to set
+ *
+ * @see RowMapper
+ */
+ public void setRowMapper(RowMapper rowMapper)
+ {
+ // TODO
+ }
+
+ /**
+ * Returns the RowMapper that is currently used to map between paths and
+ * their rows.
+ *
+ * @return the current RowMapper
+ *
+ * @see RowMapper
+ */
+ public RowMapper getRowMapper()
+ {
+ return rowMapper;
+ }
+
+ /**
+ * Sets the current selection mode. Possible values are
+ * {@link #SINGLE_TREE_SELECTION}, {@link #CONTIGUOUS_TREE_SELECTION} and
+ * {@link #DISCONTIGUOUS_TREE_SELECTION}.
+ *
+ * @param mode the selection mode to be set
+ *
+ * @see #getSelectionMode
+ * @see #SINGLE_TREE_SELECTION
+ * @see #CONTIGUOUS_TREE_SELECTION
+ * @see #DISCONTIGUOUS_TREE_SELECTION
+ */
+ public void setSelectionMode(int mode)
+ {
+ selectionMode = mode;
+ }
+
+ /**
+ * Returns the current selection mode.
+ *
+ * @return the current selection mode
+ *
+ * @see #setSelectionMode
+ * @see #SINGLE_TREE_SELECTION
+ * @see #CONTIGUOUS_TREE_SELECTION
+ * @see #DISCONTIGUOUS_TREE_SELECTION
+ */
+ public int getSelectionMode()
+ {
+ return selectionMode;
+ }
+
+ /**
+ * Sets this path as the only selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to set as selection
+ */
+ public void setSelectionPath(TreePath path)
+ {
+ selection = new TreePath[] {
+ path };
+ }
+
+ /**
+ * Sets the paths as selection. This method checks for duplicates and
+ * removes them.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to set as selection
+ */
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ // TODO
+ }
+
+ /**
+ * Adds a path to the list of selected paths. This method checks if the path
+ * is already selected and doesn't add the same path twice.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to add to the selection
+ */
+ public void addSelectionPath(TreePath path)
+ {
+ if (!isPathSelected(path))
+ {
+ if (isSelectionEmpty())
+ setSelectionPath(path);
+ else
+ {
+ TreePath[] temp = new TreePath[selection.length + 1];
+ System.arraycopy(selection, 0, temp, 0, selection.length);
+ temp[temp.length - 1] = path;
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+ }
+ leadPath = path;
+ fireValueChanged(new TreeSelectionEvent(this, path, true,
+ leadPath, path));
+ }
+ }
+
+ /**
+ * Adds the paths to the list of selected paths. This method checks if the
+ * paths are already selected and doesn't add the same path twice.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to add to the selection
+ */
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ if (paths != null)
+ {
+ TreePath v0 = null;
+ for (int i = 0; i < paths.length; i++)
+ {
+ v0 = paths[i];
+ if (!isPathSelected(v0))
+ {
+ if (isSelectionEmpty())
+ setSelectionPath(v0);
+ else
+ {
+ TreePath[] temp = new TreePath[selection.length + 1];
+ System.arraycopy(selection, 0, temp, 0,
+ selection.length);
+ temp[temp.length - 1] = v0;
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+ }
+ leadPath = paths[paths.length - 1];
+ fireValueChanged(new TreeSelectionEvent(this, v0, true,
+ leadPath, paths[0]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes the path from the selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param path the path to remove
+ */
+ public void removeSelectionPath(TreePath path)
+ {
+ int index = -1;
+ if (isPathSelected(path))
+ {
+ for (int i = 0; i < selection.length; i++)
+ {
+ if (selection[i].equals(path))
+ {
+ index = i;
+ break;
+ }
+ }
+ TreePath[] temp = new TreePath[selection.length - 1];
+ System.arraycopy(selection, 0, temp, 0, index);
+ System.arraycopy(selection, index + 1, temp, index,
+ selection.length - index - 1);
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+
+ fireValueChanged(new TreeSelectionEvent(this, path, false,
+ leadPath, path));
+ }
+ }
+
+ /**
+ * Removes the paths from the selection.
+ *
+ * If this changes the selection the registered TreeSelectionListeners are
+ * notified.
+ *
+ * @param paths the paths to remove
+ */
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ if (paths != null)
+ {
+ int index = -1;
+ TreePath v0 = null;
+ for (int i = 0; i < paths.length; i++)
+ {
+ v0 = paths[i];
+ if (isPathSelected(v0))
+ {
+ for (int x = 0; x < selection.length; x++)
+ {
+ if (selection[i].equals(v0))
+ {
+ index = x;
+ break;
+ }
+ }
+ TreePath[] temp = new TreePath[selection.length - 1];
+ System.arraycopy(selection, 0, temp, 0, index);
+ System.arraycopy(selection, index + 1, temp, index,
+ selection.length - index - 1);
+ selection = new TreePath[temp.length];
+ System.arraycopy(temp, 0, selection, 0, temp.length);
+
+ fireValueChanged(new TreeSelectionEvent(this, v0, false,
+ leadPath, paths[0]));
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the first path in the selection. This is especially useful when
+ * the selectionMode is {@link #SINGLE_TREE_SELECTION}.
+ *
+ * @return the first path in the selection
+ */
+ public TreePath getSelectionPath()
+ {
+ if ((selection == null) || (selection.length == 0))
+ return null;
+ else
+ return selection[0];
+ }
+
+ /**
+ * Returns the complete selection.
+ *
+ * @return the complete selection
+ */
+ public TreePath[] getSelectionPaths()
+ {
+ return selection;
+ }
+
+ /**
+ * Returns the number of paths in the selection.
+ *
+ * @return the number of paths in the selection
+ */
+ public int getSelectionCount()
+ {
+ if (selection == null)
+ return 0;
+ else
+ return selection.length;
+ }
+
+ /**
+ * Checks if a given path is in the selection.
+ *
+ * @param path the path to check
+ *
+ * @return <code>true</code> if the path is in the selection,
+ * <code>false</code> otherwise
+ */
+ public boolean isPathSelected(TreePath path)
+ {
+ if (selection == null)
+ return false;
+
+ for (int i = 0; i < selection.length; i++)
+ {
+ if (selection[i].equals(path))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the selection is empty.
+ *
+ * @return <code>true</code> if the selection is empty, <code>false</code>
+ * otherwise
+ */
+ public boolean isSelectionEmpty()
+ {
+ return ((selection == null) || (selection.length == 0));
+ }
+
+ /**
+ * Removes all paths from the selection.
+ */
+ public void clearSelection()
+ {
+ leadPath = null;
+ selection = null;
+ }
+
+ /**
+ * Adds a <code>TreeSelectionListener</code> object to this model.
+ *
+ * @param listener the listener to add
+ */
+ public void addTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.add(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Removes a <code>TreeSelectionListener</code> object from this model.
+ *
+ * @param listener the listener to remove
+ */
+ public void removeTreeSelectionListener(TreeSelectionListener listener)
+ {
+ listenerList.remove(TreeSelectionListener.class, listener);
+ }
+
+ /**
+ * Returns all <code>TreeSelectionListener</code> added to this model.
+ *
+ * @return an array of listeners
+ *
+ * @since 1.4
+ */
+ public TreeSelectionListener[] getTreeSelectionListeners()
+ {
+ return (TreeSelectionListener[])
+ getListeners(TreeSelectionListener.class);
+ }
+
+ /**
+ * fireValueChanged
+ *
+ * @param event the event to fire.
+ */
+ protected void fireValueChanged(TreeSelectionEvent event)
+ {
+ TreeSelectionListener[] listeners = getTreeSelectionListeners();
+
+ for (int i = 0; i < listeners.length; ++i)
+ listeners[i].valueChanged(event);
+ }
+
+ /**
+ * Returns all added listeners of a special type.
+ *
+ * @param listenerType the listener type
+ *
+ * @return an array of listeners
+ *
+ * @since 1.3
+ */
+ public EventListener[] getListeners(Class listenerType)
+ {
+ return listenerList.getListeners(listenerType);
+ }
+
+ /**
+ * Returns the currently selected rows.
+ *
+ * @return the currently selected rows
+ */
+ public int[] getSelectionRows()
+ {
+ if (rowMapper == null)
+ return null;
+ else
+ return rowMapper.getRowsForPaths(selection);
+ }
+
+ /**
+ * Returns the smallest row index from the selection.
+ *
+ * @return the smallest row index from the selection
+ */
+ public int getMinSelectionRow()
+ {
+ if ((rowMapper == null) || (selection == null)
+ || (selection.length == 0))
+ return -1;
+ else
+ {
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ int minRow = Integer.MAX_VALUE;
+ for (int index = 0; index < rows.length; index++)
+ minRow = Math.min(minRow, rows[index]);
+ return minRow;
+ }
+ }
+
+ /**
+ * Returns the largest row index from the selection.
+ *
+ * @return the largest row index from the selection
+ */
+ public int getMaxSelectionRow()
+ {
+ if ((rowMapper == null) || (selection == null)
+ || (selection.length == 0))
+ return -1;
+ else
+ {
+ int[] rows = rowMapper.getRowsForPaths(selection);
+ int maxRow = -1;
+ for (int index = 0; index < rows.length; index++)
+ maxRow = Math.max(maxRow, rows[index]);
+ return maxRow;
+ }
+ }
+
+ /**
+ * Checks if a particular row is selected.
+ *
+ * @param row the index of the row to check
+ *
+ * @return <code>true</code> if the row is in this selection,
+ * <code>false</code> otherwise
+ */
+ public boolean isRowSelected(int row)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Updates the mappings from TreePaths to row indices.
+ */
+ public void resetRowSelection()
+ {
+ // TODO
+ }
+
+ /**
+ * getLeadSelectionRow
+ *
+ * @return int
+ */
+ public int getLeadSelectionRow()
+ {
+ if ((rowMapper == null) || (leadPath == null))
+ return -1;
+ else
+ return rowMapper.getRowsForPaths(new TreePath[] {
+ leadPath })[0];
+ }
+
+ /**
+ * getLeadSelectionPath
+ *
+ * @return TreePath
+ */
+ public TreePath getLeadSelectionPath()
+ {
+ return leadPath;
+ }
+
+ /**
+ * Adds a <code>PropertyChangeListener</code> object to this model.
+ *
+ * @param listener the listener to add.
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * Removes a <code>PropertyChangeListener</code> object from this model.
+ *
+ * @param listener the listener to remove.
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * Returns all added <code>PropertyChangeListener</code> objects.
+ *
+ * @return an array of listeners.
+ *
+ * @since 1.4
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * Makes sure the currently selected paths are valid according to the
+ * current selectionMode.
+ *
+ * If the selectionMode is set to {@link #CONTIGUOUS_TREE_SELECTION} and the
+ * selection isn't contiguous then the selection is reset to the first set
+ * of contguous paths.
+ *
+ * If the selectionMode is set to {@link #SINGLE_TREE_SELECTION} and the
+ * selection has more than one path, the selection is reset to the contain
+ * only the first path.
+ */
+ protected void insureRowContinuity()
+ {
+ // TODO
+ }
+
+ /**
+ * Returns <code>true</code> if the paths are contiguous or we have no
+ * RowMapper assigned.
+ *
+ * @param paths the paths to check for continuity
+ * @return <code>true</code> if the paths are contiguous or we have no
+ * RowMapper assigned
+ */
+ protected boolean arePathsContiguous(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Checks if the paths can be added. This returns <code>true</code> if:
+ * <ul>
+ * <li><code>paths</code> is <code>null</code> or empty</li>
+ * <li>we have no RowMapper assigned</li>
+ * <li>nothing is currently selected</li>
+ * <li>selectionMode is {@link #DISCONTIGUOUS_TREE_SELECTION}</li>
+ * <li>adding the paths to the selection still results in a contiguous set
+ * of paths</li>
+ *
+ * @param paths the paths to check
+ *
+ * @return <code>true</code> if the paths can be added with respect to the
+ * selectionMode
+ */
+ protected boolean canPathsBeAdded(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * Checks if the paths can be removed without breaking the continuity of the
+ * selection according to selectionMode.
+ *
+ * @param paths the paths to check
+ * @return <code>true</code> if the paths can be removed with respect to
+ * the selectionMode
+ */
+ protected boolean canPathsBeRemoved(TreePath[] paths)
+ {
+ return false; // TODO
+ }
+
+ /**
+ * notifyPathChange
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ protected void notifyPathChange(Vector value0, TreePath value1)
+ {
+ // TODO
+ }
+
+ /**
+ * Updates the lead index instance field.
+ */
+ protected void updateLeadIndex()
+ {
+ // TODO
+ }
+
+ /**
+ * Deprecated and not used.
+ */
+ protected void insureUniqueness()
+ {
+ // TODO
+ }
+}
diff --git a/libjava/classpath/javax/swing/tree/ExpandVetoException.java b/libjava/classpath/javax/swing/tree/ExpandVetoException.java
new file mode 100644
index 00000000000..1c8827c8a6c
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/ExpandVetoException.java
@@ -0,0 +1,83 @@
+/* ExpandVetoException.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+// Imports
+import javax.swing.event.TreeExpansionEvent;
+
+/**
+ * ExpandVetoException
+ * @author Andrew Selkirk
+ */
+public class ExpandVetoException extends Exception {
+
+ //-------------------------------------------------------------
+ // Variables --------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * event
+ */
+ protected TreeExpansionEvent event = null;
+
+
+ //-------------------------------------------------------------
+ // Initialization ---------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * Constructor ExpandVetoException
+ * @param event Tree Expansion Event
+ */
+ public ExpandVetoException(TreeExpansionEvent event) {
+ super();
+ this.event = event;
+ } // ExpandVetoException()
+
+ /**
+ * Constructor ExpandVetoException
+ * @param event Tree Expansion Event
+ * @param message Message
+ */
+ public ExpandVetoException(TreeExpansionEvent event, String message) {
+ super(message);
+ this.event = event;
+ } // ExpandVetoException()
+
+
+} // ExpandVetoException
diff --git a/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java
new file mode 100644
index 00000000000..67a21f0205a
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/FixedHeightLayoutCache.java
@@ -0,0 +1,244 @@
+/* FixedHeightLayoutCache.java --
+Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+import java.awt.Rectangle;
+import java.util.Enumeration;
+
+import javax.swing.event.TreeModelEvent;
+
+/**
+ * FixedHeightLayoutCache
+ *
+ * @author Andrew Selkirk
+ */
+public class FixedHeightLayoutCache
+ extends AbstractLayoutCache
+{
+
+ // -------------------------------------------------------------
+ // Variables --------------------------------------------------
+ // -------------------------------------------------------------
+
+ // -------------------------------------------------------------
+ // Initialization ---------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * Constructor FixedHeightLayoutCache
+ */
+ public FixedHeightLayoutCache()
+ {
+ // TODO
+ } // FixedHeightLayoutCache()
+
+ // -------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ // -------------------------------------------------------------
+
+ /**
+ * getRowCount
+ *
+ * @returns int
+ */
+ public int getRowCount()
+ {
+ return 0; // TODO
+ } // getRowCount()
+
+ /**
+ * invalidatePathBounds
+ *
+ * @param value0 TODO
+ */
+ public void invalidatePathBounds(TreePath value0)
+ {
+ // TODO
+ } // invalidatePathBounds()
+
+ /**
+ * invalidateSizes
+ */
+ public void invalidateSizes()
+ {
+ // TODO
+ } // invalidateSizes()
+
+ /**
+ * isExpanded
+ *
+ * @param value0 TODO
+ * @returns boolean
+ */
+ public boolean isExpanded(TreePath value0)
+ {
+ return false; // TODO
+ } // isExpanded()
+
+ /**
+ * getBounds
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @returns Rectangle
+ */
+ public Rectangle getBounds(TreePath value0, Rectangle value1)
+ {
+ return null; // TODO
+ } // getBounds()
+
+ /**
+ * getPathForRow
+ *
+ * @param value0 TODO
+ * @returns TreePath
+ */
+ public TreePath getPathForRow(int row)
+ {
+ //TODO
+ return null;
+ } // getPathForRow()
+
+ /**
+ * getRowForPath
+ *
+ * @param value0 TODO
+ * @returns int
+ */
+ public int getRowForPath(TreePath value0)
+ {
+ return 0;
+ } // getRowForPath()
+
+ /**
+ * getPathClosestTo
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ * @returns TreePath
+ */
+ public TreePath getPathClosestTo(int value0, int value1)
+ {
+ return null; // TODO
+ } // getPathClosestTo()
+
+ /**
+ * getVisibleChildCount
+ *
+ * @param value0 TODO
+ * @returns int
+ */
+ public int getVisibleChildCount(TreePath value0)
+ {
+ return 0; // TODO
+ } // getVisibleChildCount()
+
+ /**
+ * getVisiblePathsFrom
+ *
+ * @param value0 TODO
+ * @returns Enumeration
+ */
+ public Enumeration getVisiblePathsFrom(TreePath value0)
+ {
+ return null; // TODO
+ } // getVisiblePathsFrom()
+
+ /**
+ * setExpandedState
+ *
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void setExpandedState(TreePath value0, boolean value1)
+ {
+ // TODO
+ } // setExpandedState()
+
+ /**
+ * getExpandedState
+ *
+ * @param value0 TODO
+ * @returns boolean
+ */
+ public boolean getExpandedState(TreePath value0)
+ {
+ return false; // TODO
+ } // getExpandedState()
+
+ /**
+ * treeNodesChanged
+ *
+ * @param value0 TODO
+ */
+ public void treeNodesChanged(TreeModelEvent value0)
+ {
+ // TODO
+ } // treeNodesChanged()
+
+ /**
+ * treeNodesInserted
+ *
+ * @param value0 TODO
+ */
+ public void treeNodesInserted(TreeModelEvent value0)
+ {
+ // TODO
+ } // treeNodesInserted()
+
+ /**
+ * treeNodesRemoved
+ *
+ * @param value0 TODO
+ */
+ public void treeNodesRemoved(TreeModelEvent value0)
+ {
+ // TODO
+ } // treeNodesRemoved()
+
+ /**
+ * treeStructureChanged
+ *
+ * @param value0 TODO
+ */
+ public void treeStructureChanged(TreeModelEvent value0)
+ {
+ // TODO
+ } // treeStructureChanged()
+
+} // FixedHeightLayoutCache
diff --git a/libjava/classpath/javax/swing/tree/MutableTreeNode.java b/libjava/classpath/javax/swing/tree/MutableTreeNode.java
new file mode 100644
index 00000000000..9f0ff4ded81
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/MutableTreeNode.java
@@ -0,0 +1,104 @@
+/* MutableTreeNode.java --
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+/**
+ * MutableTreeNode public interface
+
+ * @author Andrew Selkirk
+ */
+public interface MutableTreeNode extends TreeNode
+{
+ /**
+ * Inserts a node as child at a given index.
+ *
+ * @param child the note to insert
+ * @param index the index
+ *
+ * @see #remove(int)
+ * @see #remove(MutableTreeNode)
+ * @see #setParent(MutableTreeNode)
+ */
+ void insert(MutableTreeNode child, int index);
+
+ /**
+ * Removes the child node a given index.
+ *
+ * @param index the index
+ *
+ * @see #insert(MutableTreeNode,int)
+ * @see #remove(MutableTreeNode)
+ * @see #removeFromParent()
+ */
+ void remove(int index);
+
+ /**
+ * Removes a given child node.
+ *
+ * @param node the node to remove
+ *
+ * @see #insert(MutableTreeNode,int)
+ * @see #remove(int)
+ * @see #removeFromParent()
+ */
+ void remove(MutableTreeNode node);
+
+ /**
+ * Sets a user object, the data represented by the node.
+ *
+ * @param object the data
+ */
+ void setUserObject(Object object);
+
+ /**
+ * Removes this node from its parent.
+ *
+ * @see #remove(int)
+ * @see #remove(MutableTreeNode)
+ */
+ void removeFromParent();
+
+ /**
+ * Sets the parent of the node.
+ *
+ * @param parent the parent
+ *
+ * @see #insert(MutableTreeNode,int)
+ */
+ void setParent(MutableTreeNode parent);
+}
diff --git a/libjava/classpath/javax/swing/tree/RowMapper.java b/libjava/classpath/javax/swing/tree/RowMapper.java
new file mode 100644
index 00000000000..690efb77e32
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/RowMapper.java
@@ -0,0 +1,54 @@
+/* RowMapper.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.tree;
+
+/**
+ * RowMapper public interface
+ * @author Andrew Selkirk
+ */
+public interface RowMapper {
+
+ /**
+ * getRowsForPaths
+ * @param path TreePath
+ * @return TODO
+ */
+ int[] getRowsForPaths(TreePath[] path);
+
+
+} // RowMapper
diff --git a/libjava/classpath/javax/swing/tree/TreeCellEditor.java b/libjava/classpath/javax/swing/tree/TreeCellEditor.java
new file mode 100644
index 00000000000..691cbc16386
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreeCellEditor.java
@@ -0,0 +1,65 @@
+/* TreeCellEditor.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.awt.Component;
+
+import javax.swing.CellEditor;
+import javax.swing.JTree;
+
+/**
+ * TreeCellEditor public interface
+ * @author Andrew Selkirk
+ */
+public interface TreeCellEditor extends CellEditor
+{
+ /**
+ * getTreeCellEditorComponent
+ * @param tree TODO
+ * @param value TODO
+ * @param isSelected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ * @return TODO
+ */
+ Component getTreeCellEditorComponent(JTree tree, Object value,
+ boolean isSelected, boolean expanded,
+ boolean leaf, int row);
+}
diff --git a/libjava/classpath/javax/swing/tree/TreeCellRenderer.java b/libjava/classpath/javax/swing/tree/TreeCellRenderer.java
new file mode 100644
index 00000000000..ebbe3fa9133
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreeCellRenderer.java
@@ -0,0 +1,67 @@
+/* TreeCellRenderer.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.awt.Component;
+
+import javax.swing.JTree;
+
+/**
+ * TreeCellRenderer public interface
+ * @author Andrew Selkirk
+ */
+public interface TreeCellRenderer {
+
+ /**
+ * getTreeCellRendererComponent
+ * @param tree TODO
+ * @param value TODO
+ * @param selected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ * @param us TODO
+ * @returns TODO
+ */
+ Component getTreeCellRendererComponent(JTree tree,
+ Object value, boolean selected, boolean expanded,
+ boolean leaf, int row, boolean hasFocus);
+
+
+} // TreeCellRenderer
diff --git a/libjava/classpath/javax/swing/tree/TreeModel.java b/libjava/classpath/javax/swing/tree/TreeModel.java
new file mode 100644
index 00000000000..759aaac588c
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreeModel.java
@@ -0,0 +1,109 @@
+/* TreeModel.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import javax.swing.event.TreeModelListener;
+
+/**
+ * TreeModel public interface
+ * @author Andrew Selkirk
+ */
+public interface TreeModel {
+
+ //-------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * getRoot
+ * @returns Object
+ */
+ Object getRoot();
+
+ /**
+ * getChild
+ * @param parent TODO
+ * @param index TODO
+ * @returns Object
+ */
+ Object getChild(Object parent, int index);
+
+ /**
+ * getChildCount
+ * @param parent TODO
+ * @returns int
+ */
+ int getChildCount(Object parent);
+
+ /**
+ * isLeaf
+ * @param node TODO
+ * @returns boolean
+ */
+ boolean isLeaf(Object node);
+
+ /**
+ * valueForPathChanged
+ * @param path TODO
+ * @param newvalue TODO
+ */
+ void valueForPathChanged(TreePath path, Object newvalue);
+
+ /**
+ * getIndexOfChild
+ * @param parent TODO
+ * @param ild TODO
+ * @returns int
+ */
+ int getIndexOfChild(Object parent, Object child);
+
+ /**
+ * addTreeModelListener
+ * @param listener TODO
+ */
+ void addTreeModelListener(TreeModelListener listener);
+
+ /**
+ * removeTreeModelListener
+ * @param listener TODO
+ */
+ void removeTreeModelListener(TreeModelListener listener);
+
+
+} // TreeModel
diff --git a/libjava/classpath/javax/swing/tree/TreeNode.java b/libjava/classpath/javax/swing/tree/TreeNode.java
new file mode 100644
index 00000000000..fb8f880f286
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreeNode.java
@@ -0,0 +1,99 @@
+/* TreeNode.java --
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.util.Enumeration;
+
+/**
+ * TreeNode public interface
+ * @author Andrew Selkirk
+ */
+public interface TreeNode {
+
+ //-------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * getParent
+ * @returns TreeNode
+ */
+ TreeNode getParent();
+
+ /**
+ * getIndex
+ * @param node TODO
+ * @returns int
+ */
+ int getIndex(TreeNode node);
+
+ /**
+ * getChildAt
+ * @param index TODO
+ * @returns TreeNode
+ */
+ TreeNode getChildAt(int index);
+
+ /**
+ * getChildCount
+ * @returns int
+ */
+ int getChildCount();
+
+ /**
+ * getAllowsChildren
+ * @returns boolean
+ */
+ boolean getAllowsChildren();
+
+ /**
+ * isLeaf
+ * @returns boolean
+ */
+ boolean isLeaf();
+
+ /**
+ * children
+ * @returns Enumeration
+ */
+ Enumeration children();
+
+
+} // TreeNode
+
diff --git a/libjava/classpath/javax/swing/tree/TreePath.java b/libjava/classpath/javax/swing/tree/TreePath.java
new file mode 100644
index 00000000000..37ec632c95f
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreePath.java
@@ -0,0 +1,299 @@
+/* TreePath.java --
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * A <code>TreePath</code> represents a sequence of tree elements that form
+ * a path starting from the root of a tree. A tree element can be represented
+ * by any {@link Object}.
+ *
+ * @author Andrew Selkirk
+ */
+public class TreePath implements Serializable
+{
+ static final long serialVersionUID = 4380036194768077479L;
+
+ /**
+ * path
+ */
+ private Object[] path = null;
+
+
+ /**
+ * Creates a path from the list of objects representing tree elements. The
+ * incoming array is copied so that subsequent changes do not affect this
+ * tree path.
+ *
+ * @param path the elements in the path (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>path</code> is <code>null</code>.
+ */
+ public TreePath(Object[] path)
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null 'path' not permitted.");
+ this.path = new Object[path.length];
+ System.arraycopy(path, 0, this.path, 0, path.length);
+ }
+
+ /**
+ * Creates a new path from a single element.
+ *
+ * @param element the element (<code>null</code> not permitted).
+ *
+ * @throws IllegalArgumentException if <code>element</code> is
+ * <code>null</code>.
+ */
+ public TreePath(Object element)
+ {
+ path = new Object[1];
+ path[0] = element;
+ }
+
+ /**
+ * Creates a new tree path by adding the specified <code>element</code> to
+ * the <code>path</code>.
+ *
+ * @param path a tree path.
+ * @param element a path element.
+ */
+ protected TreePath(TreePath path, Object element)
+ {
+ if (element == null)
+ throw new NullPointerException("Null 'element' argument.");
+ Object[] treepath = path.getPath();
+
+ // Create Tree Path
+ this.path = new Object[treepath.length + 1];
+ System.arraycopy(treepath, 0, this.path, 0, treepath.length);
+ this.path[treepath.length] = element;
+ }
+
+ /**
+ * Creates a new tree path using the first <code>length</code> elements
+ * from the given array.
+ *
+ * @param path the path elements.
+ * @param length the path length.
+ */
+ protected TreePath(Object[] path, int length)
+ {
+ // Create Path
+ this.path = new Object[length];
+ System.arraycopy(path, 0, this.path, 0, length);
+ }
+
+ /**
+ * Default constructor.
+ */
+ protected TreePath()
+ {
+ path = new Object[0];
+ }
+
+
+ /**
+ * Returns a hashcode for the path.
+ *
+ * @return A hashcode.
+ */
+ public int hashCode()
+ {
+ return getLastPathComponent().hashCode();
+ }
+
+ /**
+ * Tests this path for equality with an arbitrary object. An object is
+ * considered equal to this path if and only if:
+ * <ul>
+ * <li>the object is not <code>null</code>;</li>
+ * <li>the object is an instanceof {@link TreePath};</li>
+ * <li>the object contains the same elements in the same order as this
+ * {@link TreePath};</li>
+ * </ul>
+ *
+ * @param object the object (<code>null</code> permitted).
+ *
+ * @returns <code>true</code> if <code>obj</code> is equal to this tree path,
+ * and <code>false</code> otherwise.
+ */
+ public boolean equals(Object object)
+ {
+ Object[] treepath;
+ int index;
+
+ if (object instanceof TreePath)
+ {
+ treepath = ((TreePath) object).getPath();
+ if (treepath.length != path.length)
+ return false;
+ for (index = 0; index < path.length; index++)
+ {
+ if (!treepath[index].equals(path[index]))
+ return false;
+ }
+
+ // Tree Path's are equals
+ return true;
+ }
+
+ // Unequal
+ return false;
+ }
+
+ /**
+ * Returns a string representation of this path.
+ *
+ * @return A string representation of this path.
+ */
+ public String toString()
+ {
+ if (path.length == 1)
+ return String.valueOf(path[0]);
+ else
+ return Arrays.asList(path).toString();
+ }
+
+ /**
+ * Returns an array containing the path elements.
+ *
+ * @returns An array containing the path elements.
+ */
+ public Object[] getPath()
+ {
+ return (Object[]) path.clone();
+ }
+
+ /**
+ * Returns the last object in the path.
+ *
+ * @return The last object in the path.
+ */
+ public Object getLastPathComponent()
+ {
+ return path[path.length - 1];
+ }
+
+ /**
+ * Returns the number of elements in the path.
+ *
+ * @returns The number of elements in the path.
+ */
+ public int getPathCount()
+ {
+ return path.length;
+ }
+
+ /**
+ * Returns the element at the specified position in the path.
+ *
+ * @param position the element position (<code>0 &lt N - 1</code>, where
+ * <code>N</code> is the number of elements in the path).
+ *
+ * @return The element at the specified position.
+ *
+ * @throws IllegalArgumentException if <code>position</code> is outside the
+ * valid range.
+ */
+ public Object getPathComponent(int position)
+ {
+ if (position < 0 || position >= getPathCount())
+ throw new IllegalArgumentException("Invalid position: " + position);
+ return path[position];
+ }
+
+ /**
+ * Returns <code>true</code> if <code>path</code> is a descendant of this
+ * path, and <code>false</code> otherwise. If <code>path</code> is
+ * <code>null</code>, this method returns <code>false</code>.
+ *
+ * @param path the path to check (<code>null</code> permitted).
+ *
+ * @returns <code>true</code> if <code>path</code> is a descendant of this
+ * path, and <code>false</code> otherwise
+ */
+ public boolean isDescendant(TreePath path)
+ {
+ if (path == null)
+ return false;
+ int count = getPathCount();
+ if (path.getPathCount() < count)
+ return false;
+ for (int i = 0; i < count; i++)
+ {
+ if (!this.path[i].equals(path.getPathComponent(i)))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Creates a new path that is equivalent to this path plus the specified
+ * element.
+ *
+ * @param element the element.
+ *
+ * @returns A tree path.
+ */
+ public TreePath pathByAddingChild(Object element)
+ {
+ return new TreePath(this, element);
+ }
+
+ /**
+ * Returns the parent path, which is a path containing all the same elements
+ * as this path, except for the last one. If this path contains only one
+ * element, the method returns <code>null</code>.
+ *
+ * @returns The parent path, or <code>null</code> if this path has only one
+ * element.
+ */
+ public TreePath getParentPath()
+ {
+ // If this path has only one element, then we return null. That
+ // is what the JDK does.
+ if (path.length <= 1)
+ return null;
+
+ return new TreePath(this.getPath(), path.length - 1);
+ }
+}
diff --git a/libjava/classpath/javax/swing/tree/TreeSelectionModel.java b/libjava/classpath/javax/swing/tree/TreeSelectionModel.java
new file mode 100644
index 00000000000..4072ccc64c5
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/TreeSelectionModel.java
@@ -0,0 +1,84 @@
+/* TreeSelectionModel.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.beans.PropertyChangeListener;
+
+import javax.swing.event.TreeSelectionListener;
+
+/**
+ * TreeSelectionModel public interface
+ * @author Andrew Selkirk
+ */
+public interface TreeSelectionModel {
+
+ int SINGLE_TREE_SELECTION = 1;
+ int CONTIGUOUS_TREE_SELECTION = 2;
+ int DISCONTIGUOUS_TREE_SELECTION = 4;
+
+ void setSelectionMode(int mode);
+ int getSelectionMode();
+ void setSelectionPath(TreePath path);
+ void setSelectionPaths(TreePath[] paths);
+ void addSelectionPath(TreePath path);
+ void addSelectionPaths(TreePath[] paths);
+ void removeSelectionPath(TreePath path);
+ void removeSelectionPaths(TreePath[] paths);
+ TreePath getSelectionPath();
+ TreePath[] getSelectionPaths();
+ int getSelectionCount();
+ boolean isPathSelected(TreePath path);
+ boolean isSelectionEmpty();
+ void clearSelection();
+ void setRowMapper(RowMapper newMapper);
+ RowMapper getRowMapper();
+ int[] getSelectionRows();
+ int getMinSelectionRow();
+ int getMaxSelectionRow();
+ boolean isRowSelected(int row);
+ void resetRowSelection();
+ int getLeadSelectionRow();
+ TreePath getLeadSelectionPath();
+ void addPropertyChangeListener(PropertyChangeListener listener);
+ void removePropertyChangeListener(PropertyChangeListener listener);
+ void addTreeSelectionListener(TreeSelectionListener x);
+ void removeTreeSelectionListener(TreeSelectionListener x);
+
+
+} // TreeSelectionModel
diff --git a/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
new file mode 100644
index 00000000000..2c9136c5103
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/VariableHeightLayoutCache.java
@@ -0,0 +1,253 @@
+/* VariableHeightLayoutCache.java --
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.swing.tree;
+
+import java.awt.Rectangle;
+import java.util.Enumeration;
+
+import javax.swing.event.TreeModelEvent;
+
+/**
+ * VariableHeightLayoutCache
+ * @author Andrew Selkirk
+ */
+public class VariableHeightLayoutCache extends AbstractLayoutCache {
+
+ //-------------------------------------------------------------
+ // Variables --------------------------------------------------
+ //-------------------------------------------------------------
+
+
+ //-------------------------------------------------------------
+ // Initialization ---------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * Constructor VariableHeightLayoutCache
+ */
+ public VariableHeightLayoutCache() {
+ // TODO
+ } // VariableHeightLayoutCache()
+
+
+ //-------------------------------------------------------------
+ // Methods ----------------------------------------------------
+ //-------------------------------------------------------------
+
+ /**
+ * setModel
+ * @param value0 TODO
+ */
+ public void setModel(TreeModel value0) {
+ // TODO
+ } // setModel()
+
+ /**
+ * setRootVisible
+ * @param value0 TODO
+ */
+ public void setRootVisible(boolean value0) {
+ // TODO
+ } // setRootVisible()
+
+ /**
+ * setNodeDimensions
+ * @param value0 TODO
+ */
+ public void setNodeDimensions(NodeDimensions value0) {
+ // TODO
+ } // setNodeDimensions()
+
+ /**
+ * setExpandedState
+ * @param value0 TODO
+ * @param value1 TODO
+ */
+ public void setExpandedState(TreePath value0, boolean value1) {
+ // TODO
+ } // setExpandedState()
+
+ /**
+ * getExpandedState
+ * @param value0 TODO
+ * @returns boolean
+ */
+ public boolean getExpandedState(TreePath value0) {
+ return false; // TODO
+ } // getExpandedState()
+
+ /**
+ * getBounds
+ * @param value0 TODO
+ * @param value1 TODO
+ * @returns Rectangle
+ */
+ public Rectangle getBounds(TreePath value0, Rectangle value1) {
+ return null; // TODO
+ } // getBounds()
+
+ /**
+ * getPathForRow
+ * @param value0 TODO
+ * @returns TreePath
+ */
+ public TreePath getPathForRow(int value0) {
+ return null; // TODO
+ } // getPathForRow()
+
+ /**
+ * getRowForPath
+ * @param value0 TODO
+ * @returns int
+ */
+ public int getRowForPath(TreePath value0) {
+ return 0; // TODO
+ } // getRowForPath()
+
+ /**
+ * getRowCount
+ * @returns int
+ */
+ public int getRowCount() {
+ return 0; // TODO
+ } // getRowCount()
+
+ /**
+ * invalidatePathBounds
+ * @param value0 TODO
+ */
+ public void invalidatePathBounds(TreePath value0) {
+ // TODO
+ } // invalidatePathBounds()
+
+ /**
+ * getPreferredHeight
+ * @returns int
+ */
+ public int getPreferredHeight() {
+ return 0; // TODO
+ } // getPreferredHeight()
+
+ /**
+ * getPreferredWidth
+ * @param value0 TODO
+ * @returns int
+ */
+ public int getPreferredWidth(Rectangle value0) {
+ return 0; // TODO
+ } // getPreferredWidth()
+
+ /**
+ * getPathClosestTo
+ * @param value0 TODO
+ * @param value1 TODO
+ * @returns TreePath
+ */
+ public TreePath getPathClosestTo(int value0, int value1) {
+ return null; // TODO
+ } // getPathClosestTo()
+
+ /**
+ * getVisiblePathsFrom
+ * @param value0 TODO
+ * @returns Enumeration
+ */
+ public Enumeration getVisiblePathsFrom(TreePath value0) {
+ return null; // TODO
+ } // getVisiblePathsFrom()
+
+ /**
+ * getVisibleChildCount
+ * @param value0 TODO
+ * @returns int
+ */
+ public int getVisibleChildCount(TreePath value0) {
+ return 0; // TODO
+ } // getVisibleChildCount()
+
+ /**
+ * invalidateSizes
+ */
+ public void invalidateSizes() {
+ // TODO
+ } // invalidateSizes()
+
+ /**
+ * isExpanded
+ * @param value0 TODO
+ * @returns boolean
+ */
+ public boolean isExpanded(TreePath value0) {
+ return false; // TODO
+ } // isExpanded()
+
+ /**
+ * treeNodesChanged
+ * @param value0 TODO
+ */
+ public void treeNodesChanged(TreeModelEvent value0) {
+ // TODO
+ } // treeNodesChanged()
+
+ /**
+ * treeNodesInserted
+ * @param value0 TODO
+ */
+ public void treeNodesInserted(TreeModelEvent value0) {
+ // TODO
+ } // treeNodesInserted()
+
+ /**
+ * treeNodesRemoved
+ * @param value0 TODO
+ */
+ public void treeNodesRemoved(TreeModelEvent value0) {
+ // TODO
+ } // treeNodesRemoved()
+
+ /**
+ * treeStructureChanged
+ * @param value0 TODO
+ */
+ public void treeStructureChanged(TreeModelEvent value0) {
+ // TODO
+ } // treeStructureChanged()
+
+
+} // VariableHeightLayoutCache
diff --git a/libjava/classpath/javax/swing/tree/package.html b/libjava/classpath/javax/swing/tree/package.html
new file mode 100644
index 00000000000..22538e4bad3
--- /dev/null
+++ b/libjava/classpath/javax/swing/tree/package.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.swing.tree package.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.swing.tree</title></head>
+
+<body>
+<p>Interfaces and classes that support the {@link javax.swing.JTree}
+component.</p>
+
+</body>
+</html>
OpenPOWER on IntegriCloud