org.argouml.model
Interface ModelEventPump


public interface ModelEventPump

This is the interface for registering interest in events sent from the model component.

Neither the registration or unregistration, nor the events themselves contain any reference to the model implementation. Instead they use the PropertyChangeListener, PropertyChangeEvent to deliver events.

The reference to the listener is a WeakReference so you don't need to call removeWHATEVERListener, you can just forget about your listener and it is eventually finalized and removed. This also means that you will have to keep a reference to your listener while it is active. Since the garbage collecting mechanism is not really deterministic a forgotten about listener might still receive events. Unless it can handle them in a harmless way, this approach should not be used. TODO: (Is this still true or does it refer to the NSUML implementation? - tfm 20051109) (This is part of the contract that is established between the Model subsystem and its users. If that is not fulfilled by the current implementation, then the current implementation is incorrect. Linus 20060411).

TODO: What event names? The event names generated are Strings and their values and meanings are not really well documented. In general they are the name of an an association end or attribute in the UML metamodel.

Here are some highlights:


Method Summary
 void addClassModelEventListener(PropertyChangeListener listener, Object modelClass, String propertyName)
          Adds a listener that listens to the event that is named eventName and that occur to instances of the given modelClass.
 void addClassModelEventListener(PropertyChangeListener listener, Object modelClass, String[] propertyNames)
          Adds a listener that listens to all events that are named eventNames and that occur to instances of the given modelClass.
 void addModelEventListener(PropertyChangeListener listener, Object modelelement)
          Adds a listener to all events fired by some modelelement.
 void addModelEventListener(PropertyChangeListener listener, Object modelelement, String propertyName)
          Adds a listener to modelevents that are fired by some given modelelement and that have the name in eventName.
 void addModelEventListener(PropertyChangeListener listener, Object modelelement, String[] propertyNames)
          Adds a listener to modelevents that are fired by some given modelelement and that have any of the names in eventNames.
 void flushModelEvents()
          Flush events from the ModelEventPump.
 void removeClassModelEventListener(PropertyChangeListener listener, Object modelClass, String propertyName)
          Removes a listener that listens to all modelevents fired by instances of modelClass and that have the name eventName.
 void removeClassModelEventListener(PropertyChangeListener listener, Object modelClass, String[] propertyNames)
          Removes a listener that listens to all modelevents fired by instances of modelClass and that have the original name eventNames.
 void removeModelEventListener(PropertyChangeListener listener, Object modelelement)
          Removes a listener that listens to all events fired by the given modelelement.
 void removeModelEventListener(PropertyChangeListener listener, Object modelelement, String propertyName)
          Removes a listener that listens to modelevents with name eventName that are fired by the given modelelement.
 void removeModelEventListener(PropertyChangeListener listener, Object modelelement, String[] propertyNames)
          Removes a listener that listens to modelevents with name eventNames that are fired by the given modelelement.
 void setSaveAction(Action saveAction)
          Register an Action with the pump that is used to perform saving.
 void startPumpingEvents()
          Start the ModelEventPump firing events.
 void stopPumpingEvents()
          Stop the ModelEventPump firing events.
 

Method Detail

addModelEventListener

public void addModelEventListener(PropertyChangeListener listener,
                                  Object modelelement,
                                  String[] propertyNames)
Adds a listener to modelevents that are fired by some given modelelement and that have any of the names in eventNames.

Parameters:
listener - The listener to add
modelelement - The modelelement the listener should be added too
propertyNames - The array of property names the listener wishes to receive events for

addModelEventListener

public void addModelEventListener(PropertyChangeListener listener,
                                  Object modelelement,
                                  String propertyName)
Adds a listener to modelevents that are fired by some given modelelement and that have the name in eventName.

Parameters:
listener - The listener to add
modelelement - The modelelement the listener should be added too
propertyName - The property name the listener wishes to receive events for

addModelEventListener

public void addModelEventListener(PropertyChangeListener listener,
                                  Object modelelement)
Adds a listener to all events fired by some modelelement.

Parameters:
listener - is the listener to add
modelelement - is the model element

removeModelEventListener

public void removeModelEventListener(PropertyChangeListener listener,
                                     Object modelelement,
                                     String[] propertyNames)
Removes a listener that listens to modelevents with name eventNames that are fired by the given modelelement.

Parameters:
listener - The listener to remove
modelelement - The modelelement that fires the events the listener is listening to.
propertyNames - The property names the listener no longer wishes to receive events for

removeModelEventListener

public void removeModelEventListener(PropertyChangeListener listener,
                                     Object modelelement,
                                     String propertyName)
Removes a listener that listens to modelevents with name eventName that are fired by the given modelelement.

Parameters:
listener - The listener to remove.
modelelement - The modelelement that fires the events the listener is listening to.
propertyName - The property name the listener no longer wishes to receive events for

removeModelEventListener

public void removeModelEventListener(PropertyChangeListener listener,
                                     Object modelelement)
Removes a listener that listens to all events fired by the given modelelement.

Parameters:
listener - is the listener
modelelement - is the model element

addClassModelEventListener

public void addClassModelEventListener(PropertyChangeListener listener,
                                       Object modelClass,
                                       String[] propertyNames)
Adds a listener that listens to all events that are named eventNames and that occur to instances of the given modelClass.

Parameters:
listener - is the listener to add.
modelClass - is the given model class
propertyNames - The property names the listener wishes to receive events for. If null or an empty array, all events will be returned.
Throws:
IllegalArgumentException - if one of the arguments is null or if the modelClass is not a valid metamodel class.
IllegalStateException - if the listener is already registred.

addClassModelEventListener

public void addClassModelEventListener(PropertyChangeListener listener,
                                       Object modelClass,
                                       String propertyName)
Adds a listener that listens to the event that is named eventName and that occur to instances of the given modelClass.

Parameters:
listener - is the listener to add.
modelClass - is the given model class
propertyName - The property name the listener wishes to receive events for.
Throws:
IllegalArgumentException - if one of the arguments is null or if the modelClass is not a valid metamodel class.
IllegalStateException - if the listener is already registred.

removeClassModelEventListener

public void removeClassModelEventListener(PropertyChangeListener listener,
                                          Object modelClass,
                                          String[] propertyNames)
Removes a listener that listens to all modelevents fired by instances of modelClass and that have the original name eventNames.

Parameters:
listener - The listener to remove
modelClass - The class the listener does not want to listen to instances anymore
propertyNames - The property names the listener no longer wishes to receive events for

removeClassModelEventListener

public void removeClassModelEventListener(PropertyChangeListener listener,
                                          Object modelClass,
                                          String propertyName)
Removes a listener that listens to all modelevents fired by instances of modelClass and that have the name eventName.

Parameters:
listener - The listener to remove
modelClass - The class the listener does not want to listen to instances anymore.
propertyName - The property name the listener no longer wishes to receive events for

setSaveAction

public void setSaveAction(Action saveAction)
Register an Action with the pump that is used to perform saving. This action will be enabled by any change to the model.

Parameters:
saveAction - the action to enable on change to model.

startPumpingEvents

public void startPumpingEvents()
Start the ModelEventPump firing events.


stopPumpingEvents

public void stopPumpingEvents()
Stop the ModelEventPump firing events.


flushModelEvents

public void flushModelEvents()
Flush events from the ModelEventPump. Blocks until all events have been delivered.



ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook