|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Implemented by model objects that fire ModelChangeEvent
s when their
state changes: an implementation of the Observer Pattern. The Swing
components in org.scopemvc.view.swing are aware to ModelChangeEvents:
model objects that implement this interface are able to automatically refresh
any View
s bound to them.
If a submodel of a model changes, the parent must also fire a
ModelChangeEvent to notify of the change in state of one of its properties.
For example, if a Person
has a Pet
as a property,
then when the Pet changes its age it fires an event to notify of a change to
the "age" property. The Person must then also fire an event to notify that
the "pet.age" property changed. The Swing components rely on this behaviour.
A useful base implementation of ModelChangeEventSource is provided in BasicModel
, which provides several convenience
methods.
Method Summary | |
void |
addModelChangeListener(ModelChangeListener inListener)
Adds a listener for ModelChangeEvents |
void |
fireModelChange(int inChangeType,
Selector inSelector)
Fire a ModelChangeEvent to all listeners |
void |
modelChanged(ModelChangeEvent inEvent)
Implement ModelChangeListener to respond to a ModelChangeEvent from a contained sub-model that needs changes to be propagated up the model hierarchy. |
void |
removeModelChangeListener(ModelChangeListener inListener)
Removes a listener for ModelChangeEvents |
Method Detail |
public void addModelChangeListener(ModelChangeListener inListener)
inListener
- The listener to be addedpublic void removeModelChangeListener(ModelChangeListener inListener)
inListener
- The listener to be removedpublic void fireModelChange(int inChangeType, Selector inSelector)
inChangeType
- The type of the change. One of the ModelChangeTypes
valuesinSelector
- The Selector for the property of the model affected by
the changepublic void modelChanged(ModelChangeEvent inEvent)
modelChanged
in interface ModelChangeListener
inEvent
- The event
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |