org.argouml.notation
Class NotationProvider

java.lang.Object
  extended by org.argouml.notation.NotationProvider
Direct Known Subclasses:
ActionStateNotation, AssociationEndNameNotation, AssociationNameNotation, AssociationRoleNotation, AttributeNotation, CallStateNotation, ClassifierRoleNotation, ComponentInstanceNotation, EnumerationLiteralNotation, ExtensionPointNotation, MessageNotation, ModelElementNameNotation, MultiplicityNotation, NodeInstanceNotation, ObjectFlowStateStateNotation, ObjectFlowStateTypeNotation, ObjectNotation, OperationNotation, StateBodyNotation, TransitionNotation

public abstract class NotationProvider
extends java.lang.Object

A class that implements this abstract class manages a text shown on a diagram. This means it is able to generate text that represents one or more UML objects. And when the user has edited this text, the model may be adapted by parsing the text. Additionally, a help text for the parsing is provided, so that the user knows the syntax.


Constructor Summary
NotationProvider()
           
 
Method Summary
protected  void addElementListener(java.beans.PropertyChangeListener listener, java.lang.Object element)
           
protected  void addElementListener(java.beans.PropertyChangeListener listener, java.lang.Object element, java.lang.String property)
           
protected  void addElementListener(java.beans.PropertyChangeListener listener, java.lang.Object element, java.lang.String[] property)
           
 void cleanListener(java.beans.PropertyChangeListener listener, java.lang.Object modelElement)
          Clean out the listeners registered before.
protected  java.lang.StringBuilder formatNameList(java.util.Collection modelElements)
           
protected  java.lang.StringBuilder formatNameList(java.util.Collection modelElements, java.lang.String separator)
           
abstract  java.lang.String getParsingHelp()
           
 void initialiseListener(java.beans.PropertyChangeListener listener, java.lang.Object modelElement)
          Initialise the appropriate model change listeners for the given modelelement to the given listener.
abstract  void parse(java.lang.Object modelElement, java.lang.String text)
          Parses the given text, and adapts the modelElement and maybe related elements accordingly.
protected  void removeAllElementListeners(java.beans.PropertyChangeListener listener)
           
protected  void removeElementListener(java.beans.PropertyChangeListener listener, java.lang.Object element)
           
abstract  java.lang.String toString(java.lang.Object modelElement, NotationSettings settings)
          Generate a string representation for the given model element.
 void updateListener(java.beans.PropertyChangeListener listener, java.lang.Object modelElement, java.beans.PropertyChangeEvent pce)
          Update the set of listeners based on the given event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotationProvider

public NotationProvider()
Method Detail

getParsingHelp

public abstract java.lang.String getParsingHelp()
Returns:
a i18 key that represents a help string giving an explanation to the user of the syntax

parse

public abstract void parse(java.lang.Object modelElement,
                           java.lang.String text)
Parses the given text, and adapts the modelElement and maybe related elements accordingly.

Parameters:
modelElement - the modelelement to adapt
text - the string given by the user to be parsed to adapt the model

toString

public abstract java.lang.String toString(java.lang.Object modelElement,
                                          NotationSettings settings)
Generate a string representation for the given model element.

Parameters:
modelElement - the base UML element
settings - settings that control rendering of the text
Returns:
the string written in the correct notation

initialiseListener

public void initialiseListener(java.beans.PropertyChangeListener listener,
                               java.lang.Object modelElement)
Initialise the appropriate model change listeners for the given modelelement to the given listener. Overrule this when you need more than listening to all events from the base modelelement.

Parameters:
listener - the given listener
modelElement - the modelelement that we provide notation for

cleanListener

public void cleanListener(java.beans.PropertyChangeListener listener,
                          java.lang.Object modelElement)
Clean out the listeners registered before. The default implementation is to remove all listeners that were remembered by the utility functions below.

Parameters:
listener - the given listener
modelElement - the modelelement that we provide notation for

updateListener

public void updateListener(java.beans.PropertyChangeListener listener,
                           java.lang.Object modelElement,
                           java.beans.PropertyChangeEvent pce)
Update the set of listeners based on the given event.

The default implementation just removes all listeners, and then re-initialises completely - this is method 1. A more efficient way would be to dissect the propertyChangeEvent, and only adapt the listeners that need to be adapted - this is method 2.

Method 2 is explained by the code below that is commented out. Method 1 is the easiest to implement, since at every arrival of an event, we just remove all old listeners, and then inspect the current model, and add listeners where we need them. I.e. the advantage is that we only need to traverse the model structure in one location, i.e. the initialiseListener() method.

Parameters:
listener - the given listener
modelElement - the modelelement that we provide notation for
pce - the received event, that we base the changes on

addElementListener

protected final void addElementListener(java.beans.PropertyChangeListener listener,
                                        java.lang.Object element)

addElementListener

protected final void addElementListener(java.beans.PropertyChangeListener listener,
                                        java.lang.Object element,
                                        java.lang.String property)

addElementListener

protected final void addElementListener(java.beans.PropertyChangeListener listener,
                                        java.lang.Object element,
                                        java.lang.String[] property)

removeElementListener

protected final void removeElementListener(java.beans.PropertyChangeListener listener,
                                           java.lang.Object element)

removeAllElementListeners

protected final void removeAllElementListeners(java.beans.PropertyChangeListener listener)

formatNameList

protected java.lang.StringBuilder formatNameList(java.util.Collection modelElements)

formatNameList

protected java.lang.StringBuilder formatNameList(java.util.Collection modelElements,
                                                 java.lang.String separator)


ArgoUML © 1996-2006ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook