jgnash.ui.register.table
Class AbstractRegisterTableModel

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

public abstract class AbstractRegisterTableModel
extends javax.swing.table.AbstractTableModel
implements MessageListener, AccountTableModel, PackableTableModel

By default, the transactions are returned in the natural order of the account.

Column order will be handled by JTable. This model is responsible for handling column visibility and saving/restoring user widths.

This model does some internal manipulation to make it possible to hide specific columns.

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

Field Summary
(package private)  Account account
           
(package private)  BigDecimalCache balanceCache
           
private  java.lang.Class<?>[] cClass
           
private  java.lang.String[] cNames
           
private  int columnCount
          The cached visible column count
private  boolean columnCountCache
          Recalculate the visible column count
private  int[] columnMap
           
(package private)  boolean[] columnVisible
          the visibility state of a column
private  int[] columnWidths
           
(package private) static java.lang.String ERROR
           
(package private) static Resource rb
           
(package private)  java.lang.String reconcileSymbol
           
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Fields inherited from interface jgnash.ui.register.table.AccountTableModel
RECONCILED_SYM
 
Constructor Summary
AbstractRegisterTableModel(Account account, java.lang.String[] names, java.lang.Class<?>[] clazz)
           
 
Method Summary
(package private)  void buildColumnMap()
          Generates the mapping between visible columns
(package private)  void dispose()
           
 Account getAccount()
           
(package private)  java.math.BigDecimal getBalanceAt(int index)
          Returns the balance of the account at the specific index The balance at each index is cached to prevent recalculation each time the table requests an update
 java.lang.Class<?> getColumnClass(int col)
           
 int getColumnCount()
          Returns the number of visible columns
(package private)  int getColumnMapping(int col)
           
 java.lang.String getColumnName(int col)
           
 java.lang.String[] getColumnNames()
          Returns the name of the columns
 boolean[] getColumnVisibility()
          Returns a boolean array representing the visibility of each column in the model.
protected abstract  java.lang.Object getInternalValueAt(int row, int col)
           
 int[] getPreferredColumnWeights()
           
 java.lang.String getReconcileSymbol()
           
 int getRowCount()
           
 Transaction getTransactionAt(int index)
           
 java.lang.Object getValueAt(int row, int col)
           
 int indexOf(Transaction t)
           
private  void init(Account a, java.lang.String[] names, java.lang.Class<?>[] clazz)
           
 boolean isColumnVisible(int col)
          Returns the visibility of a column
 void messagePosted(Message event)
           
 void setColumnVisibility(boolean[] array)
           
private  void setColumnVisible(int col, boolean visible)
          Changes the visibility of a column and notifies the JTable
 void setColumnVisible(java.lang.String name, boolean visible)
          Changes the visibility of a column and notifies the JTable
 void setPreferredColumnWeigths(int[] widths)
           
 void setReconcileSymbol(java.lang.String reconcileSymbol)
           
 
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

rb

static final Resource rb

account

Account account

balanceCache

BigDecimalCache balanceCache

cNames

private java.lang.String[] cNames

cClass

private java.lang.Class<?>[] cClass

reconcileSymbol

java.lang.String reconcileSymbol

ERROR

static final java.lang.String ERROR
See Also:
Constant Field Values

columnVisible

boolean[] columnVisible
the visibility state of a column


columnMap

private int[] columnMap

columnCountCache

private boolean columnCountCache
Recalculate the visible column count


columnCount

private int columnCount
The cached visible column count


columnWidths

private int[] columnWidths
Constructor Detail

AbstractRegisterTableModel

AbstractRegisterTableModel(Account account,
                           java.lang.String[] names,
                           java.lang.Class<?>[] clazz)
Method Detail

getPreferredColumnWeights

public int[] getPreferredColumnWeights()
Specified by:
getPreferredColumnWeights in interface PackableTableModel

setPreferredColumnWeigths

public void setPreferredColumnWeigths(int[] widths)

init

private void init(Account a,
                  java.lang.String[] names,
                  java.lang.Class<?>[] clazz)

getAccount

public Account getAccount()
Specified by:
getAccount in interface AccountTableModel

getColumnNames

public java.lang.String[] getColumnNames()
Returns the name of the columns

Returns:
An array of Strings for the names of the columns

getInternalValueAt

protected abstract java.lang.Object getInternalValueAt(int row,
                                                       int col)

setColumnVisible

private void setColumnVisible(int col,
                              boolean visible)
Changes the visibility of a column and notifies the JTable

Parameters:
col - The column to change the visibility of
visible - True if visible

setColumnVisible

public void setColumnVisible(java.lang.String name,
                             boolean visible)
Changes the visibility of a column and notifies the JTable

Parameters:
name - The column name to change the visibility of
visible - True if visible

setColumnVisibility

public void setColumnVisibility(boolean[] array)

isColumnVisible

public boolean isColumnVisible(int col)
Returns the visibility of a column

Parameters:
col - The column to get visibility of
Returns:
The visibility of a column

getColumnVisibility

public boolean[] getColumnVisibility()
Returns a boolean array representing the visibility of each column in the model. Do not modify the array outside this class

Returns:
the boolean array representing the visibility of each column

buildColumnMap

void buildColumnMap()
Generates the mapping between visible columns


getColumnMapping

int getColumnMapping(int col)

getRowCount

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

getColumnName

public java.lang.String getColumnName(int col)
Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getColumnCount

public int getColumnCount()
Returns the number of visible columns

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of visible columns

getColumnClass

public java.lang.Class<?> getColumnClass(int col)
Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel

getValueAt

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

messagePosted

public void messagePosted(Message event)
Specified by:
messagePosted in interface MessageListener

dispose

void dispose()

getTransactionAt

public Transaction getTransactionAt(int index)

indexOf

public int indexOf(Transaction t)

getBalanceAt

java.math.BigDecimal getBalanceAt(int index)
Returns the balance of the account at the specific index The balance at each index is cached to prevent recalculation each time the table requests an update

Parameters:
index - indext to get balance at
Returns:
balance at the given index

getReconcileSymbol

public java.lang.String getReconcileSymbol()
Returns:
Returns the reconcileSymbol.

setReconcileSymbol

public void setReconcileSymbol(java.lang.String reconcileSymbol)
Parameters:
reconcileSymbol - The reconcileSymbol to set.