org.argouml.ui.targetmanager
Class TargetManager

java.lang.Object
  |
  +--org.argouml.ui.targetmanager.TargetManager

public final class TargetManager
extends java.lang.Object

The manager of the target of argouml. The target of argouml is the selected element in the model. This can either be an instance of a meta-class (an Interface or a Class for example) but it can also be a diagram or a figure on a diagram.

Via an event mechanism this manager makes sure that all objects interested in knowing wether the event changed are acknowledged.


Constructor Summary
TargetManager()
           
 
Method Summary
 void addTarget(java.lang.Object target)
          Adds a target to the targets list.
 void addTargetListener(TargetListener listener)
          Adds a listener.
 void cleanHistory()
          Cleans the history.
 Fig getFigTarget()
          Convenience method to return the target as fig.
static TargetManager getInstance()
          Singleton retrieval method
 java.lang.Object getModelTarget()
          Returns the target in it's 'modelform'.
 java.lang.Object getTarget()
          Returns the current target.
 java.util.Collection getTargets()
          Returns a collection with all targets.
 boolean navigateBackPossible()
          Checks if it's possible to navigate backward
 void navigateBackward()
          Navigates the target pointer one target backward.
 void navigateForward()
          Navigates the target pointer one target forward.
 boolean navigateForwardPossible()
          Checks if it's possible to navigate forward.
 void removeHistoryElement(java.lang.Object o)
           
 void removeTarget(java.lang.Object target)
          Removes the target from the targets list.
 void removeTargetListener(TargetListener listener)
          Removes a listener.
 void setTarget(java.lang.Object o)
          Sets the targets to the single given object.
 void setTargets(java.util.Collection targetsList)
          Sets the given collection to the current targets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TargetManager

public TargetManager()
Method Detail

getInstance

public static TargetManager getInstance()
Singleton retrieval method

Returns:
The targetmanager

setTarget

public void setTarget(java.lang.Object o)
Sets the targets to the single given object. If there are targets at the moment of calling this method, these will be removed as targets. To all interested targetlisteners, a TargetEvent will be fired. If the new target o equals the current target, no events will be fired, nor will the target be (re)set.

Parameters:
o - The new target

getTarget

public java.lang.Object getTarget()
                           throws TargetException
Returns the current target.

Returns:
The current target
Throws:
TargetException - if there are more then 1 target.

setTargets

public void setTargets(java.util.Collection targetsList)
Sets the given collection to the current targets. If the collection equals the current targets, the targets will not be (re)set. When setting the targets, a TargetEvent will be fired to each interested listener.

Parameters:
targetsList - The new targets list.

addTarget

public void addTarget(java.lang.Object target)
Adds a target to the targets list. If the target is allready in the targets list no (re)setting will take place. Otherwise the target will be added and an appropriate TargetEvent will be fired to all interested listeners.

Parameters:
target - the target to be added.

removeTarget

public void removeTarget(java.lang.Object target)
Removes the target from the targets list. Does do nothing if the target does not exist in the targets list. Fires an appropriate TargetEvent to all interested listeners.

Parameters:
target - The target to remove.

getTargets

public java.util.Collection getTargets()
Returns a collection with all targets. Returns null if there are no targets.

Returns:
A collection with all targets.

addTargetListener

public void addTargetListener(TargetListener listener)
Adds a listener.

Parameters:
listener - the listener to add

removeTargetListener

public void removeTargetListener(TargetListener listener)
Removes a listener.

Parameters:
listener - the listener to remove

getFigTarget

public Fig getFigTarget()
Convenience method to return the target as fig. If the current target (retrieved by getTarget) is either a fig itself or the owner of a fig this fig will be returned. Otherwise null will be returned.

Returns:
the target in it's 'fig-form'

getModelTarget

public java.lang.Object getModelTarget()
Returns the target in it's 'modelform'. If the target retrieved by getTarget is an UMLDiagram or a modelelement the target will be returned. If the target is a fig but owned by a modelelement that modelelement will be returned. Otherwise null will be returned.

Returns:
the target in it's 'modelform'.

navigateForward

public void navigateForward()
                     throws java.lang.IllegalStateException
Navigates the target pointer one target forward. This implements together with navigateBackward browser like functionality.

Throws:
java.lang.IllegalStateException - If the target pointer is at the end of the history.

navigateBackward

public void navigateBackward()
                      throws java.lang.IllegalStateException
Navigates the target pointer one target backward. This implements together with navigateForward browser like functionality

Throws:
java.lang.IllegalStateException - If the target pointer is at the beginning of the history.

navigateForwardPossible

public boolean navigateForwardPossible()
Checks if it's possible to navigate forward.

Returns:
true if it is possible to navigate forward.

navigateBackPossible

public boolean navigateBackPossible()
Checks if it's possible to navigate backward

Returns:
true if it's possible to navigate backward

cleanHistory

public void cleanHistory()
Cleans the history. Needed for the JUnit tests and when instantiating a new project


removeHistoryElement

public void removeHistoryElement(java.lang.Object o)


ArgoUML © 1996-2003 (20040229)ArgoUML Project HomeArgoUML Cookbook