GraphLab Project

graphlab.platform.core
Class AbstractAction

java.lang.Object
  extended by graphlab.platform.core.AbstractAction
All Implemented Interfaces:
Action, Listener
Direct Known Subclasses:
AbstractExtensionAction, ActionGrouper, AddEdge, AddTab, AddVertex, BendedTrees, BlackBoardWatcher, circular, ClearGraph, ClearSelection, CloseTab, Copy, CopyAsImage, CopyAsMatrix, Cut, DeleteEdge, DeleteSelected, DeleteVertex, DeSelect, DragEdge, EdgeHighlightAction, EdgeSelectEvent, Exceptioner, ExceptionReport, ExitAction, GraphAction, GraphPropertyEditor, Help, InvertSelection, LastSelectedStatusAction, LocalSF, MemoryUsageStatusAction, MoveSelected, MoveVertex, NewGraph, Paste, PopupMenuHandler, PreferencesAction, Random, RectangularSelect, RedoAction, ResetGraph, Select, SelectAll, SelectUpdater, ShowAboutDialog, ShowPreview, SimpleAlgorithmAnimator, StatusBarMessage, TestAction, UIActionExtensionAction, UIEventHandler, UndoAction, UndoLogManager, VertexHighlightAction, VertexMoveEvent, VertexSelectEvent, VertexTransformer

public abstract class AbstractAction
extends java.lang.Object
implements Action, Listener

AbstractAction itself is a wrapper for the interface Action. As you see in the source, it contains only two methods to implement. The first one is the action that must be done by this action, performAction() gets the event(key) that has caused this action to be run. This helps if an action is result of multiple events or when event handling must be coped with in the implementation itself.

The abstract class, AbstractAction is the minimal implementation of an Action in a class. It integrates the Action with the GraphLab structure. As a result any recognized AbstractAction in the GraphLab ui is Runnable. The introducing procedure is done via Xml files.

There is no default constructor, so every descendant of AbstractAction needs to call the super constructor in its constructor first. It is because the constructor of the AbstractAction assures that the action is registered in a BlackBoard and it is enabled. Method enable() and disable() are designated to control enablity of Action groups.

As you can see AbstractAction has implemented The interface Listener. It is easy to see why! Every action is a reaction to event(key change) that is called from a user or program itself. so every AbstractAction is listening to it's relevant event to be fired. Methods listen4Event() and unListenEvent() are designed to handle the relevant events.

Basically if you want to do anything in GraphLab, you need to extend AbstractAction. Looking at it's code might help.

note: As you may see working with AbstractAction to handle UI events is not so simple, Also there are many classes in !GraphLab that use AbstractAction. But this is not advised to you, It is easier to use Extensions whenever you want to interact with user interface. (basically UIActionExtension, but almost every extensions are welcome!)

Author:
rouzbeh ebrahimi, Azin Azadi
See Also:
UIActionExtension, Action, BlackBoard

Field Summary
protected  BlackBoard blackboard
           
 
Constructor Summary
AbstractAction(BlackBoard bb)
          constructor
 
Method Summary
 void disable()
          disables the action prevent it from doing anything.
 void enable()
          enables the action see disable
 BlackBoard getBlackBoard()
           
 java.lang.String getLastListenedEventKey()
           
 boolean isEnable()
           
 void keyChanged(java.lang.String key, java.lang.Object value)
          Event occured, Go and call the listeners to do the Job
protected  void listen4Event(java.lang.String key)
          listens for an event in the black board, (so multiple listening is available)
abstract  void performAction(java.lang.String key, java.lang.Object value)
          like Action
 void setBlackBoard(BlackBoard t)
          each action have a black board which can interact with the world! by it.
protected  void unListenEvent(java.lang.String key)
          unlisten the event, see:listen4Event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blackboard

protected BlackBoard blackboard
Constructor Detail

AbstractAction

public AbstractAction(BlackBoard bb)
constructor

Parameters:
bb - the blackboard of the action
Method Detail

performAction

public abstract void performAction(java.lang.String key,
                                   java.lang.Object value)
like Action

Specified by:
performAction in interface Action
Parameters:
key -
value -

setBlackBoard

public final void setBlackBoard(BlackBoard t)
Description copied from interface: Action
each action have a black board which can interact with the world! by it.

Specified by:
setBlackBoard in interface Action

keyChanged

public final void keyChanged(java.lang.String key,
                             java.lang.Object value)
Description copied from interface: Listener
Event occured, Go and call the listeners to do the Job

Specified by:
keyChanged in interface Listener
Parameters:
key -

unListenEvent

protected final void unListenEvent(java.lang.String key)
unlisten the event, see:listen4Event

Parameters:
key - the Event for unlisten

getLastListenedEventKey

public java.lang.String getLastListenedEventKey()

listen4Event

protected final void listen4Event(java.lang.String key)
listens for an event in the black board, (so multiple listening is available)

Parameters:
e - the Event for listening

getBlackBoard

public BlackBoard getBlackBoard()
Returns:
the blackboard of this action

disable

public void disable()
disables the action prevent it from doing anything. it is used in the configuration


enable

public void enable()
enables the action see disable


isEnable

public final boolean isEnable()

GraphLab Project