SalesPoint Framework v3.1

data.swing
Class CountingStockTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byutil.swing.AbstractTableModel
          extended bydata.swing.CountingStockTableModel
All Implemented Interfaces:
CatalogChangeListener, EventListener, HelpableListener, PropertyChangeListener, Serializable, StockChangeListener, TableModel

public class CountingStockTableModel
extends AbstractTableModel
implements HelpableListener, StockChangeListener, CatalogChangeListener, PropertyChangeListener, Serializable

A TableModel that models the contents of a CountingStock.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
Serialized Form

Nested Class Summary
static class CountingStockTableModel.Record
          A CountingStockTableModel's record.
 
Field Summary
protected  Comparator m_cmpComparator
          The Comparator that defines the sorting order of records in the model.
protected  CountingStock m_csModel
          The CountingStock being modelled.
protected  DataBasket m_dbBasket
          The DataBasket used to determine visibility.
protected  boolean m_fShowZeros
          If true, show lines informing about a zero amount of objects.
protected  List m_lKeys
          The internal model.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CountingStockTableModel(CountingStock cs, DataBasket db, Comparator cmp, boolean fShowZeros, TableEntryDescriptor ted)
          Create a new CountingStockTableModel.
 
Method Summary
 void addedCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void addedStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void canEditCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void canEditStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void canRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void canRemoveStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
protected  void checkAdd(String sKey)
          Internal helper method.
protected  void checkRemove(String sKey)
          Internal helper method.
protected  void checkUpdate(String sKey)
          Internal helper method.
 void commitAddStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void commitedAddCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void commitEditCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void commitEditStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void commitedRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void commitRemoveStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void editingCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void editingStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 Object getRecord(int row)
          Get the record at the given index.
 int getRowCount()
          Get the number of records in this model.
 void noEditCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void noEditStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void noRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void noRemoveStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void propertyChange(PropertyChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void removedCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void removedStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rollbackAddStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rollbackEditCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rollbackEditStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rollbackRemoveStockItems(StockChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rolledbackAddCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void rolledbackRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void setData(Object n_csModel)
          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 CountingStock.
 
Methods inherited from class util.swing.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 used to determine visibility.


m_csModel

protected CountingStock m_csModel
The CountingStock being modelled. May be filtered.


m_cmpComparator

protected Comparator m_cmpComparator
The Comparator that defines the sorting order of records in the model. It compares the keys of the actual items.


m_fShowZeros

protected boolean m_fShowZeros
If true, show lines informing about a zero amount of objects.


m_lKeys

protected List m_lKeys
The internal model. A list of the items' keys.

Constructor Detail

CountingStockTableModel

public CountingStockTableModel(CountingStock cs,
                               DataBasket db,
                               Comparator cmp,
                               boolean fShowZeros,
                               TableEntryDescriptor ted)
Create a new CountingStockTableModel.

Parameters:
cs - the Stock to be modelled.
db - the DataBasket to be used to determine visibility.
cmp - the Comparator defining the sorting order. If null the records will be sorted according to the natural ordering of their keys.
fShowZeros - if true, lines informing about a zero amount of objects will be shown.
ted - a TableEntryDescriptor that can split a CountingStockTableModel.Record into a table's cells.
Method Detail

setData

public void setData(Object n_csModel)
set the table's data. Data is CountingStock

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

getRecord

public 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 CountingStockTableModel.Record to be displayed at the given index. May return null if either there is no record at the indicated position or an exception occurs.
Override:
Never

getRowCount

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

Specified by:
getRowCount in interface TableModel
Override:
Never

subscribe

public void subscribe()
Subscribe as a listener to the model. If the modelled Catalog is a ListenableCatalog, subscribe as a listener. If the modelled CountingStock is a ListenableStock, subscribe as a listener.

Specified by:
subscribe in interface HelpableListener
Override:
Never

unsubscribe

public void unsubscribe()
Un-Subscribe as a listener from the model. If the modelled Catalog is a ListenableCatalog, un-subscribe as a listener. If the modelled CountingStock is a ListenableStock, un-subscribe as a listener.

Specified by:
unsubscribe in interface HelpableListener
Override:
Never

updateModel

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

Specified by:
updateModel in interface HelpableListener
Override:
Never

addedStockItems

public void addedStockItems(StockChangeEvent 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:
addedStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitAddStockItems

public void commitAddStockItems(StockChangeEvent 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:
commitAddStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rollbackAddStockItems

public void rollbackAddStockItems(StockChangeEvent 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:
rollbackAddStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canRemoveStockItems

public void canRemoveStockItems(StockChangeEvent e)
                         throws VetoException
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:
canRemoveStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the removal.
Override:
Never

noRemoveStockItems

public void noRemoveStockItems(StockChangeEvent 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:
noRemoveStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

removedStockItems

public void removedStockItems(StockChangeEvent 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:
removedStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitRemoveStockItems

public void commitRemoveStockItems(StockChangeEvent 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:
commitRemoveStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rollbackRemoveStockItems

public void rollbackRemoveStockItems(StockChangeEvent 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:
rollbackRemoveStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canEditStockItems

public void canEditStockItems(StockChangeEvent e)
                       throws VetoException
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:
canEditStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the editing.
Override:
Never

noEditStockItems

public void noEditStockItems(StockChangeEvent 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:
noEditStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

editingStockItems

public void editingStockItems(StockChangeEvent 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:
editingStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitEditStockItems

public void commitEditStockItems(StockChangeEvent 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:
commitEditStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rollbackEditStockItems

public void rollbackEditStockItems(StockChangeEvent 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:
rollbackEditStockItems in interface StockChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

addedCatalogItem

public void addedCatalogItem(CatalogChangeEvent 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:
addedCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitedAddCatalogItem

public void commitedAddCatalogItem(CatalogChangeEvent 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:
commitedAddCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rolledbackAddCatalogItem

public void rolledbackAddCatalogItem(CatalogChangeEvent 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:
rolledbackAddCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canRemoveCatalogItem

public void canRemoveCatalogItem(CatalogChangeEvent e)
                          throws VetoException
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:
canRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the removal.
Override:
Never

noRemoveCatalogItem

public void noRemoveCatalogItem(CatalogChangeEvent 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:
noRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

removedCatalogItem

public void removedCatalogItem(CatalogChangeEvent 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:
removedCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitedRemoveCatalogItem

public void commitedRemoveCatalogItem(CatalogChangeEvent 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:
commitedRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rolledbackRemoveCatalogItem

public void rolledbackRemoveCatalogItem(CatalogChangeEvent 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:
rolledbackRemoveCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

canEditCatalogItem

public void canEditCatalogItem(CatalogChangeEvent e)
                        throws VetoException
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:
canEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Throws:
VetoException - if the listener wants to veto the editing.
Override:
Never

noEditCatalogItem

public void noEditCatalogItem(CatalogChangeEvent 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:
noEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

editingCatalogItem

public void editingCatalogItem(CatalogChangeEvent 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:
editingCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

commitEditCatalogItem

public void commitEditCatalogItem(CatalogChangeEvent 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:
commitEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

rollbackEditCatalogItem

public void rollbackEditCatalogItem(CatalogChangeEvent 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:
rollbackEditCatalogItem in interface CatalogChangeListener
Parameters:
e - an event object describing the event.
Override:
Never

propertyChange

public void propertyChange(PropertyChangeEvent 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:
propertyChange in interface PropertyChangeListener
Override:
Never

checkAdd

protected void checkAdd(String sKey)
Internal helper method. Check where, if at all, the given CatalogItem has been added with respect to the internal model.

Override:
Never

checkRemove

protected void checkRemove(String sKey)
Internal helper method. Check from where, if at all, the given CatalogItem has been removed with respect to the internal model.

Override:
Never

checkUpdate

protected void checkUpdate(String sKey)
Internal helper method. Check for updates in the given CatalogItem.

Override:
Never

SalesPoint Framework v3.1