edu.northwestern.at.wordhoard.swing.accounts.groups
Class GroupModel

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

public class GroupModel
extends javax.swing.table.AbstractTableModel

Group model.

Each group panel 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 panel:

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

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
GroupModel(WordHoardSession session, AbstractWindow parentWindow)
          Creates a new userGroup model.
 
Method Summary
(package private)  void addListener(GroupListener listener)
          Adds a listener.
(package private)  void createGroup()
          Creates a new userGroup.
(package private)  void deleteGroups()
          Deletes the selected groups.
(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 getCreatingNewGroup()
          Returns true if we are creating a new userGroup.
 int getRowCount()
          Gets the number of rows.
(package private)  UserGroup getSelectedGroup()
          Gets the currently selected userGroup.
(package private)  int[] getSelection()
          Gets the selection.
 java.lang.Object getValueAt(int row, int col)
          Gets the value of a cell.
 void init()
          Initializes the model.
(package private)  void removeListener(GroupListener listener)
          Removes a listener.
(package private)  void save(java.lang.String name, java.lang.String owner)
          Saves a userGroup.
 void selectGroup(int index)
          Requests that an userGroup 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

GroupModel

public GroupModel(WordHoardSession session,
                  AbstractWindow parentWindow)
           throws java.lang.Exception
Creates a new userGroup 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

public void init()
Initializes the model.


getSelection

int[] getSelection()
Gets the selection.

Returns:
Array of indexes of selected groups.

setSelection

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

Parameters:
selection - Array of indexes of selected groups.

getSelectedGroup

UserGroup getSelectedGroup()
Gets the currently selected userGroup.

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

save

void save(java.lang.String name,
          java.lang.String owner)
    throws java.lang.Exception
Saves a userGroup.

Parameters:
name - Name.
owner - User name for owner
Throws:
java.lang.Exception

selectGroup

public void selectGroup(int index)
Requests that an userGroup be selected.

Parameters:
index - Index of userGroup to be selected.

createGroup

void createGroup()
Creates a new userGroup.


getCreatingNewGroup

boolean getCreatingNewGroup()
Returns true if we are creating a new userGroup.

Returns:
True if creating new userGroup.

deleteGroups

void deleteGroups()
            throws java.lang.Exception
Deletes the selected groups.

Throws:
java.lang.Exception

addListener

void addListener(GroupListener listener)
Adds a listener.

Parameters:
listener - Group listener.

removeListener

void removeListener(GroupListener listener)
Removes a listener.

Parameters:
listener - Group listener.

err

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

Parameters:
e - Exception.