SalesPoint Framework v3.0

users.swing
Class UserListModel

java.lang.Object
  |
  +--javax.swing.AbstractListModel
        |
        +--users.swing.UserListModel
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
Version:
2.0 05/05/1999
Author:
Steffen Zschaler
See Also:
UserManager, User, Serialized Form

Field Summary
protected  Comparator m_cmpComparator
          A Comparator that orders the users.
protected  List 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 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 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, 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 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 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 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 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.
Override:
Never.
Returns:
the number of users in the model.
Overrides:
getSize in class AbstractListModel

getElementAt

public Object getElementAt(int nIndex)
Get a user by index.
Override:
Never.
Parameters:
nIndex - the index of the user to be returned.
Returns:
the user associated with the given index.
Overrides:
getElementAt in class AbstractListModel

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.
Override:
Sometimes.
Specified by:
userAdded in interface UserDataListener
Parameters:
e - the event object describing the event.

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.
Override:
Sometimes.
Specified by:
userDeleted in interface UserDataListener
Parameters:
e - the event object describing the event.

updateModel

public void updateModel()
Update the internal model.
Override:
Sometimes.
Specified by:
updateModel in interface HelpableListener

subscribe

public void subscribe()
Subscribe to the UserManager to be informed of any changes in its set of users.
Override:
Never.
Specified by:
subscribe in interface HelpableListener

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.
Override:
Never.
Specified by:
unsubscribe in interface HelpableListener

SalesPoint Framework v3.0