org.jbudget.gui.user
Class UserSelectorModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.jbudget.gui.user.UserSelectorModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ListModel

public class UserSelectorModel
extends javax.swing.AbstractListModel

A list model for selecting a user.

Author:
petrov
See Also:
Serialized Form

Field Summary
private  EventDispatcher.UserListener listener
           
private  boolean showAllUsers
          If true not all users are shown and the users are not added to the list when they are added to the DataManager.
private  java.util.List<Pair<java.lang.Integer,java.lang.String>> shownUsers
          List of displayed users
private  boolean wasDisposed
          Guard variable
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
UserSelectorModel()
          Creates a new instance of UserSelectorModel.
UserSelectorModel(java.util.List<Pair<java.lang.Integer,java.lang.String>> shownUsers)
          Initializes the data model to show only users that are in the given list.
 
Method Summary
 void addToList(Pair<java.lang.Integer,java.lang.String> userInfo)
          Add a user to the list.
 void addToList(org.jbudget.Core.User user)
          Add a user to the list.
 void dispose()
          Frees resources
 void finalize()
           
 java.lang.Object getElementAt(int i)
          Returns the element at the appropriate location
 int getSize()
          Returns the number of available budgets
private  void initialize()
          Gets a list of available budgets from the DataManager
 void removeFromList(Pair<java.lang.Integer,java.lang.String> userInfo)
          Add a user to the list.
 void removeFromList(org.jbudget.Core.User user)
          Add a user to the list.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shownUsers

private java.util.List<Pair<java.lang.Integer,java.lang.String>> shownUsers
List of displayed users


showAllUsers

private final boolean showAllUsers
If true not all users are shown and the users are not added to the list when they are added to the DataManager.


listener

private EventDispatcher.UserListener listener

wasDisposed

private boolean wasDisposed
Guard variable

Constructor Detail

UserSelectorModel

public UserSelectorModel()
Creates a new instance of UserSelectorModel. Configures the model to show all users known to the DataManager except for the system and unknown users.


UserSelectorModel

public UserSelectorModel(java.util.List<Pair<java.lang.Integer,java.lang.String>> shownUsers)
Initializes the data model to show only users that are in the given list.

Method Detail

addToList

public void addToList(org.jbudget.Core.User user)
Add a user to the list. Should only be used when showAllUsers is true


addToList

public void addToList(Pair<java.lang.Integer,java.lang.String> userInfo)
Add a user to the list. Should only be used when showAllUsers is true


removeFromList

public void removeFromList(org.jbudget.Core.User user)
Add a user to the list. Should only be used when showAllUsers is true


removeFromList

public void removeFromList(Pair<java.lang.Integer,java.lang.String> userInfo)
Add a user to the list. Should only be used when showAllUsers is true


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


getElementAt

public java.lang.Object getElementAt(int i)
Returns the element at the appropriate location


getSize

public int getSize()
Returns the number of available budgets