summaryrefslogtreecommitdiff
path: root/javax/swing/tree
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/tree')
-rw-r--r--javax/swing/tree/AbstractLayoutCache.java36
-rw-r--r--javax/swing/tree/DefaultMutableTreeNode.java176
-rw-r--r--javax/swing/tree/DefaultTreeCellEditor.java4
-rw-r--r--javax/swing/tree/DefaultTreeCellRenderer.java401
-rw-r--r--javax/swing/tree/DefaultTreeModel.java796
-rw-r--r--javax/swing/tree/DefaultTreeSelectionModel.java1290
-rw-r--r--javax/swing/tree/ExpandVetoException.java4
-rw-r--r--javax/swing/tree/FixedHeightLayoutCache.java124
-rw-r--r--javax/swing/tree/MutableTreeNode.java12
-rw-r--r--javax/swing/tree/RowMapper.java4
-rw-r--r--javax/swing/tree/TreeCellEditor.java4
-rw-r--r--javax/swing/tree/TreeCellRenderer.java4
-rw-r--r--javax/swing/tree/TreeModel.java4
-rw-r--r--javax/swing/tree/TreeNode.java4
-rw-r--r--javax/swing/tree/TreePath.java224
-rw-r--r--javax/swing/tree/TreeSelectionModel.java4
-rw-r--r--javax/swing/tree/VariableHeightLayoutCache.java12
-rw-r--r--javax/swing/tree/package.html9
18 files changed, 1742 insertions, 1370 deletions
diff --git a/javax/swing/tree/AbstractLayoutCache.java b/javax/swing/tree/AbstractLayoutCache.java
index 6fb75f77f..adece101d 100644
--- a/javax/swing/tree/AbstractLayoutCache.java
+++ b/javax/swing/tree/AbstractLayoutCache.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -48,7 +48,8 @@ import javax.swing.event.TreeModelEvent;
*
* @author Andrew Selkirk
*/
-public abstract class AbstractLayoutCache implements RowMapper
+public abstract class AbstractLayoutCache
+ implements RowMapper
{
/**
* class NodeDimensions
@@ -74,8 +75,7 @@ public abstract class AbstractLayoutCache implements RowMapper
* @return Rectangle
*/
public abstract Rectangle getNodeDimensions(Object value0, int value1,
- int value2, boolean value3,
- Rectangle value4);
+ int value2, boolean value3, Rectangle value4);
}
/**
@@ -108,7 +108,7 @@ public abstract class AbstractLayoutCache implements RowMapper
*/
public AbstractLayoutCache()
{
- // Do nothing here.
+ // Do nothing here.
}
/**
@@ -134,27 +134,31 @@ public abstract class AbstractLayoutCache implements RowMapper
/**
* getNodeDimensions
*
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- * @param value3 TODO
- * @param value4 TODO
+ * @param value TODO
+ * @param row TODO
+ * @param depth TODO
+ * @param expanded TODO
+ * @param bounds TODO
*
* @return Rectangle
*/
- protected Rectangle getNodeDimensions(Object value0, int value1, int value2, boolean value3, Rectangle value4)
+ protected Rectangle getNodeDimensions(Object value, int row, int depth,
+ boolean expanded, Rectangle bounds)
{
- return null; // TODO
+ if (bounds == null)
+ return new Rectangle();
+ return null;
+ // TODO
}
/**
* Sets the model that provides the tree data.
*
- * @param the model
+ * @param model the model
*/
public void setModel(TreeModel model)
{
- treeModel = model;
+ treeModel = model;
}
/**
@@ -314,7 +318,7 @@ public abstract class AbstractLayoutCache implements RowMapper
*
* @return int
*/
- public abstract int getVisibleChildCount(TreePath value0);
+ public abstract int getVisibleChildCount(TreePath path);
/**
* setExpandedState
diff --git a/javax/swing/tree/DefaultMutableTreeNode.java b/javax/swing/tree/DefaultMutableTreeNode.java
index de34ee072..e709e2a04 100644
--- a/javax/swing/tree/DefaultMutableTreeNode.java
+++ b/javax/swing/tree/DefaultMutableTreeNode.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -45,14 +45,19 @@ 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
@@ -232,7 +237,7 @@ public class DefaultMutableTreeNode
* Inserts given child node at the given index.
*
* @param node the child node
- * @param value the index.
+ * @param index the index.
*/
public void insert(MutableTreeNode node, int index)
{
@@ -353,7 +358,7 @@ public class DefaultMutableTreeNode
*/
public void removeFromParent()
{
- // FIXME: IS this implementation really correct ?
+ parent.remove(this);
parent = null;
}
@@ -389,7 +394,7 @@ public class DefaultMutableTreeNode
/**
* isNodeDescendant
*
- * @param node0 TODO
+ * @param node TODO
*
* @return boolean
*/
@@ -656,7 +661,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration preorderEnumeration()
{
- return null; // TODO: Implement me.
+ return new PreorderEnumeration(this);
}
/**
@@ -666,7 +671,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration postorderEnumeration()
{
- return null; // TODO: Implement me.
+ return new PostorderEnumeration(this);
}
/**
@@ -676,7 +681,7 @@ public class DefaultMutableTreeNode
*/
public Enumeration breadthFirstEnumeration()
{
- return null; // TODO: Implement me.
+ return new BreadthFirstEnumeration(this);
}
/**
@@ -913,6 +918,7 @@ public class DefaultMutableTreeNode
if (parent == null)
return null;
+ // TODO: Fix implementation.
return null;
//return parent.getChildAfter(this);
}
@@ -926,7 +932,8 @@ public class DefaultMutableTreeNode
{
if (parent == null)
return null;
-
+
+ // TODO: Fix implementation.
return null;
//return parent.getChildBefore(this);
}
@@ -951,4 +958,155 @@ public class DefaultMutableTreeNode
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/javax/swing/tree/DefaultTreeCellEditor.java b/javax/swing/tree/DefaultTreeCellEditor.java
index af280201b..e509d2c18 100644
--- a/javax/swing/tree/DefaultTreeCellEditor.java
+++ b/javax/swing/tree/DefaultTreeCellEditor.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/DefaultTreeCellRenderer.java b/javax/swing/tree/DefaultTreeCellRenderer.java
index beae3840b..0f1792161 100644
--- a/javax/swing/tree/DefaultTreeCellRenderer.java
+++ b/javax/swing/tree/DefaultTreeCellRenderer.java
@@ -1,6 +1,6 @@
-/* DefaultTreeCellRenderer.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
-
+/* 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
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -35,7 +35,6 @@ 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;
@@ -54,15 +53,16 @@ import javax.swing.plaf.UIResource;
/**
* DefaultTreeCellRenderer
+ *
* @author Andrew Selkirk
*/
public class DefaultTreeCellRenderer
- extends JLabel
- implements TreeCellRenderer
+ extends JLabel
+ implements TreeCellRenderer
{
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Variables --------------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* selected
@@ -118,380 +118,475 @@ public class DefaultTreeCellRenderer
* 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.textBackground"));
- setBackgroundSelectionColor(defaults.getColor("Tree.selectionBackground"));
- setBorderSelectionColor(defaults.getColor("Tree.selectionBorderColor"));
+ 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");
+ public Icon getDefaultOpenIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.openIcon");
}
/**
* getDefaultClosedIcon
+ *
* @returns Icon
*/
- public Icon getDefaultClosedIcon() {
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
+ public Icon getDefaultClosedIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.closedIcon");
}
/**
* getDefaultLeafIcon
+ *
* @returns Icon
*/
- public Icon getDefaultLeafIcon() {
- return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
+ public Icon getDefaultLeafIcon()
+ {
+ return UIManager.getLookAndFeelDefaults().getIcon("Tree.leafIcon");
}
/**
* setOpenIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setOpenIcon(Icon i) {
- openIcon = i;
+ public void setOpenIcon(Icon i)
+ {
+ openIcon = i;
}
/**
* getOpenIcon
+ *
* @returns Icon
*/
- public Icon getOpenIcon() {
- return openIcon;
- }
+ public Icon getOpenIcon()
+ {
+ return openIcon;
+ }
/**
* setClosedIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setClosedIcon(Icon i) {
- closedIcon = i;
- }
+ public void setClosedIcon(Icon i)
+ {
+ closedIcon = i;
+ }
/**
* getClosedIcon
+ *
* @returns Icon
*/
- public Icon getClosedIcon() {
- return closedIcon;
- }
+ public Icon getClosedIcon()
+ {
+ return closedIcon;
+ }
/**
* setLeafIcon
- * @param value0 TODO
+ *
+ * @param i the icon.
*/
- public void setLeafIcon(Icon i) {
- leafIcon = i;
+ public void setLeafIcon(Icon i)
+ {
+ leafIcon = i;
}
/**
* getLeafIcon
+ *
* @returns Icon
*/
- public Icon getLeafIcon() {
- return leafIcon;
+ public Icon getLeafIcon()
+ {
+ return leafIcon;
}
/**
* setTextSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setTextSelectionColor(Color c) {
- textSelectionColor = c;
+ public void setTextSelectionColor(Color c)
+ {
+ textSelectionColor = c;
}
/**
* getTextSelectionColor
+ *
* @returns Color
*/
- public Color getTextSelectionColor() {
- return textSelectionColor;
+ public Color getTextSelectionColor()
+ {
+ return textSelectionColor;
}
/**
* setTextNonSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setTextNonSelectionColor(Color c) {
- textNonSelectionColor = c;
+ public void setTextNonSelectionColor(Color c)
+ {
+ textNonSelectionColor = c;
}
/**
* getTextNonSelectionColor
+ *
* @returns Color
*/
- public Color getTextNonSelectionColor() {
- return textNonSelectionColor;
+ public Color getTextNonSelectionColor()
+ {
+ return textNonSelectionColor;
}
/**
* setBackgroundSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBackgroundSelectionColor(Color c) {
- backgroundSelectionColor = c;
+ public void setBackgroundSelectionColor(Color c)
+ {
+ backgroundSelectionColor = c;
}
/**
* getBackgroundSelectionColor
+ *
* @returns Color
*/
- public Color getBackgroundSelectionColor() {
- return backgroundSelectionColor;
+ public Color getBackgroundSelectionColor()
+ {
+ return backgroundSelectionColor;
}
/**
* setBackgroundNonSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBackgroundNonSelectionColor(Color c) {
- backgroundNonSelectionColor = c;
+ public void setBackgroundNonSelectionColor(Color c)
+ {
+ backgroundNonSelectionColor = c;
}
/**
* getBackgroundNonSelectionColor
+ *
* @returns Color
*/
- public Color getBackgroundNonSelectionColor() {
- return backgroundNonSelectionColor;
+ public Color getBackgroundNonSelectionColor()
+ {
+ return backgroundNonSelectionColor;
}
/**
* setBorderSelectionColor
- * @param value0 TODO
+ *
+ * @param c the color.
*/
- public void setBorderSelectionColor(Color c) {
- borderSelectionColor = c;
+ public void setBorderSelectionColor(Color c)
+ {
+ borderSelectionColor = c;
}
/**
* getBorderSelectionColor
+ *
* @returns Color
*/
- public Color getBorderSelectionColor() {
- return borderSelectionColor;
+ 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);
+ *
+ * @param f the font.
+ */
+ 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);
+ *
+ * @param c the color.
+ */
+ 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
+ *
+ * @param tree TODO
+ * @param val TODO
+ * @param selected TODO
+ * @param expanded TODO
+ * @param leaf TODO
+ * @param row TODO
+ * @param hasFocus TODO
* @returns Component
*/
- public Component getTreeCellRendererComponent(JTree tree,
- Object val,
- boolean selected,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus) {
- this.selected = selected;
- this.hasFocus = hasFocus;
-
- if (leaf)
- setIcon(getLeafIcon());
- else if (expanded)
- setIcon(getOpenIcon());
- else
- setIcon(getClosedIcon());
-
- setText(val.toString());
- setHorizontalAlignment(LEFT);
- setVerticalAlignment(TOP);
-
- return this;
+ public Component getTreeCellRendererComponent(JTree tree, Object val,
+ boolean selected, boolean expanded, boolean leaf, int row,
+ boolean hasFocus)
+ {
+ if (leaf)
+ setIcon(getLeafIcon());
+ else if (expanded)
+ setIcon(getOpenIcon());
+ else
+ setIcon(getClosedIcon());
+
+ setText(val.toString());
+ 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
+ *
+ * @param g the graphics device.
*/
- public void paint(Graphics g) {
- super.paint(g);
+ public void paint(Graphics g)
+ {
+ super.paint(g);
}
/**
* getPreferredSize
+ *
* @returns Dimension
*/
- public Dimension getPreferredSize() {
+ public Dimension getPreferredSize()
+ {
return null; // TODO
} // getPreferredSize()
/**
* validate
*/
- public void validate() {
- // TODO
+ public void validate()
+ {
+ // Overridden for performance reasons.
} // validate()
/**
* revalidate
*/
- public void revalidate() {
- // TODO
+ 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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) {
- // 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 value1, boolean value2) {
- // TODO
+ *
+ * @param name the property name.
+ * @param v1 the old value.
+ * @param v2 the new value.
+ */
+ public void firePropertyChange(String name, boolean v1, boolean v2)
+ {
+ // Overridden for performance reasons.
} // firePropertyChange()
-
} // DefaultTreeCellRenderer
diff --git a/javax/swing/tree/DefaultTreeModel.java b/javax/swing/tree/DefaultTreeModel.java
index 2e34a3522..e4291e130 100644
--- a/javax/swing/tree/DefaultTreeModel.java
+++ b/javax/swing/tree/DefaultTreeModel.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -47,405 +47,409 @@ 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
+ 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)
- {
- 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);
- }
+ static final long serialVersionUID = -2621068368932566998L;
+
+ /**
+ * root
+ */
+ protected TreeNode root = null;
+
+ /**
+ * listenerList
+ */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ /**
+ * asksAllowsChildren
+ */
+ protected boolean asksAllowsChildren;
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param root the tree root.
+ */
+ public DefaultTreeModel(TreeNode root)
+ {
+ if (root == null)
+ root = new DefaultMutableTreeNode();
+ setRoot(root);
+ }
+
+ /**
+ * Constructor DefaultTreeModel
+ * @param root the tree root.
+ * @param asksAllowsChildren TODO
+ */
+ public DefaultTreeModel(TreeNode root, boolean asksAllowsChildren)
+ {
+ setRoot(root);
+ this.asksAllowsChildren = asksAllowsChildren;
+ }
+
+ /**
+ * writeObject
+ * @param obj the object.
+ * @exception IOException TODO
+ */
+ private void writeObject(ObjectOutputStream obj) 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 value TODO
+ */
+ public void setAsksAllowsChildren(boolean value)
+ {
+ asksAllowsChildren = value; // TODO
+ }
+
+ /**
+ * setRoot
+ * @param root the root node.
+ */
+ 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 parent TODO
+ * @param child TODO
+ * @return int
+ */
+ public int getIndexOfChild(Object parent, Object child)
+ {
+ return 0; // TODO
+ }
+
+ /**
+ * getChild
+ * @param node TODO
+ * @param idx TODO
+ * @return Object
+ */
+ public Object getChild(Object node, int idx)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildAt(idx);
+ else
+ return null;
+ }
+
+ /**
+ * getChildCount
+ * @param node TODO
+ * @return int
+ */
+ public int getChildCount(Object node)
+ {
+ if (node instanceof TreeNode)
+ return ((TreeNode) node).getChildCount();
+ else
+ return 0;
+ }
+
+ /**
+ * isLeaf
+ * @param node 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/javax/swing/tree/DefaultTreeSelectionModel.java b/javax/swing/tree/DefaultTreeSelectionModel.java
index d53de53aa..de27dad04 100644
--- a/javax/swing/tree/DefaultTreeSelectionModel.java
+++ b/javax/swing/tree/DefaultTreeSelectionModel.java
@@ -1,6 +1,6 @@
-/* DefaultTreeSelectionModel.java --
- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
-
+/* 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
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -35,7 +35,6 @@ 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;
@@ -54,593 +53,702 @@ import javax.swing.event.TreeSelectionListener;
/**
* DefaultTreeSelectionModel
+ *
* @author Andrew Selkirk
*/
public class DefaultTreeSelectionModel
- implements Cloneable, Serializable, TreeSelectionModel
+ 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 {@link RowMapper
- */
- public void setRowMapper(RowMapper value0)
- {
- // TODO
- }
-
- /**
- * Returns the RowMapper that is currently used to map between paths and
- * their rows.
- *
- * @return the current RowMapper
- *
- * @see {@link 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 {@link #getSelectionMode}
- * @see {@link #SINGLE_TREE_SELECTION}
- * @see {@link #CONTIGUOUS_TREE_SELECTION}
- * @see {@link #DISCONTIGUOUS_TREE_SELECTION}
- */
- public void setSelectionMode(int mode)
- {
- selectionMode = mode;
- }
-
- /**
- * Returns the current selection mode.
- *
- * @return the current selection mode
- *
- * @see {@link #setSelectionMode}
- * @see {@link #SINGLE_TREE_SELECTION}
- * @see {@link #CONTIGUOUS_TREE_SELECTION}
- * @see {@link #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[] value0)
- {
- // 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 value0)
- {
- // TODO
- }
-
- /**
- * 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[] value0)
- {
- // TODO
- }
-
- /**
- * 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 value0)
- {
- // TODO
- }
-
- /**
- * Removes the paths from the selection.
- *
- * If this changes the selection the registered TreeSelectionListeners
- * are notified.
- *
- * @param paths the path to remove
- */
- public void removeSelectionPaths(TreePath[] value0)
- {
- // TODO
- }
-
- /**
- * 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 value0)
- {
- return false; // TODO
- }
-
- /**
- * 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()
- {
- // TODO
- }
-
- /**
- * 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[]) listenerList.getListeners(TreeSelectionListener.class);
- }
-
- /**
- * fireValueChanged
- *
- * @param event the event to fire.
- */
- protected void fireValueChanged(TreeSelectionEvent event)
- {
- TreeSelectionListener[] listeners = getTreeSelectionListeners();
-
- for (int i = listeners.length - 1; i >= 0; --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 value0)
- {
- 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[] value0)
- {
- 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[] value0)
- {
- 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[] value0)
- {
- 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
- }
+ 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/javax/swing/tree/ExpandVetoException.java b/javax/swing/tree/ExpandVetoException.java
index 5edf09a11..1c8827c8a 100644
--- a/javax/swing/tree/ExpandVetoException.java
+++ b/javax/swing/tree/ExpandVetoException.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/FixedHeightLayoutCache.java b/javax/swing/tree/FixedHeightLayoutCache.java
index 5cb6d3a2a..535417ec3 100644
--- a/javax/swing/tree/FixedHeightLayoutCache.java
+++ b/javax/swing/tree/FixedHeightLayoutCache.java
@@ -1,5 +1,5 @@
/* FixedHeightLayoutCache.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -35,7 +35,6 @@ 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;
@@ -45,192 +44,201 @@ import javax.swing.event.TreeModelEvent;
/**
* FixedHeightLayoutCache
+ *
* @author Andrew Selkirk
*/
-public class FixedHeightLayoutCache extends AbstractLayoutCache {
+public class FixedHeightLayoutCache
+ extends AbstractLayoutCache
+{
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Variables --------------------------------------------------
- //-------------------------------------------------------------
-
+ // -------------------------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Initialization ---------------------------------------------
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
/**
* Constructor FixedHeightLayoutCache
*/
- public FixedHeightLayoutCache() {
+ public FixedHeightLayoutCache()
+ {
// TODO
} // FixedHeightLayoutCache()
-
- //-------------------------------------------------------------
+ // -------------------------------------------------------------
// Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * setModel
- * @param value0 TODO
- */
- public void setModel(TreeModel value0) {
- // TODO
- } // setModel()
-
- /**
- * setRootVisible
- * @param value0 TODO
- */
- public void setRootVisible(boolean value0) {
- // TODO
- } // setRootVisible()
-
- /**
- * setRowHeight
- * @param value0 TODO
- */
- public void setRowHeight(int value0) {
- // TODO
- } // setRowHeight()
+ // -------------------------------------------------------------
/**
* getRowCount
+ *
* @returns int
*/
- public int getRowCount() {
+ public int getRowCount()
+ {
return 0; // TODO
} // getRowCount()
/**
* invalidatePathBounds
+ *
* @param value0 TODO
*/
- public void invalidatePathBounds(TreePath value0) {
+ public void invalidatePathBounds(TreePath value0)
+ {
// TODO
} // invalidatePathBounds()
/**
* invalidateSizes
*/
- public void invalidateSizes() {
+ public void invalidateSizes()
+ {
// TODO
} // invalidateSizes()
/**
* isExpanded
+ *
* @param value0 TODO
* @returns boolean
*/
- public boolean isExpanded(TreePath value0) {
+ 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) {
+ public Rectangle getBounds(TreePath value0, Rectangle value1)
+ {
return null; // TODO
} // getBounds()
/**
* getPathForRow
- * @param value0 TODO
+ *
+ * @param row TODO
* @returns TreePath
*/
- public TreePath getPathForRow(int value0) {
- return null; // TODO
+ public TreePath getPathForRow(int row)
+ {
+ //TODO
+ return null;
} // getPathForRow()
/**
* getRowForPath
+ *
* @param value0 TODO
* @returns int
*/
- public int getRowForPath(TreePath value0) {
- return 0; // TODO
+ public int getRowForPath(TreePath value0)
+ {
+ return 0;
} // getRowForPath()
/**
* getPathClosestTo
+ *
* @param value0 TODO
* @param value1 TODO
* @returns TreePath
*/
- public TreePath getPathClosestTo(int value0, int value1) {
+ public TreePath getPathClosestTo(int value0, int value1)
+ {
return null; // TODO
} // getPathClosestTo()
/**
* getVisibleChildCount
+ *
* @param value0 TODO
* @returns int
*/
- public int getVisibleChildCount(TreePath value0) {
+ public int getVisibleChildCount(TreePath value0)
+ {
return 0; // TODO
} // getVisibleChildCount()
/**
* getVisiblePathsFrom
+ *
* @param value0 TODO
* @returns Enumeration
*/
- public Enumeration getVisiblePathsFrom(TreePath value0) {
+ public Enumeration getVisiblePathsFrom(TreePath value0)
+ {
return null; // TODO
} // getVisiblePathsFrom()
/**
* setExpandedState
+ *
* @param value0 TODO
* @param value1 TODO
*/
- public void setExpandedState(TreePath value0, boolean value1) {
+ public void setExpandedState(TreePath value0, boolean value1)
+ {
// TODO
} // setExpandedState()
/**
* getExpandedState
+ *
* @param value0 TODO
* @returns boolean
*/
- public boolean getExpandedState(TreePath value0) {
+ public boolean getExpandedState(TreePath value0)
+ {
return false; // TODO
} // getExpandedState()
/**
* treeNodesChanged
+ *
* @param value0 TODO
*/
- public void treeNodesChanged(TreeModelEvent value0) {
+ public void treeNodesChanged(TreeModelEvent value0)
+ {
// TODO
} // treeNodesChanged()
/**
* treeNodesInserted
+ *
* @param value0 TODO
*/
- public void treeNodesInserted(TreeModelEvent value0) {
+ public void treeNodesInserted(TreeModelEvent value0)
+ {
// TODO
} // treeNodesInserted()
/**
* treeNodesRemoved
+ *
* @param value0 TODO
*/
- public void treeNodesRemoved(TreeModelEvent value0) {
+ public void treeNodesRemoved(TreeModelEvent value0)
+ {
// TODO
} // treeNodesRemoved()
/**
* treeStructureChanged
+ *
* @param value0 TODO
*/
- public void treeStructureChanged(TreeModelEvent value0) {
+ public void treeStructureChanged(TreeModelEvent value0)
+ {
// TODO
} // treeStructureChanged()
-
} // FixedHeightLayoutCache
diff --git a/javax/swing/tree/MutableTreeNode.java b/javax/swing/tree/MutableTreeNode.java
index 1f0c943aa..9f0ff4ded 100644
--- a/javax/swing/tree/MutableTreeNode.java
+++ b/javax/swing/tree/MutableTreeNode.java
@@ -1,5 +1,5 @@
/* MutableTreeNode.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -61,7 +61,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param index the index
*
- * @see #add(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
* @see #remove(MutableTreeNode)
* @see #removeFromParent()
*/
@@ -72,7 +72,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param node the node to remove
*
- * @see #add(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
* @see #remove(int)
* @see #removeFromParent()
*/
@@ -98,7 +98,7 @@ public interface MutableTreeNode extends TreeNode
*
* @param parent the parent
*
- * @see insert(MutableTreeNode,int)
+ * @see #insert(MutableTreeNode,int)
*/
void setParent(MutableTreeNode parent);
}
diff --git a/javax/swing/tree/RowMapper.java b/javax/swing/tree/RowMapper.java
index ea3122a46..690efb77e 100644
--- a/javax/swing/tree/RowMapper.java
+++ b/javax/swing/tree/RowMapper.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/TreeCellEditor.java b/javax/swing/tree/TreeCellEditor.java
index 4b4357a16..691cbc163 100644
--- a/javax/swing/tree/TreeCellEditor.java
+++ b/javax/swing/tree/TreeCellEditor.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/TreeCellRenderer.java b/javax/swing/tree/TreeCellRenderer.java
index ebd173efa..ebbe3fa91 100644
--- a/javax/swing/tree/TreeCellRenderer.java
+++ b/javax/swing/tree/TreeCellRenderer.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/TreeModel.java b/javax/swing/tree/TreeModel.java
index 00bd88b4c..759aaac58 100644
--- a/javax/swing/tree/TreeModel.java
+++ b/javax/swing/tree/TreeModel.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/TreeNode.java b/javax/swing/tree/TreeNode.java
index d7967f0ef..fb8f880f2 100644
--- a/javax/swing/tree/TreeNode.java
+++ b/javax/swing/tree/TreeNode.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/TreePath.java b/javax/swing/tree/TreePath.java
index 7c16fc21e..37ec632c9 100644
--- a/javax/swing/tree/TreePath.java
+++ b/javax/swing/tree/TreePath.java
@@ -1,5 +1,5 @@
/* TreePath.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -38,13 +38,14 @@ 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.Arrays;
/**
- * TreePath
+ * 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
@@ -58,39 +59,48 @@ public class TreePath implements Serializable
/**
- * Constructor TreePath
- * @param path TODO
+ * 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)
{
- // Create 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);
}
/**
- * Constructor TreePath
- * @param element TODO
+ * 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)
{
- // Create Path
path = new Object[1];
path[0] = element;
}
/**
- * Constructor TreePath
- * @param path TODO
- * @param element TODO
+ * 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)
{
- // Variables
- Object[] treepath;
-
- // Get Tree Path
- treepath = path.getPath();
+ if (element == null)
+ throw new NullPointerException("Null 'element' argument.");
+ Object[] treepath = path.getPath();
// Create Tree Path
this.path = new Object[treepath.length + 1];
@@ -99,9 +109,11 @@ public class TreePath implements Serializable
}
/**
- * Constructor TreePath
- * @param path TODO
- * @param length TODO
+ * 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)
{
@@ -111,7 +123,7 @@ public class TreePath implements Serializable
}
/**
- * Constructor TreePath
+ * Default constructor.
*/
protected TreePath()
{
@@ -120,8 +132,9 @@ public class TreePath implements Serializable
/**
- * hashCode
- * @returns int
+ * Returns a hashcode for the path.
+ *
+ * @return A hashcode.
*/
public int hashCode()
{
@@ -129,30 +142,33 @@ public class TreePath implements Serializable
}
/**
- * equals
- * @param object TODO
- * @returns boolean
+ * 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)
{
- // Variables
- Object[] treepath;
- int index;
+ Object[] treepath;
+ int index;
- // Check for TreePath
if (object instanceof TreePath)
{
- // Get Path Elements
treepath = ((TreePath) object).getPath();
-
- // Check length
if (treepath.length != path.length)
return false;
-
- // Check Elements
for (index = 0; index < path.length; index++)
{
- if (treepath[index] != path[index])
+ if (!treepath[index].equals(path[index]))
return false;
}
@@ -165,49 +181,32 @@ public class TreePath implements Serializable
}
/**
- * toString
- * @returns String
+ * Returns a string representation of this path.
+ *
+ * @return A string representation of this path.
*/
public String toString()
{
- return null; // TODO
+ if (path.length == 1)
+ return String.valueOf(path[0]);
+ else
+ return Arrays.asList(path).toString();
}
/**
- * 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
- }
-
- /**
- * getPath
- * @returns Object[]
+ * Returns an array containing the path elements.
+ *
+ * @returns An array containing the path elements.
*/
public Object[] getPath()
{
- return path;
+ return (Object[]) path.clone();
}
/**
- * getLastPathComponent
- * @returns Object
+ * Returns the last object in the path.
+ *
+ * @return The last object in the path.
*/
public Object getLastPathComponent()
{
@@ -215,8 +214,9 @@ public class TreePath implements Serializable
}
/**
- * getPathCount
- * @returns int
+ * Returns the number of elements in the path.
+ *
+ * @returns The number of elements in the path.
*/
public int getPathCount()
{
@@ -224,57 +224,55 @@ public class TreePath implements Serializable
}
/**
- * getPathComponent
- * @param position TODO
- * @returns Object
+ * 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];
}
/**
- * isDescendant
- * @param path TODO
- * @returns boolean
+ * 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)
{
-
- // Variables
- Object[] treepath;
- int index;
- int index2;
-
- // Get Descendant path
- treepath = path.getPath();
-
- // Locate Start Index
- index = 0;
- index2 = 0;
- while (treepath[index] != this.path[index2])
- index++;
-
- // Verify Paths
- while (treepath[index] == this.path[index2])
- {
- index++;
- index2++;
- }
-
- // Check for descendant
- if (index2 != this.path.length)
+ if (path == null)
return false;
-
- // Is Descendant
+ 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;
-
}
/**
- * pathByAddingChild
- * @param element TODO
- * @returns TreePath
+ * 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)
{
@@ -282,8 +280,12 @@ public class TreePath implements Serializable
}
/**
- * getParentPath
- * @returns TreePath
+ * 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()
{
diff --git a/javax/swing/tree/TreeSelectionModel.java b/javax/swing/tree/TreeSelectionModel.java
index c72617bff..4072ccc64 100644
--- a/javax/swing/tree/TreeSelectionModel.java
+++ b/javax/swing/tree/TreeSelectionModel.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
diff --git a/javax/swing/tree/VariableHeightLayoutCache.java b/javax/swing/tree/VariableHeightLayoutCache.java
index 14e6ea902..2c9136c51 100644
--- a/javax/swing/tree/VariableHeightLayoutCache.java
+++ b/javax/swing/tree/VariableHeightLayoutCache.java
@@ -15,8 +15,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -87,14 +87,6 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
} // setRootVisible()
/**
- * setRowHeight
- * @param value0 TODO
- */
- public void setRowHeight(int value0) {
- // TODO
- } // setRowHeight()
-
- /**
* setNodeDimensions
* @param value0 TODO
*/
diff --git a/javax/swing/tree/package.html b/javax/swing/tree/package.html
index 32d3d3c3e..22538e4ba 100644
--- a/javax/swing/tree/package.html
+++ b/javax/swing/tree/package.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in javax.swing.tree package.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -16,8 +16,8 @@ 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
+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
@@ -40,7 +40,8 @@ exception statement from your version. -->
<head><title>GNU Classpath - javax.swing.tree</title></head>
<body>
-<p></p>
+<p>Interfaces and classes that support the {@link javax.swing.JTree}
+component.</p>
</body>
</html>