org.bibalex.daf.commongui.datamodels
Class UIListModel

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

public class UIListModel
extends DataTable
implements javax.swing.ListModel

A Data Model Class used with JLists, it also extends DataTable. It acts as a transformation layer to display DataTable values into a JList. We do not recommend using this class with editable data (add or remove entries dynamically) as this functionality was not tested properly. For such purposes use the UIListEditableModel instead.

Author:
Fadi.Edward
See Also:
Serialized Form

Field Summary
protected  int colID
          The index of the Column in the DataTable considered as ID.
protected  int colVisisble
          The index of the Column in the DataTable to be displayed in the List.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
UIListModel(DataTable dataTable, int colID, int colVisible)
          Constructor (1).
UIListModel(int colID, int colVisible)
          Constructor (2).
 
Method Summary
 void addElement(int elementID, java.lang.String elementValue)
          Adds an element to the list.
 void addListDataListener(javax.swing.event.ListDataListener l)
          (not implemented)
 java.lang.Object getElementAt(int index)
          Retreives the element at the specified index.
 int getIDAt(int index)
          Retreives the ID of the element at the given index.
 int getSize()
          Retrieves the List items count.
 void removeElementAt(int index)
          Removes an element from the list.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          (not implemented)
 
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 index of the Column in the DataTable considered as ID.


colVisisble

protected int colVisisble
The index of the Column in the DataTable to be displayed in the List.

Constructor Detail

UIListModel

public UIListModel(DataTable dataTable,
                   int colID,
                   int colVisible)
Constructor (1). Construct the model from a DataTable.

Parameters:
dataTable - The DataTable to extract the data from.
colID - The index of the column indicating the ID in the DataTable.
colVisible - The index of the column to be displayed on the list from the DataTable.

UIListModel

public UIListModel(int colID,
                   int colVisible)
Constructor (2). No DataTable is used, for constructing using a DataTable please refer to Constructor (1).

Parameters:
colID - The index of the column indicating the ID in the DataTable.
colVisible - The index of the column to be displayed on the list from the DataTable.
Method Detail

getSize

public int getSize()
Retrieves the List items count.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
The list items count.

getElementAt

public java.lang.Object getElementAt(int index)
Retreives the element at the specified index.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - The index of the Element to retreive.
Returns:
An Object containing the element (PS: The value displayed is the toString call of the Object retruned).

addListDataListener

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

Specified by:
addListDataListener in interface javax.swing.ListModel
Parameters:
l -

removeListDataListener

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

Specified by:
removeListDataListener in interface javax.swing.ListModel
Parameters:
l -

getIDAt

public int getIDAt(int index)
Retreives the ID of the element at the given index.

Parameters:
index - The index to get the ID for.
Returns:
The ID.

removeElementAt

public void removeElementAt(int index)
Removes an element from the list. (not tested)

Parameters:
index - The index of the element in the list.

addElement

public void addElement(int elementID,
                       java.lang.String elementValue)
Adds an element to the list. (not tested)

Parameters:
elementID - The ID of the added element.
elementValue - The displayed value of the added element.