Diamond Control Suite 3.0

diamondedge.swing
Class DsListItem

java.lang.Object
  extended by diamondedge.swing.DsListItem
Direct Known Subclasses:
DsListViewItem

public class DsListItem
extends Object

An item in a DsListView or DsComboBox control that contains the index of icons associated with it, text, and an array of strings (cells) representing subitems that are displayed in the list.


Field Summary
protected  int lastItemAdded
           
protected  Object smallIcon
           
protected  Vector values
           
 
Method Summary
 DsListCell addCell(int index, String key, String text)
          Adds a DsListCell object to the collection of DsListCells.
protected  DsListCell createListCell()
          Creates a new DsListCell.
 DsListCell getCell(int index)
          Returns a DsListCell representing the ListItem's data.
 DsListCell getCell(String key)
          Returns a DsListCell that has the specified key if it exists.
 Object getCellValue(int index)
          Returns an Object whose string representation will be displayed at the specified column.
 Object getData()
          Returns the object associated with the item.
 Color getForeground()
          Returns a value which determines the color of the label.
 String getKey()
          Returns the unique string by which this item can be located.
 Object getSmallIcon()
          Returns the icon or the index/key of the icon that is displayed in the list.
 Icon getSmallIcon(IconList iconList)
          Returns the icon that is displayed in the list.
 String getText()
          Returns the text displayed in the list for this item.
 Object getValue()
          Returns the value displayed in the list for this item.
 int indexOf(DsListCell cell)
          Returns the index of a DsListCell with in this DsListItem.
 int indexOf(String key)
          Returns the index of a DsListCell by its key.
 boolean isFontBold()
          Returns a value that determines whether the label for the item is displayed with a bold font.
 void loadData()
          Load data from the object stored in setData() into each cell.
 void removeCell(int index)
          Removes a DsListCell object from the collection of DsListCells.
 void setCellValue(int index, Object text)
          Sets the Object whose string representation will be displayed at the specified column.
 void setData(Object val)
          Sets an object to be stored with the item.
 void setFontBold(boolean bold)
          Sets a value that determines whether the label for the item is displayed with a bold font.
 void setForeground(Color c)
          Sets a value which determines the color of the label.
 void setKey(String key)
          Sets the unique string by which this item can be located.
 void setSmallIcon(Object indexOrKeyOrIcon)
          Sets the index (Integer) or key (String) of an icon that is displayed in the list.
 void setText(String text)
          Sets the text displayed in the list for this item.
 void setValue(Object val)
          Sets the value displayed in the list for this item.
 String toString()
          Returns the label for the item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

smallIcon

protected Object smallIcon

lastItemAdded

protected int lastItemAdded

values

protected Vector values
Method Detail

loadData

public void loadData()
Load data from the object stored in setData() into each cell. If the object is an instanceof DsListObject then all columns and icons are populated. Otherwise just the first cell (label) is set.


getSmallIcon

public Icon getSmallIcon(IconList iconList)
Returns the icon that is displayed in the list.

Parameters:
iconList - List of icons used if the stored value was actually a String or Integer which represents the index into the icon list

getSmallIcon

public Object getSmallIcon()
Returns the icon or the index/key of the icon that is displayed in the list.


setSmallIcon

public void setSmallIcon(Object indexOrKeyOrIcon)
Sets the index (Integer) or key (String) of an icon that is displayed in the list. Can also be an Icon or Image.


getText

public String getText()
Returns the text displayed in the list for this item. This is the same string as the one in the 0th column of the list.


setText

public void setText(String text)
Sets the text displayed in the list for this item. This is the same string as the one in the 0th column of the list. This is a convenience method that calls setValue(text).


getValue

public Object getValue()
Returns the value displayed in the list for this item. This is the same string as the one in the 0th column of the list.


setValue

public void setValue(Object val)
Sets the value displayed in the list for this item. This is the same string as the one in the 0th column of the list.


getKey

public String getKey()
Returns the unique string by which this item can be located.


setKey

public void setKey(String key)
Sets the unique string by which this item can be located.


isFontBold

public boolean isFontBold()
Returns a value that determines whether the label for the item is displayed with a bold font.


setFontBold

public void setFontBold(boolean bold)
Sets a value that determines whether the label for the item is displayed with a bold font.


getForeground

public Color getForeground()
Returns a value which determines the color of the label.


setForeground

public void setForeground(Color c)
Sets a value which determines the color of the label.


getData

public Object getData()
Returns the object associated with the item. Initially is set to null or the object that was used to load the ListItem.


setData

public void setData(Object val)
Sets an object to be stored with the item. This can be any type of object. The value is never used internally.


toString

public String toString()
Returns the label for the item

Overrides:
toString in class Object

getCellValue

public Object getCellValue(int index)
Returns an Object whose string representation will be displayed at the specified column.


setCellValue

public void setCellValue(int index,
                         Object text)
Sets the Object whose string representation will be displayed at the specified column.

This is the preferred way of setting values. Using getCell(index).setValue(text) forces the creation of a cell object and also does not cause list to be re-sorted.


getCell

public DsListCell getCell(int index)
Returns a DsListCell representing the ListItem's data. This creates a DsListCell if not already created that can be used to set the formatting and user data.


getCell

public DsListCell getCell(String key)
Returns a DsListCell that has the specified key if it exists. This creates a DsListCell if not already created that can be used to set the formatting and user data.


createListCell

protected DsListCell createListCell()
Creates a new DsListCell. Subclasses can override this to return an instance of a subclass of DsListCell


indexOf

public int indexOf(DsListCell cell)
Returns the index of a DsListCell with in this DsListItem.


indexOf

public int indexOf(String key)
Returns the index of a DsListCell by its key.

Parameters:
key - unique
Returns:
index of cell that has a Key equal to the specified key. Otherwise, it returns -1.

addCell

public DsListCell addCell(int index,
                          String key,
                          String text)
Adds a DsListCell object to the collection of DsListCells.

Parameters:
index - position to insert new cell. -1 means append to end.

removeCell

public void removeCell(int index)
Removes a DsListCell object from the collection of DsListCells.


Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.