org.bibalex.daf.commongui.datamodels
Class ComboBoxDataModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.bibalex.daf.handlers.dbhandler.DataTable
          extended by org.bibalex.daf.commongui.datamodels.ComboBoxDataModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel, javax.swing.table.TableModel

public class ComboBoxDataModel
extends DataTable
implements javax.swing.ComboBoxModel

This class is an implementation of the ComboBoxModel, that also supports (extends) DataTable. Used as a DataModel for the ComboBoxes that are filled through DataTables.

Author:
Fadi.Edward
See Also:
Serialized Form

Nested Class Summary
 class ComboBoxDataModel.ComboBoxObject
          This Class represents a ComboBox item.
 
Field Summary
protected  int colID
          The Column in the DataTable that represents the ID of the row.
protected  int colVisible
          The Column in the DataTable to be displayed in the ComboBox.
protected  int selectedItemIndex
          The selected Item index in the ComboBox.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ComboBoxDataModel(DataTable dataTable, int colID, int colVisible)
          Constructor
 
Method Summary
 void addListDataListener(javax.swing.event.ListDataListener l)
          Adds a ListDataListener.
 java.lang.Object getElementAt(int index)
          Retreives the ComboBoxObject at the given selected Index.
 int getIndexOf(int id)
          Retrives the Index of a given ID from within the List.
 int getSelectedID()
          Retreives the selected DB ID and not the selected Index.
 java.lang.Object getSelectedItem()
          Retreives the selected Item as a ComboBoxObject.
 int getSize()
          Returns the size of the combo box.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Removes a ListDataListener.
 void setSelectedID(int id)
          Sets the selected Item from the list based on the DB ID and not the list index.
 void setSelectedItem(java.lang.Object anItem)
          Sets a specific item as the selected one in the ComboBox.
 
Methods inherited from class org.bibalex.daf.handlers.dbhandler.DataTable
addRow, addRow, addRowAt, addRowAt, deleteRow, elementAt, elementAt, ExportToExcel, getColumnCount, getColumnName, getDynamicColumnIndices, getNameOfColumn, getNoOfColumns, getNoOfRows, getRow, getRowCount, getValueAt, setArchivingMatrix, setDynamicColumnIndices, setDynamicTable, setNameOfColumn, setNoOfColumn, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colID

protected int colID
The Column in the DataTable that represents the ID of the row.


colVisible

protected int colVisible
The Column in the DataTable to be displayed in the ComboBox.


selectedItemIndex

protected int selectedItemIndex
The selected Item index in the ComboBox.

Constructor Detail

ComboBoxDataModel

public ComboBoxDataModel(DataTable dataTable,
                         int colID,
                         int colVisible)
Constructor

Parameters:
dataTable - The DataTable to extract the values from.
colID - The Column in the DataTable that represents the ID of the row.
colVisible - The Column in the DataTable to be displayed in the ComboBox.
Method Detail

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Sets a specific item as the selected one in the ComboBox.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
anItem - The object to set as selected.

getSelectedItem

public java.lang.Object getSelectedItem()
Retreives the selected Item as a ComboBoxObject.

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
A the selected ComboBoxObject casted as Object.

getSize

public int getSize()
Returns the size of the combo box.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
The elements count in the combobox.

getElementAt

public java.lang.Object getElementAt(int index)
Retreives the ComboBoxObject at the given selected Index.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - The index to retrieve the element at.
Returns:
The ComboBoxObject at the given index casted to Object.

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Adds a ListDataListener. (not implemented)

Specified by:
addListDataListener in interface javax.swing.ListModel
Parameters:
l - The Implementation of the ListDataListener class to be added.

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Removes a ListDataListener. (not implemented)

Specified by:
removeListDataListener in interface javax.swing.ListModel
Parameters:
l - The Implementation of the ListDataListener class to be added.

getSelectedID

public int getSelectedID()
Retreives the selected DB ID and not the selected Index.

Returns:
The selected DB ID.

setSelectedID

public void setSelectedID(int id)
Sets the selected Item from the list based on the DB ID and not the list index.

Parameters:
id - The DB ID for which its item is selected.

getIndexOf

public int getIndexOf(int id)
Retrives the Index of a given ID from within the List.

Parameters:
id - The DB ID to fetch on.
Returns:
The index of the given ID, -1 if not found.