GraphLab Project

graphlab.ui
Class AbstractExtensionAction<t extends Extension>

java.lang.Object
  extended by graphlab.platform.core.AbstractAction
      extended by graphlab.ui.AbstractExtensionAction<t>
All Implemented Interfaces:
Action, Listener, java.awt.event.ActionListener, java.util.EventListener
Direct Known Subclasses:
AlgorithmExtensionAction, AtomAnimatorExtensionAction, GraphActionExtensionAction, GraphGeneratorExtensionAction, GraphReaderExtensionAction, GraphReportExtensionAction, GraphWriterExtensionAction, VisualizationExtensionAction

public abstract class AbstractExtensionAction<t extends Extension>
extends AbstractAction
implements java.awt.event.ActionListener

the base class for creating extension handlers the implementing class will have a menu assigned to it automatically the name of the menu will be from the constructors parametr(sp) and the will also listen to UI.getUIEvent(sp.getName())

Author:
azin azadi

Field Summary
protected  javax.swing.JButton extraButton
          a button which will be added to the right of menu item
 GMenuItem menuItem
           
protected  javax.swing.JMenu parentMenu
           
 t target
           
 
Fields inherited from class graphlab.platform.core.AbstractAction
blackboard
 
Constructor Summary
AbstractExtensionAction(BlackBoard bb, t sp)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          occurs whenever extraButton pressed

=

protected  void createExtensionCommandsForCommandLine()
           
protected  GMenuItem createMenuItem(java.lang.String name, java.lang.String actionId, BlackBoard bb)
          if you want to create custom menues for your extension (i.e.
protected  java.lang.String getMenuNamePrefix()
          to put a prefix before the name of your extension menu override this method
protected  int getMenuPlace()
          It is a XML-Based UI concept
protected  javax.swing.JMenu getParentMenu()
          gets a menu for adding the sub menu, if returns null, no submenu will added!
abstract  java.lang.String getParentMenuName()
          returns the menu name that the menuitem of this action is its child
 t getTarget()
           
protected  boolean isInsertExtraButtonToMenuItem()
          determines wheter to insert an extra button at the right side of mene item, normally this is true whenever the target extension implements Parametrizable (have some parameters) on this mode on pressing the button a dialog for setting the parameters will be shown, and then it will be executed, if the user clicks the menu item directly the extension will be performed without asking of parameters.
 void performAction(java.lang.String eventKey, java.lang.Object value)
          like Action
abstract  void performExtension()
           
 java.lang.Object performExtensionInCommandLine()
          inorder if you created a new type of extension and for that extension you want to do some thing different when it is called on commandline (i.e.
 void removeCreatedUIComponents()
          removes all UI Components that are created for the extension (menues, ...)
 boolean testAndSetParameters(java.lang.Object o)
          first checks if o instanceof Parametrizable if so, shows an editor for it's Parameters.
 
Methods inherited from class graphlab.platform.core.AbstractAction
disable, enable, getBlackBoard, getLastListenedEventKey, isEnable, keyChanged, listen4Event, setBlackBoard, unListenEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentMenu

protected javax.swing.JMenu parentMenu

menuItem

public GMenuItem menuItem

extraButton

protected javax.swing.JButton extraButton
a button which will be added to the right of menu item


target

public t extends Extension target
Constructor Detail

AbstractExtensionAction

public AbstractExtensionAction(BlackBoard bb,
                               t sp)
Method Detail

getTarget

public t getTarget()

getMenuPlace

protected int getMenuPlace()
It is a XML-Based UI concept

Returns:
the place which the extension menu will be inserted in its parents menu, the place is only a comparative value, it means that Menu Items with bigger place will be inserted after smaller place Menue Items

createMenuItem

protected final GMenuItem createMenuItem(java.lang.String name,
                                         java.lang.String actionId,
                                         BlackBoard bb)
if you want to create custom menues for your extension (i.e. want to add some extra components to it) you should override this method.

Parameters:
name -
actionId -
bb -
Returns:
See Also:
AlgorithmExtensionAction

isInsertExtraButtonToMenuItem

protected boolean isInsertExtraButtonToMenuItem()
determines wheter to insert an extra button at the right side of mene item, normally this is true whenever the target extension implements Parametrizable (have some parameters) on this mode on pressing the button a dialog for setting the parameters will be shown, and then it will be executed, if the user clicks the menu item directly the extension will be performed without asking of parameters.

if you want to override this method for your own ExtensionAction NOTE that on pressing the button the actionPerformed will be called, so you can do what you want to do by overriding that method.

Returns:
true to insert the extra button, false to no insert it.
See Also:
Parametrizable, @Parameter, AlgorithmExtensionAction

performExtensionInCommandLine

public java.lang.Object performExtensionInCommandLine()
inorder if you created a new type of extension and for that extension you want to do some thing different when it is called on commandline (i.e. in normal state it uses some GUI functionalities and you want to avoid them) you can override this method and do what you want, which will be called whenever your extension called from commandline for an example see GraphGeneratorExtensionAction

See Also:
GraphGeneratorExtensionAction

createExtensionCommandsForCommandLine

protected void createExtensionCommandsForCommandLine()

getMenuNamePrefix

protected java.lang.String getMenuNamePrefix()
to put a prefix before the name of your extension menu override this method


getParentMenu

protected javax.swing.JMenu getParentMenu()
gets a menu for adding the sub menu, if returns null, no submenu will added!


testAndSetParameters

public boolean testAndSetParameters(java.lang.Object o)
first checks if o instanceof Parametrizable if so, shows an editor for it's Parameters.

Parameters:
o -
Returns:
true if o isn't an instance of Parametrizable or the user cancells the editing

removeCreatedUIComponents

public void removeCreatedUIComponents()
removes all UI Components that are created for the extension (menues, ...)


getParentMenuName

public abstract java.lang.String getParentMenuName()
returns the menu name that the menuitem of this action is its child


performAction

public final void performAction(java.lang.String eventKey,
                                java.lang.Object value)
Description copied from class: AbstractAction
like Action

Specified by:
performAction in interface Action
Specified by:
performAction in class AbstractAction

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
occurs whenever extraButton pressed

=

Specified by:
actionPerformed in interface java.awt.event.ActionListener

performExtension

public abstract void performExtension()

GraphLab Project