001/* 002 * $Id: MutableTreeTableNode.java 3927 2011-02-22 16:34:11Z kleopatra $ 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 */ 021package org.jdesktop.swingx.treetable; 022 023import java.util.Enumeration; 024 025/** 026 * Defines the requirements for a tree table node object that can change -- by 027 * adding or removing child nodes, or by changing the contents of a user object 028 * stored in the node. 029 * <p> 030 * Note this does not extend {@code MutableTreeNode} to minimize the contract 031 * breakage, cf. {@link TreeTableNode#getIndex(javax.swing.tree.TreeNode)}. 032 * 033 * @see javax.swing.tree.MutableTreeNode 034 * 035 * @author Karl Schaefer 036 */ 037public interface MutableTreeTableNode extends TreeTableNode { 038 /** 039 * Returns an enumeration this node's children. 040 * 041 * @return an enumeration of {@code TreeTableNode}s 042 */ 043 @Override 044 Enumeration<? extends MutableTreeTableNode> children(); 045 046 /** 047 * Adds the {@code child} to this node at the specified {@code index}. This 048 * method calls {@code setParent} on {@code child} with {@code this} as the 049 * parameter. 050 * 051 * @param child 052 * the node to add as a child 053 * @param index 054 * the index of the child 055 * @throws IndexOutOfBoundsException 056 * if {@code index} is not a valid index 057 */ 058 void insert(MutableTreeTableNode child, int index); 059 060 /** 061 * Removes the child node at the specified {@code index} from this node. 062 * This method calls {@code setParent} on {@code child} with a {@code null} 063 * parameter. 064 * 065 * @param index 066 * the index of the child 067 * @throws IndexOutOfBoundsException 068 * if {@code index} is not a valid index 069 */ 070 void remove(int index); 071 072 /** 073 * Removes the specified child {@code node} from this node. 074 * This method calls {@code setParent} on {@code child} with a {@code null} 075 * parameter. 076 * 077 * @param node 078 * the index of the child 079 */ 080 void remove(MutableTreeTableNode node); 081 082 /** 083 * Removes this node from it's parent. Most implementations will use 084 * {@code getParent().remove(this)}. 085 * 086 * @throws NullPointerException 087 * if {@code getParent()} returns {@code null} 088 */ 089 void removeFromParent(); 090 091 /** 092 * Sets the parent of this node to {@code newParent}. This methods remove 093 * the node from its old parent. 094 * 095 * @param newParent 096 * the new parent for this node 097 */ 098 void setParent(MutableTreeTableNode newParent); 099}