edu.northwestern.at.wordhoard.swing.accounts
Class AccountModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by edu.northwestern.at.wordhoard.swing.accounts.AccountModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

 class AccountModel
extends javax.swing.table.AbstractTableModel

Account model.

Each manage accounts window has a model which acts as a Swing table model, manages all communications with the server session, and maintains the following state information for the window:

Window components register listeners on the model to listen for and react appropriately to changes in the state of the window.


Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
AccountModel(WordHoardSession session, AbstractWindow parentWindow)
          Creates a new account model.
 
Method Summary
(package private)  void addListener(AccountListener listener)
          Adds a listener.
(package private)  void createAccount()
          Creates a new account.
(package private)  void deleteAccounts()
          Deletes the selected accounts.
(package private)  void err(java.lang.Exception e)
          Handles an exception.
 int getColumnCount()
          Gets the number of columns.
 java.lang.String getColumnName(int col)
          Gets the name of a column.
(package private)  boolean getCreatingNewAccount()
          Returns true if we are creating a new account.
 int getRowCount()
          Gets the number of rows.
(package private)  Account getSelectedAccount()
          Gets the currently selected account.
(package private)  int[] getSelection()
          Gets the selection.
 java.lang.Object getValueAt(int row, int col)
          Gets the value of a cell.
(package private)  void init()
          Initializes the model.
(package private)  void removeListener(AccountListener listener)
          Removes a listener.
(package private)  void save(java.lang.String username, java.lang.String name, java.lang.String password, boolean nuAccount, boolean canManageAccounts)
          Saves an account.
 void selectAccount(int index)
          Requests that an account be selected.
(package private)  void setSelection(int[] selection)
          Sets the selection.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountModel

AccountModel(WordHoardSession session,
             AbstractWindow parentWindow)
       throws java.lang.Exception
Creates a new account model.

Parameters:
session - Server session.
parentWindow - Parent window.
Throws:
java.lang.Exception
Method Detail

getRowCount

public int getRowCount()
Gets the number of rows.

Returns:
The number of rows.

getColumnCount

public int getColumnCount()
Gets the number of columns.

Returns:
The number of columns.

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Gets the value of a cell.

Parameters:
row - Row index.
col - Column index.
Returns:
Value of cell.

getColumnName

public java.lang.String getColumnName(int col)
Gets the name of a column.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
col - Column index.
Returns:
Name of column.

init

void init()
Initializes the model.


getSelection

int[] getSelection()
Gets the selection.

Returns:
Array of indexes of selected accounts.

setSelection

void setSelection(int[] selection)
Sets the selection.

Parameters:
selection - Array of indexes of selected accounts.

getSelectedAccount

Account getSelectedAccount()
Gets the currently selected account.

Returns:
The currently selected account, or null if the selection is empty or has more than one account.

save

void save(java.lang.String username,
          java.lang.String name,
          java.lang.String password,
          boolean nuAccount,
          boolean canManageAccounts)
    throws java.lang.Exception
Saves an account.

Parameters:
username - Username.
name - Name.
password - Password. For an existing account, a null or empty value leaves the password unchanged.
nuAccount - True if NU account.
canManageAccounts - True if user is permitted to manage accounts.
Throws:
java.lang.Exception

selectAccount

public void selectAccount(int index)
Requests that an account be selected.

Parameters:
index - Index of account to be selected.

createAccount

void createAccount()
Creates a new account.


getCreatingNewAccount

boolean getCreatingNewAccount()
Returns true if we are creating a new account.

Returns:
True if creating new account.

deleteAccounts

void deleteAccounts()
              throws java.lang.Exception
Deletes the selected accounts.

Throws:
java.lang.Exception

addListener

void addListener(AccountListener listener)
Adds a listener.

Parameters:
listener - Account listener.

removeListener

void removeListener(AccountListener listener)
Removes a listener.

Parameters:
listener - Account listener.

err

void err(java.lang.Exception e)
Handles an exception.

Parameters:
e - Exception.