org.argouml.model.uml
Class UmlModelListener

java.lang.Object
  extended byorg.argouml.model.uml.UmlModelListener
All Implemented Interfaces:
EventListener, PropertyChangeListener

public class UmlModelListener
extends Object
implements PropertyChangeListener

This class captures the information about the "change flag" of the current project. Initially, the "change flag" is clear, which means that there is nothing in the project to save. The "change flag" is set by every change made to its UML model, which means that the project becomes 'dirty', i.e. it needs saving.

The UmlModelListener is a single listener that listens to all UML ModelElement events and on its turn, sends events out that indicate that the "change flag" of the Save action needs to be set.

This class only keeps an eye on changes to the UML model - i.e. it does not notice changes done to e.g. the graph like moving an edge (when they do not also change the UML model), settings, todo items or the diagrams.

The UmlModelListener only transfers information when the flag needs to be set - it does not know its current status. That is a task for the listeners in the listenerList.

Since:
ARGO0.11.2

Field Summary
private static UmlModelListener INSTANCE
          Singleton instance.
private  EventListenerList listenerList
          The listener list
static String SAVE_STATE_PROPERTY_NAME
          The name of the property that defines the save state.
private  Action saveAction
          The action to enable when the model changes.
 
Constructor Summary
private UmlModelListener()
          Don't allow instantiation.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener to the listener list.
 void deleteElement(Object elm)
          For every ModelElement that has been deleted, we want to remove its listener.
private  void fireNeedsSavePropertyChanged()
          Fire an event to all members of the listener list.
static UmlModelListener getInstance()
          Singleton instance access method.
 void newElement(Object elm)
          For every new ModelElement that has been created, we want to register for updation events.
 void propertyChange(PropertyChangeEvent pce)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a listener from the listener list.
 void setSaveAction(Action action)
          Register the Action that will be enabled whenever a model change takes place.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

private static final UmlModelListener INSTANCE
Singleton instance.


listenerList

private EventListenerList listenerList
The listener list


SAVE_STATE_PROPERTY_NAME

public static final String SAVE_STATE_PROPERTY_NAME
The name of the property that defines the save state.

See Also:
Constant Field Values

saveAction

private Action saveAction
The action to enable when the model changes.

Constructor Detail

UmlModelListener

private UmlModelListener()
Don't allow instantiation.

Method Detail

getInstance

public static UmlModelListener getInstance()
Singleton instance access method.

Returns:
the singleton instance.

setSaveAction

public void setSaveAction(Action action)
Register the Action that will be enabled whenever a model change takes place.

Parameters:
action - the action to be enabled on model change.

propertyChange

public void propertyChange(PropertyChangeEvent pce)
Specified by:
propertyChange in interface PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

newElement

public void newElement(Object elm)
For every new ModelElement that has been created, we want to register for updation events.

Parameters:
elm - the UML modelelement that has been created

deleteElement

public void deleteElement(Object elm)
For every ModelElement that has been deleted, we want to remove its listener.

Parameters:
elm - the UML modelelement that has been deleted

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to the listener list.

Parameters:
listener - The listener to add.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from the listener list.

Parameters:
listener - The listener to remove.

fireNeedsSavePropertyChanged

private void fireNeedsSavePropertyChanged()
Fire an event to all members of the listener list.



ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook