org.salespointframework.desktop.models
Class DataBasketTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.salespointframework.desktop.models.AbstractTableModel
          extended by org.salespointframework.desktop.models.DataBasketTableModel
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel, DataBasketListener, HelpableListener

public class DataBasketTableModel
extends AbstractTableModel
implements DataBasketListener, HelpableListener

A TableModel that models the contents of a DataBasket.

Since:
v2.0
Version:
2.0 23/08/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
protected  java.util.Comparator<DataBasketEntry> m_cmpComparator
          The Comparator that defines the sorting order of records in the model.
protected  DataBasket m_dbBasket
          The DataBasket being modelled.
protected  DataBasketCondition m_dbcCondition
          The condition specifying the items to be displayed.
protected  DataBasketEntryGrouper m_dbegGrouper
          A strategy that will group individual DataBasketEntries together for display.
protected  java.util.List<DataBasketEntry> m_lEntries
          The internal model.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DataBasketTableModel(DataBasket db, DataBasketCondition dbc, DataBasketEntryGrouper dbeg, java.util.Comparator<DataBasketEntry> cmp, TableEntryDescriptor ted)
          Create a new DataBasketTableModel.
 
Method Summary
 void addedDBE(DataBasketEvent e)
          Update the internal model and inform any listeners according to the received event.
 void dataBasketChanged(DataBasketEvent e)
          Update the internal model and inform any listeners according to the received event.
 java.lang.Object getRecord(int row)
          Get the record at the given index.
 int getRowCount()
          Get the number of records in this model.
 void removedDBE(DataBasketEvent e)
          Update the internal model and inform any listeners according to the received event.
 void setData(java.lang.Object n_dbBasket)
          set the table's data.
 void subscribe()
          Subscribe as a listener to the model.
 void unsubscribe()
          Un-Subscribe as a listener from the model.
 void updateModel()
          Update the internal model based on the modelled DataBasket.
 
Methods inherited from class org.salespointframework.desktop.models.AbstractTableModel
getColumnClass, getColumnCount, getColumnName, getEntryDescriptor, getValueAt, isCellEditable, orderByColumn, reOrderBy, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_dbBasket

protected DataBasket m_dbBasket
The DataBasket being modelled.


m_dbcCondition

protected DataBasketCondition m_dbcCondition
The condition specifying the items to be displayed.


m_dbegGrouper

protected DataBasketEntryGrouper m_dbegGrouper
A strategy that will group individual DataBasketEntries together for display. If null, no grouping will occur.


m_cmpComparator

protected java.util.Comparator<DataBasketEntry> m_cmpComparator
The Comparator that defines the sorting order of records in the model. It compares DataBasketEntries.


m_lEntries

protected java.util.List<DataBasketEntry> m_lEntries
The internal model. A list of the DataBasketEntries.

Constructor Detail

DataBasketTableModel

public DataBasketTableModel(DataBasket db,
                            DataBasketCondition dbc,
                            DataBasketEntryGrouper dbeg,
                            java.util.Comparator<DataBasketEntry> cmp,
                            TableEntryDescriptor ted)
Create a new DataBasketTableModel.

Parameters:
db - the DataBasket to be modeled.
dbc - a condition specifying the DataBasketEntries to be part of the model.
dbeg - a strategy that will group individual DataBasketEntries together for display. If null, no grouping will occur.
cmp - a Comparator defining the sort order of the records. If null, records are ordered according to the main key of the entries first and of the secondary key second.
ted - a TableEntryDescriptor that can split individual DataBasketEntries into a table's cells.
Method Detail

setData

public void setData(java.lang.Object n_dbBasket)
set the table's data. Data is data.DataBasket

Specified by:
setData in class AbstractTableModel
Parameters:
n_dbBasket - the new data

getRecord

public java.lang.Object getRecord(int row)
Get the record at the given index.

Specified by:
getRecord in class AbstractTableModel
Parameters:
row - the index for which to retrieve the record. Element of [0, getRowCount()).
Returns:
the DataBasketEntry to be displayed at the given index. May return null if there is no record at the indicated position.

getRowCount

public int getRowCount()
Get the number of records in this model.

Specified by:
getRowCount in interface javax.swing.table.TableModel

subscribe

public void subscribe()
Subscribe as a listener to the model. If the modelled DataBasket is a ListenableDataBasket, subscribe as a listener.

Specified by:
subscribe in interface HelpableListener

unsubscribe

public void unsubscribe()
Un-Subscribe as a listener from the model. If the modelled DataBasket is a ListenableDataBasket, un-subscribe as a listener.

Specified by:
unsubscribe in interface HelpableListener

updateModel

public void updateModel()
Update the internal model based on the modelled DataBasket.

Specified by:
updateModel in interface HelpableListener

addedDBE

public void addedDBE(DataBasketEvent e)
Update the internal model and inform any listeners according to the received event.

This method is public as an implementation detail and must not be called directly.

Specified by:
addedDBE in interface DataBasketListener
Parameters:
e - an event object that describes the event.

removedDBE

public void removedDBE(DataBasketEvent e)
Update the internal model and inform any listeners according to the received event.

This method is public as an implementation detail and must not be called directly.

Specified by:
removedDBE in interface DataBasketListener
Parameters:
e - an event object that describes the event.

dataBasketChanged

public void dataBasketChanged(DataBasketEvent e)
Update the internal model and inform any listeners according to the received event.

This method is public as an implementation detail and must not be called directly.

Specified by:
dataBasketChanged in interface DataBasketListener
Parameters:
e - an event object that describes the event. (e.getAffectedEntry() == null!)