jgnash.ui.register.table
Class SortedTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by jgnash.ui.register.table.AbstractRegisterTableModel
          extended by jgnash.ui.register.table.RegisterTableModel
              extended by jgnash.ui.register.table.SortedTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, MessageListener, AccountTableModel, PackableTableModel, SortableTableModel
Direct Known Subclasses:
SortedNegatedTableModel

public class SortedTableModel
extends RegisterTableModel
implements SortableTableModel

Sortable table model

Version:
$Id$
Author:
Craig Cavanaugh
See Also:
Serialized Form

Field Summary
private  boolean ascending
           
private  java.util.Comparator<Transaction> comparator
           
(package private)  java.lang.Object lock
           
private static long serialVersionUID
           
private  int sortColumn
           
private  boolean[] sortColumns
           
private  boolean[] sortedColumnMap
           
(package private)  java.util.List<Transaction> transactions
           
 
Fields inherited from class jgnash.ui.register.table.RegisterTableModel
_clazz, split
 
Fields inherited from class jgnash.ui.register.table.AbstractRegisterTableModel
account, balanceCache, columnVisible, ERROR, rb, reconcileSymbol
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface jgnash.ui.register.table.AccountTableModel
RECONCILED_SYM
 
Constructor Summary
SortedTableModel(Account account, java.lang.String[] names)
           
 
Method Summary
private  void addTransaction(Transaction t)
           
protected  void buildColumnMap()
          Overrides the super to build the sort column map
 boolean getAscending()
           
 java.math.BigDecimal getBalanceAt(int index)
          Get the account balance up to a specified index.
 int getRowCount()
           
private  boolean[] getSortableColumns()
           
 int getSortedColumn()
           
 Transaction getTransactionAt(int index)
           
private  void getTransactions()
          Creates a private clone of the account's transactions
 int indexOf(Transaction t)
           
 boolean isSortable(int col)
           
 void messagePosted(Message event)
          this override the update in AbstractRegisterTableModel to improve performance
private  void removeTransaction(Transaction t)
           
 void sortColumn(int col, boolean ascending1)
           
 
Methods inherited from class jgnash.ui.register.table.RegisterTableModel
getInternalValueAt
 
Methods inherited from class jgnash.ui.register.table.AbstractRegisterTableModel
dispose, getAccount, getColumnClass, getColumnCount, getColumnMapping, getColumnName, getColumnNames, getColumnVisibility, getPreferredColumnWeights, getReconcileSymbol, getValueAt, isColumnVisible, setColumnVisibility, setColumnVisible, setPreferredColumnWeigths, setReconcileSymbol
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, isCellEditable, removeTableModelListener, setValueAt
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

transactions

java.util.List<Transaction> transactions

sortColumn

private int sortColumn

ascending

private boolean ascending

sortedColumnMap

private boolean[] sortedColumnMap

sortColumns

private boolean[] sortColumns

comparator

private java.util.Comparator<Transaction> comparator

lock

final java.lang.Object lock
Constructor Detail

SortedTableModel

public SortedTableModel(Account account,
                        java.lang.String[] names)
Method Detail

getSortableColumns

private boolean[] getSortableColumns()

buildColumnMap

protected void buildColumnMap()
Overrides the super to build the sort column map

Overrides:
buildColumnMap in class AbstractRegisterTableModel
See Also:
AbstractRegisterTableModel.buildColumnMap()

getTransactions

private void getTransactions()
Creates a private clone of the account's transactions


getRowCount

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

getTransactionAt

public Transaction getTransactionAt(int index)
Overrides:
getTransactionAt in class AbstractRegisterTableModel

indexOf

public int indexOf(Transaction t)
Overrides:
indexOf in class AbstractRegisterTableModel

getBalanceAt

public java.math.BigDecimal getBalanceAt(int index)
Get the account balance up to a specified index.

Overrides:
getBalanceAt in class AbstractRegisterTableModel
Parameters:
index - the balance of this account at the specified index.
Returns:
the balance of the account at the specified index.

messagePosted

public void messagePosted(Message event)
this override the update in AbstractRegisterTableModel to improve performance

Specified by:
messagePosted in interface MessageListener
Overrides:
messagePosted in class AbstractRegisterTableModel

addTransaction

private void addTransaction(Transaction t)

removeTransaction

private void removeTransaction(Transaction t)

isSortable

public boolean isSortable(int col)
Specified by:
isSortable in interface SortableTableModel

sortColumn

public void sortColumn(int col,
                       boolean ascending1)
Specified by:
sortColumn in interface SortableTableModel

getSortedColumn

public int getSortedColumn()
Specified by:
getSortedColumn in interface SortableTableModel

getAscending

public boolean getAscending()
Specified by:
getAscending in interface SortableTableModel