SalesPoint v3.3 API

users.swing
Class UserListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by users.swing.UserListModel
All Implemented Interfaces:
Serializable, EventListener, ListModel, UserDataListener, HelpableListener
Direct Known Subclasses:
UserComboBoxModel

public class UserListModel
extends AbstractListModel
implements UserDataListener, HelpableListener

A ListModel modelling the set or a subset of users managed by a UserManager.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
UserManager, User, Serialized Form

Field Summary
protected  Comparator<User> m_cmpComparator
          A Comparator that orders the users.
protected  List<User> m_lUsers
          A local copy of the list of users to provide easy and consistent access via an index.
protected  UserFilter m_ufFilter
          A filter that defines the subset of users that are displayed.
protected  UserManager m_um
          The UserManager that is being modelled.
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
UserListModel()
          Create a new UserListModel modelling the global UserManager.
UserListModel(UserFilter uf, Comparator<User> cmp)
          Create a new UserListModel modelling the global UserManager.
UserListModel(UserManager um)
          Create a new UserListModel modelling a given UserManager.
UserListModel(UserManager um, UserFilter uf, Comparator<User> cmp)
          Create a new UserListModel modelling a given UserManager.
 
Method Summary
 Object getElementAt(int nIndex)
          Get a user by index.
 int getSize()
          Return the number of users in the model.
 void subscribe()
          Subscribe to the UserManager to be informed of any changes in its set of users.
 void unsubscribe()
          Unsubscribe from the UserManager as there is no need to listen to it anymore, as we are not listened to anymore.
 void updateModel()
          Update the internal model.
 void userAdded(UserDataEvent e)
          Respond to the userAdded event by updating the internal model and forwarding a translated version of the event to anyone who listens to us.
 void userDeleted(UserDataEvent e)
          Respond to the userDeleted event by updating the internal model and forwarding a translated version of the event to anyone who listens to us.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_lUsers

protected List<User> m_lUsers
A local copy of the list of users to provide easy and consistent access via an index. This model is kept up to date by registering as a listener with the UserManager.


m_cmpComparator

protected Comparator<User> m_cmpComparator
A Comparator that orders the users. By default, users are ordered by their name.


m_ufFilter

protected UserFilter m_ufFilter
A filter that defines the subset of users that are displayed. If null no filtering will occur.


m_um

protected UserManager m_um
The UserManager that is being modelled.

Constructor Detail

UserListModel

public UserListModel()
Create a new UserListModel modelling the global UserManager. All Users will be displayed and they will be sorted by their names.


UserListModel

public UserListModel(UserFilter uf,
                     Comparator<User> cmp)
Create a new UserListModel modelling the global UserManager.

Parameters:
uf - a filter that defines the set of users to be displayed. If null, no filtering will occur.
cmp - a Comparator that defines the order of the users to be displayed. The objects to be compared by this comparator will be Users. If null, users will be ordered by their names.

UserListModel

public UserListModel(UserManager um)
Create a new UserListModel modelling a given UserManager. All Users will be displayed and they will be sorted by their names.

Parameters:
um - the UserManager to be modelled.

UserListModel

public UserListModel(UserManager um,
                     UserFilter uf,
                     Comparator<User> cmp)
Create a new UserListModel modelling a given UserManager.

Parameters:
um - the UserManager to be modelled.
uf - a filter that defines the set of users to be displayed. If null, no filtering will occur.
cmp - a Comparator that defines the order of the users to be displayed. The objects to be compared by this comparator will be Users. If null, users will be ordered by their names.
Method Detail

getSize

public int getSize()
Return the number of users in the model.

Specified by:
getSize in interface ListModel
Returns:
the number of users in the model.
Override:
Never

getElementAt

public Object getElementAt(int nIndex)
Get a user by index.

Specified by:
getElementAt in interface ListModel
Parameters:
nIndex - the index of the user to be returned.
Returns:
the user associated with the given index.
Override:
Never

userAdded

public void userAdded(UserDataEvent e)
Respond to the userAdded event by updating the internal model and forwarding a translated version of the event to anyone who listens to us.

Specified by:
userAdded in interface UserDataListener
Parameters:
e - the event object describing the event.
Override:
Sometimes

userDeleted

public void userDeleted(UserDataEvent e)
Respond to the userDeleted event by updating the internal model and forwarding a translated version of the event to anyone who listens to us.

Specified by:
userDeleted in interface UserDataListener
Parameters:
e - the event object describing the event.
Override:
Sometimes

updateModel

public void updateModel()
Update the internal model.

Specified by:
updateModel in interface HelpableListener
Override:
Sometimes

subscribe

public void subscribe()
Subscribe to the UserManager to be informed of any changes in its set of users.

Specified by:
subscribe in interface HelpableListener
Override:
Never

unsubscribe

public void unsubscribe()
Unsubscribe from the UserManager as there is no need to listen to it anymore, as we are not listened to anymore. From now on we are working in "poll-mode" until any listener indicates an interest in us again.

Specified by:
unsubscribe in interface HelpableListener
Override:
Never

SalesPoint v3.3 API