org.graffiti.plugin.view.interactive
Class ViewFamily<T extends InteractiveView<T>>

java.lang.Object
  extended by org.graffiti.plugin.view.interactive.ViewFamily<T>
Type Parameters:
T - common superclass of all views belonging to this ViewFamily.

public abstract class ViewFamily<T extends InteractiveView<T>>
extends Object

If different view classes want to share the same tools, triggers and actions, they return the same ViewFamily instance.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Constructor Summary
protected ViewFamily()
          Constructs a new ViewFamily.
 
Method Summary
protected  void add(ToolAction<T> action)
          Adds an action.
protected abstract  Trigger createRootTrigger()
           
 ToolAction<T> getAction(Class<? extends ToolAction<?>> toolClass)
          Returns the action implementing the specified action class, which must be annotated with the id of the action.
 ToolAction<T> getAction(String id)
          Returns the action with the specified id.
 Map<String,ToolAction<T>> getActions()
          Returns a map of ToolActions compatible with this view family.
abstract  Class<T> getCommonSuperClass()
          Returns a common super class of all views sharing this view family.
 String getId()
          Returns an id unique to each view family.
abstract  String getName()
          Returns the name of the view family as seen by the user.
 Trigger getRootTrigger()
          Gets the universal trigger root of this view family.
 Trigger getTrigger(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewFamily

protected ViewFamily()
Constructs a new ViewFamily. Note that getId() must return a different for each simultaneous instance of ViewFamily.

Method Detail

createRootTrigger

protected abstract Trigger createRootTrigger()

add

protected void add(ToolAction<T> action)
Adds an action.

Parameters:
action - an action.
See Also:
getActions()

getRootTrigger

public Trigger getRootTrigger()
Gets the universal trigger root of this view family. All triggers supported by this view family are children of the returned trigger.

Returns:
the trigger root of this view family.

getTrigger

public Trigger getTrigger(String id)

getActions

public Map<String,ToolAction<T>> getActions()
Returns a map of ToolActions compatible with this view family. That actions are provided innately by this view family. There may be other actions compatible with this view family but not contained in the map.

Returns:
a map of ToolActions compatible with this view family.

getAction

public ToolAction<T> getAction(String id)
Returns the action with the specified id.

Parameters:
id - the id of the action to return.
Returns:
the action with the specified id.
Throws:
NoSuchElementException - if no such action exists.

getAction

public ToolAction<T> getAction(Class<? extends ToolAction<?>> toolClass)
Returns the action implementing the specified action class, which must be annotated with the id of the action.

Parameters:
toolClass - the class of the action to return.
Returns:
the action implementing the specified action class.
Throws:
IllegalArgumentException - if the specified action class is not annotated with ActionId.
NoSuchElementException - if no such action exists.

getName

public abstract String getName()
Returns the name of the view family as seen by the user. Result must not contain slashes ('/').

Returns:
the name of the view family as seen by the user.

getCommonSuperClass

public abstract Class<T> getCommonSuperClass()
Returns a common super class of all views sharing this view family.

Returns:
a common super class of all views sharing this view family.

getId

public String getId()
Returns an id unique to each view family. The default implementation returns the canonical name of the common super class.

Returns:
an id unique to each view family.


Generated at 2012-05-30 11:00:36 PM CEST