|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object SessionAdapter SwingModelFactory
A handy class for creating self-updating models for use with Swing's MVC scheme.
This class is rather clever. It will register itself with the session provided, and enacts any events from said session on the model objects it creates automatically. Eg, having created a ListModel for a chat room, this class will automatically update the ListModel's status, based upon messages received from Yahoo (or rather, the session events they generate).
The result is that users coming and going, or changing their status, will be automatically reflected by the model, and any Swing component 'listening' will be told to update its display. (For best results, take advantage of Swing's 'cell renderer' scheme to include status icons etc, based upon data provided by these models.)
Note: you should not create duplicate models for the same data, as subsequent calls will create models which superceed previous models. Each source of data, be it the user's groups, or a chat room, should have only one model created for it, which should then be passed to all Swing components which need to use that model. (This is how MVC is supposed to work anyway - with single models for each distinct data source.)
Technical note: this class uses weak references to map the objects it creates. The models are automatically freed for garbage collection once there are no strong references left outside the factory instance.
This is an experimental class, with only basic testing applied. Please report all bugs via the usual channels.
Constructor Summary | |
SwingModelFactory(Session ss)
Create a model factory. |
Method Summary | |
javax.swing.ListModel |
createListModel(YahooChatLobby ycl,
boolean sort)
Create a Swing ListModel, based upon the activities of the users in a given chatroom lobby. |
javax.swing.ListModel |
createListModel(YahooConference yc,
boolean sort)
Create a Swing ListModel, based upon the activities of the users in a given conference. |
javax.swing.tree.TreeModel |
createTreeModel(boolean sort)
Create a Swing TreeModel, based upon the activities of the users in the session's friends groups. |
static javax.swing.ListModel |
getEmptyListModel()
Convenience method to create an empty list model. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface SessionListener |
errorMessageReceived |
Constructor Detail |
public SwingModelFactory(Session ss)
Note: this method will attempt to register listeners with the given session.
ss
- sessionMethod Detail |
public javax.swing.ListModel createListModel(YahooChatLobby ycl, boolean sort)
Note: please only create one model per lobby. Future implementations of this method may refuse to work a second time for a given lobby..
ycl
- the lobby to modelsort
- true if the list is to be kept sorted
public javax.swing.ListModel createListModel(YahooConference yc, boolean sort)
Note: please only create one model per conference. Future implementations of this method may refuse to work a second time for a given conference..
Note: this model is, as yet, not fully implemented/tested.
yc
- the conference to modelsort
- true if the list is to be kept sorted
public javax.swing.tree.TreeModel createTreeModel(boolean sort)
Note: please only create model per session. Future implementations of this method may refuse to work a second time..
sort
- true if the list is to be kept sorted
public static javax.swing.ListModel getEmptyListModel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |