org.scopemvc.core
Interface ModelChangeEventSource

All Superinterfaces:
ModelChangeListener
All Known Implementing Classes:
BasicModel

public interface ModelChangeEventSource
extends ModelChangeListener

Implemented by model objects that fire ModelChangeEvents 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 Views 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.

Version:
$Revision: 1.6 $ $Date: 2002/09/11 19:12:29 $
Author:
Steve Meyfroidt

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

addModelChangeListener

public void addModelChangeListener(ModelChangeListener inListener)
Adds a listener for ModelChangeEvents

Parameters:
inListener - The listener to be added

removeModelChangeListener

public void removeModelChangeListener(ModelChangeListener inListener)
Removes a listener for ModelChangeEvents

Parameters:
inListener - The listener to be removed

fireModelChange

public void fireModelChange(int inChangeType,
                            Selector inSelector)
Fire a ModelChangeEvent to all listeners

Parameters:
inChangeType - The type of the change. One of the ModelChangeTypes values
inSelector - The Selector for the property of the model affected by the change

modelChanged

public 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.

Specified by:
modelChanged in interface ModelChangeListener
Parameters:
inEvent - The event


Copyright © 2000-2002 The Scope Team. All Rights Reserved.