org.jbudget.gui.budget
Class AccountSelectorModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.jbudget.gui.budget.AccountSelectorModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class AccountSelectorModel
extends javax.swing.table.AbstractTableModel

A list model for selecting an account.

Author:
petrov
See Also:
Serialized Form

Field Summary
private  java.util.List<org.jbudget.Core.Account> availableAccounts
          List of displayed accounts
private  org.jbudget.Core.Budget budget
          Used when showing accounts registered with a particular budget
private  java.lang.String[] columnNames
          Column names
private  EventDispatcher.AccountListener listener
           
private  int listType
          Type of list
static int SHOW_ALL
           
static int SHOW_REGISTERED
           
static int SHOW_UNREGISTERED
           
static int SHOW_UNUSED
           
private  boolean showHidden
          should we show hidden accounts
private  boolean wasDisposed
          Guard variable
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AccountSelectorModel(boolean showUnused)
          Creates a new instance of BudgetSelectorModel.
AccountSelectorModel(org.jbudget.Core.Budget budget, boolean showUnused)
          Creates a new instance of BudgetSelectorModel.
 
Method Summary
 void dispose()
          Frees resources
 void finalize()
           
 java.lang.Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
          Number of columns.
 java.lang.String getColumnName(int columnIndex)
          Get column name.
 int getRowCount()
          Number of rows.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
           
private  void initialize()
          Gets a list of available budgets from the DataManager
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
           
 
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, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

budget

private final org.jbudget.Core.Budget budget
Used when showing accounts registered with a particular budget


SHOW_ALL

public static final int SHOW_ALL
See Also:
Constant Field Values

SHOW_UNUSED

public static final int SHOW_UNUSED
See Also:
Constant Field Values

SHOW_REGISTERED

public static final int SHOW_REGISTERED
See Also:
Constant Field Values

SHOW_UNREGISTERED

public static final int SHOW_UNREGISTERED
See Also:
Constant Field Values

listType

private final int listType
Type of list


showHidden

private boolean showHidden
should we show hidden accounts


availableAccounts

private java.util.List<org.jbudget.Core.Account> availableAccounts
List of displayed accounts


columnNames

private java.lang.String[] columnNames
Column names


listener

private EventDispatcher.AccountListener listener

wasDisposed

private boolean wasDisposed
Guard variable

Constructor Detail

AccountSelectorModel

public AccountSelectorModel(boolean showUnused)
Creates a new instance of BudgetSelectorModel. Configures the model to show all or a subset of all accounts known to the DataManager

Parameters:
showUnused - if true only accounts that are not registered with any budget are shown. In the opposite case all accounts are shown.

AccountSelectorModel

public AccountSelectorModel(org.jbudget.Core.Budget budget,
                            boolean showUnused)
Creates a new instance of BudgetSelectorModel. Configures the model to show accounts registered with a particular budget, or all accounts that have not been registered with the budget.

Parameters:
showUnused - if true accounts that are not registered with the budget are shown. In the opposite case all accounts registered with the budget are shown.
Method Detail

dispose

public void dispose()
Frees resources


finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

initialize

private void initialize()
Gets a list of available budgets from the DataManager


getColumnCount

public int getColumnCount()
Number of columns.


getRowCount

public int getRowCount()
Number of rows.


getColumnName

public java.lang.String getColumnName(int columnIndex)
Get column name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getColumnClass

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

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)

setValueAt

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

isCellEditable

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