org.jbudget.gui.trans
Class TransactionListModelBase

java.lang.Object
  extended by org.jbudget.gui.trans.TransactionListModelBase
All Implemented Interfaces:
javax.swing.table.TableModel, FilterChangeListener, TransactionSorterPanel.TransactionSorterListener, EventDispatcher.DataSourceListener, EventDispatcher.UserListener
Direct Known Subclasses:
AllocationsListModel, TransactionListModel

public abstract class TransactionListModelBase
extends java.lang.Object
implements javax.swing.table.TableModel, TransactionSorterPanel.TransactionSorterListener, FilterChangeListener, EventDispatcher.UserListener, EventDispatcher.DataSourceListener

A model for creating a list of transactions or allocations. An abstract class that is used to create TableModels for lists (the table has only one column) of Transactions or Allocations

Author:
petrov

Field Summary
private  java.util.Comparator<org.jbudget.Core.Transaction> comparator
          Comparator used for sorting
protected  boolean dispose_called
           
protected  org.jbudget.Core.TransactionFilter filter
          current filter
private  java.util.List<TransactionListPanelBase.ModelListener> listeners
          List of listeners
protected  java.util.List<org.jbudget.Core.Transaction> transactions
          List of Transactions
 
Constructor Summary
TransactionListModelBase()
          Creates a new instance of TransactionListModelBase
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener l)
           
 void addTableModelListener(TransactionListPanelBase.ModelListener l)
           
 void dataSourceChanged()
          Method that is called when the data directory has changed.
(package private)  void dispose()
           
 void filterUpdated(org.jbudget.Core.TransactionFilter newFilter, java.lang.Object initiator)
          Changes the filter
 void fireStopEditing()
          Forces all listeners to stop editing and save the updated values.
 void fireTableChanged()
          Notifies all listeners that the contents of the list has changed
 java.lang.Class getColumnClass(int index)
           
 int getColumnCount()
           
 java.lang.String getColumnName(int index)
           
 org.jbudget.Core.TransactionFilter getFilter()
           
 int getRowCount()
           
protected abstract  java.util.List<org.jbudget.Core.Transaction> getTransactions()
          Returns a list of transactions.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
 int indexOf(java.lang.Object key)
          Returns the index of an object
(package private)  void initialize()
          Creates a local list of transactions that satisfy the filtering requirements and sorts them if the comparator is set
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void removeTableModelListener(javax.swing.event.TableModelListener l)
           
 void setComparator(java.util.Comparator<org.jbudget.Core.Transaction> comparator)
          Change comparator
abstract  void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 void userAdded(org.jbudget.Core.User user)
          Implementing the interface.
 void userChanged(org.jbudget.Core.User user)
          Called when the user has changed.
 void userRemoved(int uid)
          Implementing the interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

private final java.util.List<TransactionListPanelBase.ModelListener> listeners
List of listeners


transactions

protected java.util.List<org.jbudget.Core.Transaction> transactions
List of Transactions


comparator

private java.util.Comparator<org.jbudget.Core.Transaction> comparator
Comparator used for sorting


filter

protected org.jbudget.Core.TransactionFilter filter
current filter


dispose_called

protected boolean dispose_called
Constructor Detail

TransactionListModelBase

public TransactionListModelBase()
Creates a new instance of TransactionListModelBase

Method Detail

dispose

void dispose()

addTableModelListener

public void addTableModelListener(TransactionListPanelBase.ModelListener l)

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
addTableModelListener in interface javax.swing.table.TableModel

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)
Specified by:
removeTableModelListener in interface javax.swing.table.TableModel

getColumnClass

public java.lang.Class getColumnClass(int index)
Specified by:
getColumnClass in interface javax.swing.table.TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface javax.swing.table.TableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int index)
Specified by:
getColumnName in interface javax.swing.table.TableModel

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Specified by:
getValueAt in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface javax.swing.table.TableModel

setValueAt

public abstract void setValueAt(java.lang.Object aValue,
                                int rowIndex,
                                int columnIndex)
Specified by:
setValueAt in interface javax.swing.table.TableModel

userChanged

public void userChanged(org.jbudget.Core.User user)
Called when the user has changed.

Specified by:
userChanged in interface EventDispatcher.UserListener

userRemoved

public void userRemoved(int uid)
Implementing the interface.

Specified by:
userRemoved in interface EventDispatcher.UserListener

userAdded

public void userAdded(org.jbudget.Core.User user)
Implementing the interface.

Specified by:
userAdded in interface EventDispatcher.UserListener

dataSourceChanged

public void dataSourceChanged()
Method that is called when the data directory has changed.

Specified by:
dataSourceChanged in interface EventDispatcher.DataSourceListener

fireTableChanged

public void fireTableChanged()
Notifies all listeners that the contents of the list has changed


fireStopEditing

public void fireStopEditing()
Forces all listeners to stop editing and save the updated values.


getTransactions

protected abstract java.util.List<org.jbudget.Core.Transaction> getTransactions()
Returns a list of transactions.


initialize

void initialize()
Creates a local list of transactions that satisfy the filtering requirements and sorts them if the comparator is set


filterUpdated

public void filterUpdated(org.jbudget.Core.TransactionFilter newFilter,
                          java.lang.Object initiator)
Changes the filter

Specified by:
filterUpdated in interface FilterChangeListener
Parameters:
newFilter - the new filter object.
initiator - reference to the object that initiated the change.

getFilter

public org.jbudget.Core.TransactionFilter getFilter()

setComparator

public void setComparator(java.util.Comparator<org.jbudget.Core.Transaction> comparator)
Change comparator

Specified by:
setComparator in interface TransactionSorterPanel.TransactionSorterListener

indexOf

public int indexOf(java.lang.Object key)
Returns the index of an object