com.bbn.swede.editor.visualeditors.restriction
Class ComboBoxCellEditorModel

java.lang.Object
  extended bycom.bbn.swede.editor.visualeditors.restriction.ComboBoxCellEditorModel

class ComboBoxCellEditorModel
extends Object

This class provides a model for Combo Box Cell editors so that generic objects can be represented conveniently. It uses a label provider to generate strings for a combo box cell editor. Usage is as follows:

Construct an instance of this class with a label provider. Call setElements(List) with a list of the objects you wish to represent in the list. Call getItems() to retrieve an array of strings suitable for ComboBoxCellEditor. Query the combo box cell editor for the selected index, and use either getElement(int) or getElement(Integer) to return the original model element associated with that selection.

Author:
aperezlo

Constructor Summary
ComboBoxCellEditorModel(ILabelProvider stringy)
          Constructs a model w/ the given ILabelProvider.
ComboBoxCellEditorModel(ILabelProvider stringy, List elements)
          Constructs a model w/ the given ILabelProvider and elements.
 
Method Summary
 Object getElement(int index)
          Retrieves the object associated with an index into the combo box.
 Object getElement(Integer index)
          Retrieves the object associated with an index into the combo box.
 Integer getIndex(Object element)
          This method returns, given an object, the index of that object in the array of strings returned by getItems() or an Integer representing -1 if the model object requested was not in the original List processed by setElements(List).
 int getIntIndex(Object element)
          This method returns, given an object, the index of that object in the array of strings returned by getItems() or an -1 if the model object requested was not in the original List processed by setElements(List).
 String[] getItems()
          After a call to setElements(List), this method will return an array of strings suitable as input to ComboBoxCellEditor#setItems(java.lang.String[]) .
 void setElements(List elements)
          The method sets the contents of this model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComboBoxCellEditorModel

public ComboBoxCellEditorModel(ILabelProvider stringy)
Constructs a model w/ the given ILabelProvider.

Parameters:
stringy - the ILabelProvider to use to create the text representations for the combo box cell editor

ComboBoxCellEditorModel

public ComboBoxCellEditorModel(ILabelProvider stringy,
                               List elements)
Constructs a model w/ the given ILabelProvider and elements.

Parameters:
stringy - the ILabelProvider to use to create the text representations for the combo box cell editor
elements - the elements that constitute this model
Method Detail

setElements

public void setElements(List elements)
The method sets the contents of this model. After a call to this method (or object construction with ComboBoxCellEditorModel(ILabelProvider, List)), a call to the other methods in this class will result in the proper responses.

Parameters:
elements - a List of the objects to be maintained by this model

getItems

public String[] getItems()
After a call to setElements(List), this method will return an array of strings suitable as input to ComboBoxCellEditor#setItems(java.lang.String[]) .

Returns:
an array of string representations of this model's objects

getElement

public Object getElement(Integer index)
Retrieves the object associated with an index into the combo box.

Parameters:
index - an index from the array of strings returned by getItems()
Returns:
the object associated with that index

getElement

public Object getElement(int index)
Retrieves the object associated with an index into the combo box.

Parameters:
index - an index from the array of strings returned by getItems()
Returns:
the object associated with that index

getIndex

public Integer getIndex(Object element)
This method returns, given an object, the index of that object in the array of strings returned by getItems() or an Integer representing -1 if the model object requested was not in the original List processed by setElements(List).

Parameters:
element - a model object
Returns:
the index of that object in the array of strings

getIntIndex

public int getIntIndex(Object element)
This method returns, given an object, the index of that object in the array of strings returned by getItems() or an -1 if the model object requested was not in the original List processed by setElements(List).

Parameters:
element - a model object
Returns:
the index of that object in the array of strings


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.