|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgraphlab.platform.core.AbstractAction
public abstract class AbstractAction
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!)
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 |
---|
protected BlackBoard blackboard
Constructor Detail |
---|
public AbstractAction(BlackBoard bb)
bb
- the blackboard of the actionMethod Detail |
---|
public abstract void performAction(java.lang.String key, java.lang.Object value)
performAction
in interface Action
key
- value
- public final void setBlackBoard(BlackBoard t)
Action
setBlackBoard
in interface Action
public final void keyChanged(java.lang.String key, java.lang.Object value)
Listener
keyChanged
in interface Listener
key
- protected final void unListenEvent(java.lang.String key)
key
- the Event for unlistenpublic java.lang.String getLastListenedEventKey()
protected final void listen4Event(java.lang.String key)
e
- the Event for listeningpublic BlackBoard getBlackBoard()
public void disable()
public void enable()
public final boolean isEnable()
|
GraphLab Project | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |