org.salespointframework.desktop.models
Class CatalogTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.salespointframework.desktop.models.AbstractTableModel
          extended by org.salespointframework.desktop.models.CatalogTableModel
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel, CatalogChangeListener, DatasourceChangeListener, HelpableListener, FilterableModel

public class CatalogTableModel
extends AbstractTableModel
implements HelpableListener, CatalogChangeListener, java.beans.PropertyChangeListener, FilterableModel

A TableModel that models the contents of a Catalog.

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.salespointframework.desktop.models.FilterableModel
FilterableModel.DefaultModelFilter, FilterableModel.ModelFilter, FilterableModel.ResultCountListener
 
Field Summary
protected  Catalog<?> m_cModel
          The Catalog that is being modelled.
protected  java.util.Comparator<CatalogItem> m_cmpComparator
          The Comparator that defines the sorting order of records in the model.
protected  DataBasket m_dbBasket
          The DataBasket used to determine visibility.
protected  java.util.List<java.lang.String> m_lKeys
          The internal model.
protected  FilterableModel.ModelFilter modelFilter
          applied model filter
protected  java.util.List<FilterableModel.ResultCountListener> resultCountListeners
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CatalogTableModel(Catalog c, DataBasket db, java.util.Comparator<CatalogItem> cmp, TableEntryDescriptor ted)
          Create a new CatalogTableModel.
 
Method Summary
 void addedCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 boolean addResultCountListener(FilterableModel.ResultCountListener rcs)
          add new FilterableModel.ResultCountListener
 void canEditCatalogItem(CatalogChangeEvent 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.
protected  void checkAdd(CatalogItem ci)
          Internal helper method.
protected  void checkRemove(CatalogItem ci)
          Internal helper method.
protected  void checkUpdate(CatalogItem ci)
          Internal helper method.
 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 commitedRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void DatasourceChanged(boolean pumpUp)
          Indicates a change of Datasource.
 void editingCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void filterPropertyChanged()
          property of model filter changed
 java.util.Comparator<CatalogItem> getComparator()
           
 java.lang.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 noRemoveCatalogItem(CatalogChangeEvent e)
          Update the internal model and inform any listeners according to the received event.
 void propertyChange(java.beans.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 removeResultCountListener(FilterableModel.ResultCountListener rcs)
          remove FilterableModel.ResultCountListener
 void rollbackEditCatalogItem(CatalogChangeEvent 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(java.lang.Object n_cModel)
          Set the table's org.salespointframework.data.
 void setModelFilter(FilterableModel.ModelFilter modelFilter)
          apply new model filter
 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 Catalog.
 
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 used to determine visibility.


m_cModel

protected Catalog<?> m_cModel
The Catalog that is being modelled.


m_cmpComparator

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


resultCountListeners

protected java.util.List<FilterableModel.ResultCountListener> resultCountListeners

modelFilter

protected FilterableModel.ModelFilter modelFilter
applied model filter


m_lKeys

protected java.util.List<java.lang.String> m_lKeys
The internal model. A list of the CatalogItems' keys.

Constructor Detail

CatalogTableModel

public CatalogTableModel(Catalog c,
                         DataBasket db,
                         java.util.Comparator<CatalogItem> cmp,
                         TableEntryDescriptor ted)
Create a new CatalogTableModel.

Parameters:
c - the Catalog to be modelled. May be filtered.
db - the DataBasket to be used to determine visibility.
cmp - a Comparator defining the sort order of the records. If null, records are ordered according to the natural ordering of the CatalogItems.
ted - a TableEntryDescriptor that can split individual CatalogItems into a table's cells.
the - catalog filter
Method Detail

setData

public void setData(java.lang.Object n_cModel)
Set the table's org.salespointframework.data. Data is Catalog

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

getComparator

public java.util.Comparator<CatalogItem> getComparator()

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

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 Catalog is a ListenableCatalog, 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 Catalog is a ListenableCatalog, un-subscribe as a listener.

Specified by:
unsubscribe in interface HelpableListener

updateModel

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

Specified by:
updateModel in interface HelpableListener

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

propertyChange

public void propertyChange(java.beans.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 java.beans.PropertyChangeListener

checkAdd

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

Parameters:
ci - the added CatalogItem

checkRemove

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

Parameters:
ci - the removed CatalogItem

checkUpdate

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

Parameters:
ci - the updated CatalogItem

DatasourceChanged

public void DatasourceChanged(boolean pumpUp)
Indicates a change of Datasource. Model should invalidate all internal structures and force its listener, to update themselves completely

Specified by:
DatasourceChanged in interface DatasourceChangeListener
Parameters:
pumpUp - true if the event should be pumped up to hosts, because this event is mostly triggered twice. first time to invalidate caches. second time for load new data

addResultCountListener

public boolean addResultCountListener(FilterableModel.ResultCountListener rcs)
Description copied from interface: FilterableModel
add new FilterableModel.ResultCountListener

Specified by:
addResultCountListener in interface FilterableModel
Returns:
true, on success

filterPropertyChanged

public void filterPropertyChanged()
Description copied from interface: FilterableModel
property of model filter changed

Specified by:
filterPropertyChanged in interface FilterableModel

removeResultCountListener

public void removeResultCountListener(FilterableModel.ResultCountListener rcs)
Description copied from interface: FilterableModel
remove FilterableModel.ResultCountListener

Specified by:
removeResultCountListener in interface FilterableModel

setModelFilter

public void setModelFilter(FilterableModel.ModelFilter modelFilter)
Description copied from interface: FilterableModel
apply new model filter

Specified by:
setModelFilter in interface FilterableModel
Parameters:
modelFilter - new model filter