001 /*
002 * $Id: TreeTableNode.java 3100 2008-10-14 22:33:10Z rah003 $
003 *
004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005 * Santa Clara, California 95054, U.S.A. All rights reserved.
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020 */
021 package org.jdesktop.swingx.treetable;
022
023 import java.util.Enumeration;
024
025 import javax.swing.tree.TreeNode;
026
027 /**
028 * Defines the requirements for an object that can be used as a tree node in a
029 * {@code JXTreeTable}.
030 *
031 * @author Karl Schaefer
032 */
033 public interface TreeTableNode extends TreeNode {
034 /**
035 * Returns an enumeration this node's children.
036 *
037 * @return an enumeration of {@code TreeTableNode}s
038 */
039 Enumeration<? extends TreeTableNode> children();
040
041 /**
042 * Gets the value for this node that corresponds to a particular tabular
043 * column.
044 *
045 * @param column
046 * the column to query
047 * @return the value for the queried column
048 * @throws IndexOutOfBoundsException
049 * if {@code column} is not a valid column index
050 */
051 Object getValueAt(int column);
052
053 /**
054 * Overridden to specify the return type. Returns the child {@code TreeNode}
055 * at index {@code childIndex}. Models that utilize this node should verify
056 * the column count before querying this node, since nodes may return
057 * differing sizes even for the same model.
058 *
059 * @param childIndex
060 * the index of the child
061 * @return the {@code TreeTableNode} corresponding to the specified index
062 */
063 TreeTableNode getChildAt(int childIndex);
064
065 /**
066 * Returns the number of columns supported by this {@code TreeTableNode}.
067 *
068 * @return the number of columns this node supports
069 */
070 int getColumnCount();
071
072 /**
073 * Overridden to specify the return type. Returns the parent
074 * {@code TreeTableNode} of the receiver.
075 *
076 * @return the parent {@code TreeTableNode} or {@code null} if this node has
077 * no parent (such nodes are usually root nodes).
078 */
079 TreeTableNode getParent();
080
081 /**
082 * Determines whether the specified column is editable.
083 *
084 * @param column
085 * the column to query
086 * @return {@code true} if the column is editable, {@code false} otherwise
087 */
088 boolean isEditable(int column);
089
090 /**
091 * Sets the value for the given {@code column}.
092 *
093 * @param aValue
094 * the value to set
095 * @param column
096 * the column to set the value on
097 */
098 void setValueAt(Object aValue, int column);
099
100 /**
101 * Returns this node's user object.
102 *
103 * @return the Object stored at this node by the user
104 */
105 Object getUserObject();
106
107 /**
108 * Sets the user object stored in this node.
109 *
110 * @param userObject
111 * the object to store
112 */
113 void setUserObject(Object userObject);
114 }