com.sapportals.htmlb

Class DefaultListModel

java.lang.Object
  extended bycom.sapportals.htmlb.DefaultListModel
All Implemented Interfaces:
IListModel, Serializable

public class DefaultListModel
extends Object
implements IListModel, Serializable

Default implementation of IListModel for ListBox and DropdownListBox

Copyright 2004 SAP AG

See Also:
Serialized Form

Constructor Summary
DefaultListModel()
          Create a new DefaultListModel.
 
Method Summary
 void addItem(int index, String key, String text)
          adds an item to the list of choices.
 void addItem(String key, String text)
          adds an item to the list of choices.
 void addSelection(String key)
          adds the item with the given key to the selection.
 String getKeyByIndex(int index)
          gets the key of an item for a specified index.
 Iterator getKeys()
          gets an Iterator for all keys currently in the list
 String[] getMultiSelection()
          gets the keys of the currently selected items if the model is a multi selection model.
 String getNameOfKeyColumn()
          gets the name of the column containing the key values if the list model is associated with a table.
 String getNameOfTextColumn()
          gets the name of the column containing the visible texts if the list model is associated with a table.
 String getSingleSelection()
          gets the key of the currently selected item if the model is a single selection model.
 String getTextByIndex(int index)
          gets the visible text of an item for a specified index.
 String getTextForKey(String key)
          gets the text associated with the key
 boolean isSelected(int index)
          determines if the item at the given index is currently selected.
 boolean isSelected(String key)
          determines if the item with the given key is currently selected.
 boolean isSingleSelection()
          determines if the model is a single selection model, i.e. allows only a single item to be selected at any given time.
 void removeItem(String key)
          removes an item to the list of choices.
 void removeSelection(String key)
          adds the item with the given key to the selection.
 void setNameOfKeyColumn(String nameOfKeyColumn)
          sets the name of the column containing the key values if the list model is associated with a table.
 void setNameOfTextColumn(String nameOfValueColumn)
          sets the name of the column containing the visible texts if the list model is associated with a table.
 void setSelection(String key)
          sets the current selection to the item with the given key.
 void setSingleSelection(boolean isSingleSelection)
          sets the selection behaviour for the list model
 int size()
          gets the size of the list, i.e. the number of items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultListModel

public DefaultListModel()
Create a new DefaultListModel. This model is automatically created by ListBox and DropdownListBox if you add an item to the list without setting a specific model first.

Method Detail

addItem

public void addItem(String key,
                    String text)
adds an item to the list of choices. If a Item with the spesified was already added to the model, the old key and text is removed and the new key and text is added.

Specified by:
addItem in interface IListModel
Parameters:
key - the key of the item
text - the visible text of the item

addItem

public void addItem(int index,
                    String key,
                    String text)
adds an item to the list of choices.

Parameters:
index - the index of the item
key - the key of the item
text - the visible text of the item

size

public int size()
gets the size of the list, i.e. the number of items.

Specified by:
size in interface IListModel
Returns:
the current size of the list

getKeyByIndex

public String getKeyByIndex(int index)
gets the key of an item for a specified index.

Specified by:
getKeyByIndex in interface IListModel
Parameters:
index - the index of the item in the list
Returns:
the key for that index
Throws:
IndexOutOfBoundsException

getTextByIndex

public String getTextByIndex(int index)
gets the visible text of an item for a specified index.

Specified by:
getTextByIndex in interface IListModel
Parameters:
index - the index of the item in the list
Returns:
the text for that index
Throws:
IndexOutOfBoundsException

getKeys

public Iterator getKeys()
gets an Iterator for all keys currently in the list

Specified by:
getKeys in interface IListModel
Returns:
an Iterator for the keys

getTextForKey

public String getTextForKey(String key)
gets the text associated with the key

Specified by:
getTextForKey in interface IListModel
Parameters:
key - the key of an item
Returns:
the text of that item

isSelected

public boolean isSelected(int index)
determines if the item at the given index is currently selected. Checking for the selection via the index is not supported for reconstructed Lists. Use isSelected(String key) instead.

Specified by:
isSelected in interface IListModel
Parameters:
index - the index of the item
Returns:
true if that item is currently selected
See Also:
isSelected(String)

isSelected

public boolean isSelected(String key)
determines if the item with the given key is currently selected.

Specified by:
isSelected in interface IListModel
Parameters:
key - the key of the item
Returns:
true if that item is currently selected

getNameOfKeyColumn

public String getNameOfKeyColumn()
gets the name of the column containing the key values if the list model is associated with a table.

Specified by:
getNameOfKeyColumn in interface IListModel
Returns:
the column identifier of the key column

setNameOfKeyColumn

public void setNameOfKeyColumn(String nameOfKeyColumn)
sets the name of the column containing the key values if the list model is associated with a table.

Specified by:
setNameOfKeyColumn in interface IListModel
Parameters:
nameOfKeyColumn - the column identifier of the key column

getNameOfTextColumn

public String getNameOfTextColumn()
gets the name of the column containing the visible texts if the list model is associated with a table.

Specified by:
getNameOfTextColumn in interface IListModel
Returns:
the column identifier of the text column

setNameOfTextColumn

public void setNameOfTextColumn(String nameOfValueColumn)
sets the name of the column containing the visible texts if the list model is associated with a table.

Specified by:
setNameOfTextColumn in interface IListModel
Parameters:
nameOfValueColumn - the column identifier of the text column

setSelection

public void setSelection(String key)
sets the current selection to the item with the given key.

Specified by:
setSelection in interface IListModel
Parameters:
key - the key of the item to select

isSingleSelection

public boolean isSingleSelection()
determines if the model is a single selection model, i.e. allows only a single item to be selected at any given time.

Specified by:
isSingleSelection in interface IListModel
Returns:
true if the model only allows single selection

setSingleSelection

public void setSingleSelection(boolean isSingleSelection)
Description copied from interface: IListModel
sets the selection behaviour for the list model

Specified by:
setSingleSelection in interface IListModel
Parameters:
isSingleSelection - true if the model should only allow single selection.

getSingleSelection

public String getSingleSelection()
gets the key of the currently selected item if the model is a single selection model.

Specified by:
getSingleSelection in interface IListModel
Returns:
the key of the selected item

getMultiSelection

public String[] getMultiSelection()
gets the keys of the currently selected items if the model is a multi selection model.

Specified by:
getMultiSelection in interface IListModel
Returns:
the keys of the selected item

addSelection

public void addSelection(String key)
adds the item with the given key to the selection. This should only work in single selection mode.

Specified by:
addSelection in interface IListModel
Parameters:
key - the key of the item to add to the selection

removeSelection

public void removeSelection(String key)
adds the item with the given key to the selection. This should only work in single selection mode.

Specified by:
removeSelection in interface IListModel
Parameters:
key - the key of the item to remove from the selection

removeItem

public void removeItem(String key)
removes an item to the list of choices.

Parameters:
key - the key of the item to remove


Copyright 2006 SAP AG Complete Copyright Notice