gov.virginia.dcjs.gui.field
Class ComboBoxFieldModel

java.lang.Object
  extended byjavax.swing.AbstractListModel
      extended bygov.virginia.dcjs.gui.field.ComboBoxFieldModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.MutableComboBoxModel, java.io.Serializable

public class ComboBoxFieldModel
extends javax.swing.AbstractListModel
implements javax.swing.MutableComboBoxModel

This mutable data model accepts a Relation and allows a key * field to be specified by the user. This key field is stored in * the database and may optionally be hidden from the user's view. * Other fields in the Relation are displayed.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
ComboBoxFieldModel()
           
ComboBoxFieldModel(Relation r)
          Populate the list with all fields from the given Relation * .
ComboBoxFieldModel(Relation r, int key, boolean showKey)
          Populate the list with all fields from the given Relation * .
 
Method Summary
 void addElement(java.lang.Object record)
          Add the specified Record element to the end of the * list.
 java.lang.Object getElementAt(int index)
          Obtain the entire data row as a delimited string * @param index Row to obtain the data for
protected  java.lang.String getListItem(long row)
           
 java.lang.Object getSelectedItem()
          Obtain the list value for the currently selected list item
 java.lang.String getSelectedKey()
          Obtain the key value for the currently selected list item
 int getSize()
          Obtain the number of items being managed in this list
 void insertElementAt(java.lang.Object record, int index)
          Add the specified Record element at the specified list index.
 void removeElement(java.lang.Object key)
          Remove the specified String element from the list.
 void removeElementAt(int index)
          Remove the specified String element from the list.
 void setSelectedItem(java.lang.Object item)
          Move the selection to the item with the specified list value.
 void setSelectedKey(java.lang.String key)
          Move the selection to the item with the specified key value.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

ComboBoxFieldModel

public ComboBoxFieldModel()

ComboBoxFieldModel

public ComboBoxFieldModel(Relation r)
Populate the list with all fields from the given Relation * . The first field will serve as the key and will be * hidden from the user. * @param r Data contents for list items


ComboBoxFieldModel

public ComboBoxFieldModel(Relation r,
                          int key,
                          boolean showKey)
Populate the list with all fields from the given Relation * . The specified field index will serve as the key. * If the showKey parameter is false, the key will also * be hidden from the user. * @param r Data contents for list items * @param key Field index of database key for each list item * @param showKey True when the key field value is to be visible to * the user, false to hide the key field.

Method Detail

getSelectedItem

public java.lang.Object getSelectedItem()
Obtain the list value for the currently selected list item

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel

setSelectedItem

public void setSelectedItem(java.lang.Object item)
Move the selection to the item with the specified list value. * @param item A String having the list * value to move to.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel

addElement

public void addElement(java.lang.Object record)
Add the specified Record element to the end of the * list. * @param record Two column (minimum) record containing the key value in the * previously specified key column and the list description in the others.

Specified by:
addElement in interface javax.swing.MutableComboBoxModel

insertElementAt

public void insertElementAt(java.lang.Object record,
                            int index)
Add the specified Record element at the specified list index. * Presently, this functionality is not implemented, but the element is simply * added to the end of the list. * @param record Two column record containing the key value in the * first column and the list description in the second. * @param index List location for the specified element.

Specified by:
insertElementAt in interface javax.swing.MutableComboBoxModel

removeElement

public void removeElement(java.lang.Object key)
Remove the specified String element from the list. * An invalid key value has no impact upon the list. * @param key Unique identifier to locate the element by.

Specified by:
removeElement in interface javax.swing.MutableComboBoxModel

removeElementAt

public void removeElementAt(int index)
Remove the specified String element from the list. * An invalid index has no impact upon the list. * @param index Zero based location of list element.

Specified by:
removeElementAt in interface javax.swing.MutableComboBoxModel

getSelectedKey

public java.lang.String getSelectedKey()
Obtain the key value for the currently selected list item


setSelectedKey

public void setSelectedKey(java.lang.String key)
Move the selection to the item with the specified key value. * @param key Item having this key value to move to


getElementAt

public java.lang.Object getElementAt(int index)
Obtain the entire data row as a delimited string * @param index Row to obtain the data for

Specified by:
getElementAt in interface javax.swing.ListModel

getListItem

protected java.lang.String getListItem(long row)

getSize

public int getSize()
Obtain the number of items being managed in this list

Specified by:
getSize in interface javax.swing.ListModel