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: KListModel.java,v $
023   Revision 1.2  2004/05/31 07:30:26  markl
024   Final cleanup and bugfixes of kiwi.ui.model.
025
026   Revision 1.1  2004/05/13 21:40:21  markl
027   new classes
028   ----------------------------------------------------------------------------
029*/
030
031package kiwi.ui.model;
032
033import java.util.Iterator;
034import javax.swing.Icon;
035
036import kiwi.event.*;
037
038/** This interface defines the behavior for a data model for list data
039 * structures.
040 *
041 * @since Kiwi 2.0
042 *
043 * @author Mark Lindner
044 */
045
046public interface KListModel extends ModelProperties
047  {
048  /** Determine if the model is empty.
049   *
050   * @return <code>true</code> if the model is empty, and <code>false</code>
051   * otherwise.
052   */
053  
054  public boolean isEmpty();
055
056  /** Remove all items from the model.
057   */
058  
059  public void clear();
060
061  /** Get the number of items in the model.
062   *
063   * @return The number of items.
064   */
065  
066  public int getItemCount();
067
068  /** Return an <code>Enumeration</code> of the items in the model.
069   *
070   * @return An <code>Enumeration</code> of the items.
071   */
072
073  public Iterator getItems();
074
075  /** Get the item at the specified index in the model.
076   *
077   * @param index The index.
078   * @return The item at the specified index.
079   */
080
081  public Object getItemAt(int index);
082
083  /** Get the index of the specified item in the model.
084   *
085   * @param item The item.
086   * @return The index of the item, or <code>-1</code> if the item is not in
087   * the model.
088   */
089  
090  public int indexOf(Object item);
091
092  /** Add an item to the model. The item is added as the last item in the
093   * model.
094   *
095   * @param item The new item.
096   */
097    
098  public void addItem(Object item);
099
100  /** Insert an item at the specified index in the model.
101   *
102   * @param item The new item.
103   * @param index The index.
104   */
105  
106  public void insertItemAt(Object item, int index);
107
108  /** Remove the item at the specified index from the model.
109   *
110   * @param index The index.
111   */
112  
113  public void removeItemAt(int index);
114
115  /** Remove the specified item from the model.
116   *
117   * @param item The item.
118   */
119  
120  public void removeItem(Object item);
121
122  /** Indicate to listeners that the specified item has changed.
123   *
124   * @param item The item.
125   */
126
127  public void updateItem(Object item);
128
129  /** Indicate to listeners that the item at the specified index has changed.
130   *
131   * @param index The index.
132   */
133
134  public void updateItemAt(int index);
135
136  /** Add a <code>ListModelListener</code> to this model's list of listeners.
137   *
138   * @param listener The listener to add.
139   */
140
141  public void addListModelListener(KListModelListener listener);
142
143  /** Remove a <code>KListModelListener</code> from this model's list of
144   * listeners.
145   *
146   * @param listener The listener to remove.
147   */
148  
149  public void removeListModelListener(KListModelListener listener);
150
151  /** Get the label for an item.
152   *
153   * @param item The item.
154   * @return A string label for the item.
155   */
156  
157  public String getLabel(Object item);
158
159  /** Get the icon for an item.
160   *
161   * @param item The item.
162   * @return An icon for the item.
163   */
164  
165  public Icon getIcon(Object item);
166
167  /** Get the value of an arbitrary property for a given item.
168    *
169    * @param item The item.
170    * @param property The name of the property.
171    * @return The value of the specified property, or <code>null</code> if
172    * there is no value for this property.
173    */
174
175  public Object getValueForProperty(Object item, String property);
176  }
177
178/* end of source file */