Package org.cytoscape.application.swing
Class AbstractCyAction
java.lang.Object
javax.swing.AbstractAction
org.cytoscape.application.swing.AbstractCyAction
- All Implemented Interfaces:
ActionListener
,Serializable
,Cloneable
,EventListener
,Action
,MenuListener
,PopupMenuListener
,CyAction
An abstract implementation of the CyAction interface. Instead of using this
class directly you should (strongly) consider implementing a
TaskFactory
/Task
pair. Doing so will
allow your action to be used outside of a Swing specific application (which
the CyAction interface binds you to)!- See Also:
Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.
Module: swing-application-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>swing-application-api</artifactId> </dependency>
-
Field Summary
Modifier and TypeFieldDescriptionprotected KeyStroke
The accelerator keystroke, if set.protected boolean
Indicates whether accelerator keys have been set for the action.The configuration properties.protected boolean
Indicates whether the action is in the Edge Table Panel's toolbar.protected boolean
Indicates whether the action is in a menu.protected boolean
Indicates whether the action is in the Network Table Panel's toolbar.protected boolean
Indicates whether the action is in the Node Table Panel's toolbar.protected boolean
Indicates whether a menu separator should be inserted after this itemprotected boolean
Indicates whether a menu separator should be inserted before this itemprotected boolean
Indicates whether a toolbar separator should be inserted after this itemprotected boolean
Indicates whether a toolbar separator should be inserted before this itemprotected boolean
Indicates whether the action is in the main toolbar.protected boolean
Indicates whether the action is in the Unassigned Tables Panel's toolbar.protected float
The float value placing the action within the menu.protected String
The name of the action.protected String
The name describing the preferred menu for the action.protected float
The float value placing the action within the toolbar.protected URL
Path to an optional tool tip imageprotected boolean
Indicates whether to use a checkbox menu item.protected boolean
Indicates whether to use a toggle button in the tool bar.Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
-
Constructor Summary
ConstructorDescriptionAbstractCyAction
(String name) Creates a new AbstractCyAction object that is always enabled.AbstractCyAction
(String name, CyApplicationManager applicationManager, String enableFor, CyNetworkViewManager networkViewManager) Creates a new AbstractCyAction object that is enabled for the specific "enableFor" state.AbstractCyAction
(Map<String, String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager) Creates a new AbstractCyAction object.AbstractCyAction
(Map<String, String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager, TaskFactory factory) Creates a new AbstractCyAction object.AbstractCyAction
(Map<String, String> configProps, TaskFactory predicate) Creates a new AbstractCyAction object. -
Method Summary
Modifier and TypeMethodDescriptionReturns the accelerator KeyStroke defined for this action.float
Returns the gravity used to place the menu item for this action.getName()
Returns the name of the action.This method returns a Menu specification string.Return the config props.float
Returns the gravity used to place this action in the toolbar.Optional image to be displayed in the target component's tool tip.boolean
Insert a separator after this menu item.boolean
Insert a separator before this menu item.boolean
Insert a separator after this menu item.boolean
Insert a separator before this toolbar item.boolean
Returns whether the action should be in the Edge Table Panel's tool bar.boolean
By default all CytoscapeActions wish to be included in the menu bar at the 'preferredMenuName' location is specified and the 'Tools' menu not.boolean
Returns whether the action should be in the Network Table Panel's tool bar.boolean
Returns whether the action should be in the Node Table Panel's tool bar.boolean
By default no CytoscapeActions will be included in the toolbar.boolean
Returns whether the action should be in the Unassigned Tables Panel's tool bar.void
This method can be used at your discretion, but otherwise does nothing.void
This method can be used at your discretion, but otherwise does nothing.void
This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about.void
This method can be used at your discretion, but otherwise does nothing.void
This method can be used at your discretion, but otherwise does nothing.void
This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about.void
Sets the accelerator KeyStroke for this action.void
setIsInEdgeTableToolBar
(boolean b) To support configurable menus and tools, added for 3.9void
setIsInMenuBar
(boolean b) To support configurable menus and tools, setIsInMenuBar added for 3.6void
setIsInNetworkTableToolBar
(boolean b) To support configurable menus and tools, added for 3.9void
setIsInNodeTableToolBar
(boolean b) To support configurable menus and tools, added for 3.9void
setIsInToolBar
(boolean b) To support configurable menus and tools, setIsInToolBar added for 3.6void
setIsInUnassignedTableToolBar
(boolean b) To support configurable menus and tools, added for 3.9void
setMenuGravity
(float gravity) Sets the gravity used to order this action in the menu bar.void
Sets the name of the action.void
setPreferredMenu
(String newPreferredMenu) Sets the preferredMenuString.void
setToolbarGravity
(float gravity) Sets the gravity used to order this action in the toolbar.void
Triggers the enable state of the action to be updated based on the enableFor state of the action and the state of the system.boolean
Returns whether or not a checkbox menu item should be used.boolean
Returns whether or not a toggle button should be used in the tool bar.Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.swing.Action
accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
-
Field Details
-
preferredMenu
The name describing the preferred menu for the action. -
toolbarGravity
protected float toolbarGravityThe float value placing the action within the toolbar. Value of 0.0 is the beginning and -1.0 means to sort alphabetically. App developers are strongly encouraged to set specific gravities within your own menus. -
acceleratorSet
protected boolean acceleratorSetIndicates whether accelerator keys have been set for the action. -
acceleratorKeyStroke
The accelerator keystroke, if set. -
useCheckBoxMenuItem
protected boolean useCheckBoxMenuItemIndicates whether to use a checkbox menu item. -
useToggleButton
protected boolean useToggleButtonIndicates whether to use a toggle button in the tool bar. -
inToolBar
protected boolean inToolBarIndicates whether the action is in the main toolbar. -
inNodeTableToolBar
protected boolean inNodeTableToolBarIndicates whether the action is in the Node Table Panel's toolbar. -
inEdgeTableToolBar
protected boolean inEdgeTableToolBarIndicates whether the action is in the Edge Table Panel's toolbar. -
inNetworkTableToolBar
protected boolean inNetworkTableToolBarIndicates whether the action is in the Network Table Panel's toolbar. -
inUnassignedTableToolBar
protected boolean inUnassignedTableToolBarIndicates whether the action is in the Unassigned Tables Panel's toolbar. -
inMenuBar
protected boolean inMenuBarIndicates whether the action is in a menu. -
insertSeparatorBefore
protected boolean insertSeparatorBeforeIndicates whether a menu separator should be inserted before this item -
insertSeparatorAfter
protected boolean insertSeparatorAfterIndicates whether a menu separator should be inserted after this item -
insertToolbarSeparatorBefore
protected boolean insertToolbarSeparatorBeforeIndicates whether a toolbar separator should be inserted before this item -
insertToolbarSeparatorAfter
protected boolean insertToolbarSeparatorAfterIndicates whether a toolbar separator should be inserted after this item -
name
The name of the action. -
toolTipImage
Path to an optional tool tip image -
configurationProperties
The configuration properties. Adding it here allows extensions of this class to pass their own properties.
-
-
Constructor Details
-
AbstractCyAction
Creates a new AbstractCyAction object that is always enabled.- Parameters:
name
- The name of the action.
-
AbstractCyAction
public AbstractCyAction(String name, CyApplicationManager applicationManager, String enableFor, CyNetworkViewManager networkViewManager) Creates a new AbstractCyAction object that is enabled for the specific "enableFor" state.- Parameters:
name
- The name of the action.applicationManager
- The application manager providing context for this action.enableFor
- A string declaring which states this action should be enabled for.networkViewManager
- The network view manager that provides context for this action.
-
AbstractCyAction
public AbstractCyAction(Map<String, String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager) Creates a new AbstractCyAction object.- Parameters:
configProps
- A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include (seeServiceProperties
):title
- The title of the menu.preferredMenu
- The preferred menu for the action.largeIconURL
- The icon to be used for the toolbar.smallIconURL
- The icon to be used for the menu.tooltip
- The toolbar or menu tooltip.inToolBar
- Whether the action should be in the toolbar.inNodeTableToolBar
- Whether the action should be in the Node Table Panel's toolbar.inEdgeTableToolBar
- Whether the action should be in the Edge Table Panel's toolbar.inNetworkTableToolBar
- Whether the action should be in the Network Table Panel's toolbar.inUnassignedTableToolBar
- Whether the action should be in the Unassigned Tables Panel's toolbar.inMenuBar
- Whether the action should be in a menu.insertSeparatorBefore
- Whether a separator should be inserted before this menu item.insertSeparatorAfter
- Whether a separator should be inserted after this menu item.insertToolbarSeparatorBefore
- Whether a separator should be inserted before this toolbar item.insertToolbarSeparatorAfter
- Whether a separator should be inserted after this toolbar item.enableFor
- Will only use this value if the TaskFactory is not a TaskFactoryPredicate! SeeActionEnableSupport
for more detail.accelerator
- Accelerator key bindings.menuGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the menu.toolBarGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the toolbar.
applicationManager
- The application manager providing context for this action.
-
AbstractCyAction
Creates a new AbstractCyAction object.- Parameters:
configProps
- A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include (seeServiceProperties
):title
- The title of the menu.preferredMenu
- The preferred menu for the action.largeIconURL
- The icon to be used for the toolbar.smallIconURL
- The icon to be used for the menu.tooltip
- The toolbar or menu tooltip.inToolBar
- Whether the action should be in the toolbar.inNodeTableToolBar
- Whether the action should be in the Node Table Panel's toolbar.inEdgeTableToolBar
- Whether the action should be in the Edge Table Panel's toolbar.inNetworkTableToolBar
- Whether the action should be in the Network Table Panel's toolbar.inUnassignedTableToolBar
- Whether the action should be in the Unassigned Tables Panel's toolbar.inMenuBar
- Whether the action should be in a menu.insertSeparatorBefore
- Whether a separator should be inserted before this menu item.insertSeparatorAfter
- Whether a separator should be inserted after this menu item.insertToolbarSeparatorBefore
- Whether a separator should be inserted before this toolbar item.insertToolbarSeparatorAfter
- Whether a separator should be inserted after this toolbar item.enableFor
- Will only use this value if the TaskFactory is not a TaskFactoryPredicate! SeeActionEnableSupport
for more detail.accelerator
- Accelerator key bindings.menuGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the menu.toolBarGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the toolbar.
predicate
- The task factory predicate that indicates whether or not this action should be enabled.
-
AbstractCyAction
public AbstractCyAction(Map<String, String> configProps, CyApplicationManager applicationManager, CyNetworkViewManager networkViewManager, TaskFactory factory) Creates a new AbstractCyAction object.- Parameters:
configProps
- A String-String Map of configuration metadata. This will usually be the Map provided by the OSGi service configuration. Available configuration keys include (seeServiceProperties
):title
- The title of the menu.preferredMenu
- The preferred menu for the action.largeIconURL
- The icon to be used for the toolbar.smallIconURL
- The icon to be used for the menu.tooltip
- The toolbar or menu tooltip.inToolBar
- Whether the action should be in the toolbar.inNodeTableToolBar
- Whether the action should be in the Node Table Panel's toolbar.inEdgeTableToolBar
- Whether the action should be in the Edge Table Panel's toolbar.inNetworkTableToolBar
- Whether the action should be in the Network Table Panel's toolbar.inUnassignedTableToolBar
- Whether the action should be in the Unassigned Tables Panel's toolbar.inMenuBar
- Whether the action should be in a menu.insertSeparatorBefore
- Whether a separator should be inserted before this menu item.insertSeparatorAfter
- Whether a separator should be inserted after this menu item.insertToolbarSeparatorBefore
- Whether a separator should be inserted before this toolbar item.insertToolbarSeparatorAfter
- Whether a separator should be inserted after this toolbar item.enableFor
- Will only use this value if the TaskFactory is not a TaskFactoryPredicate! SeeActionEnableSupport
for more detail.accelerator
- Accelerator key bindings.menuGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the menu.toolBarGravity
- Float value with 0.0 representing the top and larger values moving towards the bottom of the toolbar.
applicationManager
- The application manager providing context for this action.factory
- The task factory that may or may not be a TaskFactoryPredicate. If it is a predicate, it will be used to indicate whether or not this action should be enabled. This TaskFactory is not used by the AbstractCyAction in any other way. Any execution of tasks from this TaskFactory must be handled by a subclass.
-
-
Method Details
-
setName
Sets the name of the action.- Parameters:
name
- The name of the action.
-
getName
Description copied from interface:CyAction
Returns the name of the action. -
getToolTipImage
Description copied from interface:CyAction
Optional image to be displayed in the target component's tool tip.- Specified by:
getToolTipImage
in interfaceCyAction
-
isInMenuBar
public boolean isInMenuBar()By default all CytoscapeActions wish to be included in the menu bar at the 'preferredMenuName' location is specified and the 'Tools' menu not.- Specified by:
isInMenuBar
in interfaceCyAction
- Returns:
- true if this CyAction should be included in menu bar.
-
setIsInMenuBar
public void setIsInMenuBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, setIsInMenuBar added for 3.6- Specified by:
setIsInMenuBar
in interfaceCyAction
-
isInToolBar
public boolean isInToolBar()By default no CytoscapeActions will be included in the toolbar.- Specified by:
isInToolBar
in interfaceCyAction
- Returns:
- true if this Action should be included in the toolbar.
-
setIsInToolBar
public void setIsInToolBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, setIsInToolBar added for 3.6- Specified by:
setIsInToolBar
in interfaceCyAction
-
isInNodeTableToolBar
public boolean isInNodeTableToolBar()Description copied from interface:CyAction
Returns whether the action should be in the Node Table Panel's tool bar.- Specified by:
isInNodeTableToolBar
in interfaceCyAction
- Returns:
- true if the action should be in the Node Table Panel's tool bar.
-
setIsInNodeTableToolBar
public void setIsInNodeTableToolBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, added for 3.9- Specified by:
setIsInNodeTableToolBar
in interfaceCyAction
-
isInEdgeTableToolBar
public boolean isInEdgeTableToolBar()Description copied from interface:CyAction
Returns whether the action should be in the Edge Table Panel's tool bar.- Specified by:
isInEdgeTableToolBar
in interfaceCyAction
- Returns:
- true if the action should be in the Edge Table Panel's tool bar.
-
setIsInEdgeTableToolBar
public void setIsInEdgeTableToolBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, added for 3.9- Specified by:
setIsInEdgeTableToolBar
in interfaceCyAction
-
isInNetworkTableToolBar
public boolean isInNetworkTableToolBar()Description copied from interface:CyAction
Returns whether the action should be in the Network Table Panel's tool bar.- Specified by:
isInNetworkTableToolBar
in interfaceCyAction
- Returns:
- true if the action should be in the Network Table Panel's tool bar.
-
setIsInNetworkTableToolBar
public void setIsInNetworkTableToolBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, added for 3.9- Specified by:
setIsInNetworkTableToolBar
in interfaceCyAction
-
isInUnassignedTableToolBar
public boolean isInUnassignedTableToolBar()Description copied from interface:CyAction
Returns whether the action should be in the Unassigned Tables Panel's tool bar.- Specified by:
isInUnassignedTableToolBar
in interfaceCyAction
- Returns:
- true if the action should be in the Unassigned Tables Panel's tool bar.
-
setIsInUnassignedTableToolBar
public void setIsInUnassignedTableToolBar(boolean b) Description copied from interface:CyAction
To support configurable menus and tools, added for 3.9- Specified by:
setIsInUnassignedTableToolBar
in interfaceCyAction
-
insertSeparatorBefore
public boolean insertSeparatorBefore()Insert a separator before this menu item.- Specified by:
insertSeparatorBefore
in interfaceCyAction
- Returns:
- true if this Action should have a separator before it
-
insertSeparatorAfter
public boolean insertSeparatorAfter()Insert a separator after this menu item.- Specified by:
insertSeparatorAfter
in interfaceCyAction
- Returns:
- true if this Action should have a separator after it
-
insertToolbarSeparatorBefore
public boolean insertToolbarSeparatorBefore()Insert a separator before this toolbar item.- Returns:
- true if this Action should have a separator before it
-
insertToolbarSeparatorAfter
public boolean insertToolbarSeparatorAfter()Insert a separator after this menu item.- Returns:
- true if this Action should have a separator after it
-
setMenuGravity
public void setMenuGravity(float gravity) Sets the gravity used to order this action in the menu bar.- Specified by:
setMenuGravity
in interfaceCyAction
- Parameters:
gravity
- The gravity for ordering menu bar actions.
-
getMenuGravity
public float getMenuGravity()Description copied from interface:CyAction
Returns the gravity used to place the menu item for this action. Gravity is a numeric value associated with each menu item. MenuItems in the same menu pull-down are sorted in ascending order based on their gravity values.- Specified by:
getMenuGravity
in interfaceCyAction
- Returns:
- The gravity used to place the menu item for this action.
-
setToolbarGravity
public void setToolbarGravity(float gravity) Sets the gravity used to order this action in the toolbar.- Specified by:
setToolbarGravity
in interfaceCyAction
- Parameters:
gravity
- The gravity for ordering toolbar actions.
-
getToolbarGravity
public float getToolbarGravity()Description copied from interface:CyAction
Returns the gravity used to place this action in the toolbar. Gravity is a numeric value associated with each menu item. MenuItems in the same menu pull-down are sorted in ascending order based on their gravity values.- Specified by:
getToolbarGravity
in interfaceCyAction
- Returns:
- The gravity used to place this action in the toolbar.
-
setAcceleratorKeyStroke
Sets the accelerator KeyStroke for this action.- Specified by:
setAcceleratorKeyStroke
in interfaceCyAction
- Parameters:
ks
- The KeyStroke to be used as an accelerator for this action. This parameter may be null, in which case no accelerator is defined.
-
getAcceleratorKeyStroke
Description copied from interface:CyAction
Returns the accelerator KeyStroke defined for this action. Will return null if no accelerator is set.- Specified by:
getAcceleratorKeyStroke
in interfaceCyAction
- Returns:
- the accelerator KeyStroke defined for this action. Will return null if no accelerator is set.
-
getPreferredMenu
Description copied from interface:CyAction
This method returns a Menu specification string. Submenus are preceded by dots in this string, so the result "File.Import" specifies the submenu "Import" of the menu "File". If the result is null, the menu will be placed in a default location.- Specified by:
getPreferredMenu
in interfaceCyAction
- Returns:
- the string identifying the preferred menu.
-
setPreferredMenu
Sets the preferredMenuString. See thegetPreferredMenu()
description for formatting description.- Specified by:
setPreferredMenu
in interfaceCyAction
- Parameters:
newPreferredMenu
- The string describing the preferred menu name.
-
useCheckBoxMenuItem
public boolean useCheckBoxMenuItem()Description copied from interface:CyAction
Returns whether or not a checkbox menu item should be used. UseAction.putValue(String, Object)
to set the value ofAction.SELECTED_KEY
to true in order to have the menu item checked.- Specified by:
useCheckBoxMenuItem
in interfaceCyAction
- Returns:
- whether or not a checkbox menu item should be used.
-
useToggleButton
public boolean useToggleButton()Description copied from interface:CyAction
Returns whether or not a toggle button should be used in the tool bar. Only valid whenCyAction.setIsInToolBar(boolean)
is also set to true. UseAction.putValue(String, Object)
to set the value ofAction.SELECTED_KEY
to true in order to have the toggle button selected.- Specified by:
useToggleButton
in interfaceCyAction
- Returns:
- true toggle button should be used.
-
popupMenuWillBecomeVisible
This method can be overridden by individual actions to set the state of menu items based on whatever unique circumstances that menu option cares about. By default it sets the state of the menu based on the "enableFor" property found in the properties used to construct the action. The valid options for "enableFor" are "network", "networkAndView", and "selectedNetworkObjs".- Specified by:
popupMenuWillBecomeVisible
in interfacePopupMenuListener
- Parameters:
e
- The triggering event.
-
popupMenuWillBecomeInvisible
This method can be used at your discretion, but otherwise does nothing.- Specified by:
popupMenuWillBecomeInvisible
in interfacePopupMenuListener
- Parameters:
e
- The triggering event.
-
popupMenuCanceled
This method can be used at your discretion, but otherwise does nothing.- Specified by:
popupMenuCanceled
in interfacePopupMenuListener
- Parameters:
e
- The triggering event.
-
updateEnableState
public void updateEnableState()Triggers the enable state of the action to be updated based on the enableFor state of the action and the state of the system.- Specified by:
updateEnableState
in interfaceCyAction
-
getProperties
Return the config props.- Specified by:
getProperties
in interfaceCyAction
-