001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: TreeDataSource.java,v $ 023 Revision 1.1 2004/05/31 07:30:26 markl 024 Final cleanup and bugfixes of kiwi.ui.model. 025 026 ---------------------------------------------------------------------------- 027*/ 028 029package kiwi.ui.model; 030 031import javax.swing.Icon; 032 033/** This interface defines a data source for populating tree data structures. 034 * 035 * @author Mark Lindner 036 * @since Kiwi 2.0 037 */ 038 039public interface TreeDataSource extends ModelProperties 040 { 041 /** Get the root object. */ 042 043 public Object getRoot(); 044 045 /** Get the children of a given node in the tree. 046 * 047 * @param node The node that children are being requested for. 048 * @return A (possibly empty) array of children for the node. 049 */ 050 051 public Object[] getChildren(Object node); 052 053 /** Get the value of an arbitrary property for a given node. 054 * 055 * @param node The node. 056 * @param property The name of the property; one of the constants defined 057 * above, or some arbitrary application-defined property. 058 * @return The value of the specified property, or <code>null</code> if 059 * there is no value for this property. 060 */ 061 062 public Object getValueForProperty(Object node, String property); 063 064 /** Determine if this node is expandable. 065 * 066 * @param node The node. 067 * @return <b>true</b> if the node is expandable, <b>false</b> otherwise. 068 */ 069 070 public boolean isExpandable(Object node); 071 072 /** Get the icon for a node. 073 * 074 * @param node The node. 075 * @param expanded The current expanded state of the node. 076 * @return An icon for the item. 077 */ 078 079 public Icon getIcon(Object node, boolean expanded); 080 081 /** Get the label for a node. 082 * 083 * @param node The node. 084 * @return A string label for the node. 085 */ 086 087 public String getLabel(Object node); 088 089 } 090 091/* end of source file */