Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.ide.controller
Class IdeAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by oracle.ide.controls.ToggleAction
          extended by oracle.ide.controller.IdeAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public class IdeAction
extends ToggleAction

An IdeAction is used when adding a menu and/or toobar button. An action object is associated with a specific command. When a menu or toolbar button is clicked on, the action determines the active view and tells the view controller to handle the command.

An action may also have a controller associated with it. When this is the case, the action uses this controller to execute the command. Otherwise, it tries to use the active view controller.

When an action cannot find a controller, it uses the IDE controller.

In addition, actions can store additional information such as: extra data, and a context.

See Also:
Command, Controller, Serialized Form

Field Summary
static java.lang.String CONTROLLER_HANDLING_UPDATE
          Internal use only.
static boolean DEBUG
          Internal use only.
static java.lang.String INVOKED_FROM
          Key which may be set on the action to specify where it was invoked from.
static java.lang.String LAST_TOOLTIP_SUFFIX
          Internal use only.
static java.lang.String ORIGINAL_ACTION_NAME
          Internal use only.
 
Fields inherited from class oracle.ide.controls.ToggleAction
ACCELERATOR, ACTION, ACTION_MENU_ACTIONS, BUTTON_GROUP_NAME, CATEGORY, CONTEXT_INDEPENDENT_NAME, DISABLED_ICON, HIDDEN, MENU_WEIGHT, MENU_WEIGHT_UNASSIGNED, MNEMONIC, PERFORM_ACTION_LATER, RADIO, STATE, TOGGLES, USER_DATA
 
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
protected IdeAction()
          Deprecated. Do not use. This constructor just throws an exception.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This method is called when the user clicks on a menu or toolbar button associated with this action.
 void addController(Controller controller)
          Adds the specified controller to the list of controllers that manage this IdeAction.
static void addController(int actionID, Controller controller)
          Convenience method for looking up the specified IdeAction by its action ID and, if found, adding the specified controller to it.
 void addControllerLast(Controller controller)
           
static IdeAction find(int cmdId)
          Finds the action associated with the specified command if it already exists.
static IdeAction find(java.lang.String commandName)
          Finds the action associated with the specified command name if it already exists.
static IdeAction[] findGroup(java.lang.String groupName)
          Finds the actions associated with the specified groupName.
static IdeAction get(int cmdId)
          Gets the action associated with the specified command id if it already exists.
static IdeAction get(int cmdId, java.lang.String name, java.lang.Integer mnemonic)
          Gets the action associated with the specified command if it already exists.
static IdeAction get(int cmdId, java.lang.String cmdClass, java.lang.String name)
          Gets the action associated with the specified command if it already exits.
static IdeAction get(int cmdId, java.lang.String cmdClass, java.lang.String name, ArrayResourceBundle bundle, int key)
          Deprecated. since 11.0. Declare actions in an extension manifest, or use one of the get methods that takes an Icon directly. Note for internal JDEVADF developers: The addin policy that icons must not be loaded during product startup is still in effect. You should avoid incurring the cost of icon loading during product startup by using the OracleIcons API.
static IdeAction get(int cmdId, java.lang.String cmdClass, java.lang.String name, java.lang.String sCategory, java.lang.Integer mnemonic, ArrayResourceBundle bundle, int key, java.lang.Object data, boolean enabled)
          Deprecated. since 11.0. Declare actions in an extension manifest, or use one of the get methods that takes an Icon directly. Note for internal JDEVADF developers: The addin policy that icons must not be loaded during product startup is still in effect. You should avoid incurring the cost of icon loading during product startup by using the OracleIcons API.
static IdeAction get(int cmdId, java.lang.String cmdClass, java.lang.String name, java.lang.String sCategory, java.lang.Integer mnemonic, javax.swing.Icon icon, java.lang.Object data, boolean enabled)
          Gets the action associated with the specified command if it already exits.
static IdeAction get(int cmdId, java.lang.String cmdClass, java.lang.String name, java.lang.String sCategory, java.lang.Integer mnemonic, java.util.ResourceBundle bundle, java.lang.String key, java.lang.Object data, boolean enabled)
          Gets the action associated with the specified command if it already exits.
 java.lang.ClassLoader getClassloader()
           
 java.lang.String getCommand()
          Gets the action command.
 int getCommandId()
          Gets the action data.
static IdeAction getEnabled(int cmdId, java.lang.String name)
           
static IdeAction getEnabled(int cmdId, java.lang.String name, javax.swing.Icon icon)
           
static IdeAction getEnabled(int cmdId, java.lang.String name, java.util.ResourceBundle bundle)
           
static IdeAction getEnabled(int cmdId, java.lang.String name, java.lang.String category)
           
 LabelUpdater getLabelUpdater()
           
 java.lang.Object getValue(java.lang.String key)
          Gets the Object associated with the specified key.
Overriddden to handle the special case when a LabelUpdater may need to update the action's name and updateAction() has not been called yet.
static boolean isHandlerInProgress()
          Internal only.
 boolean isLocalAction()
          Returns true if this IdeAction is a local action, false if global.
static IdeAction newLocalAction(int cmdId, View view)
          Creates a new local IdeAction for the specified cmdId and for the specified View.
 IdeAction newLocalAction(View view)
          Creates a new local IdeAction for the specified View.
 void performAction()
           
 void performAction(Context context)
           
 void putValueDirectly(java.lang.String key, java.lang.Object value)
          This method has the same effect of calling putValue, except that it does not propagate the value to any linked IdeAction.
static void remove(int cmdId)
          Removes the action associated with the specified command, if it exists, from the IdeActionMap.
 void removeController(Controller controller)
          Removes the specified controller from the list of controllers that manage this IdeAction.
static void removeController(int actionID, Controller controller)
          Convenience method for looking up the specified IdeAction by its action ID and, if found, removing the specified controller from it.
 void setClassloader(java.lang.ClassLoader classloader)
           
 void setCommand(java.lang.String command)
          Sets the action command.
 void setCommandId(int commandId)
          Sets the command id data.
 void setLabelUpdater(LabelUpdater labelUpdater)
           
 void updateAction()
           
 void updateAction(Context context)
           
 
Methods inherited from class oracle.ide.controls.ToggleAction
addPropertyResolver, freezeKeyboard, getBooleanValue, getMenuWeight, getState, isActionMenu, isRadio, isToggle, listenForItemEvent, removePropertyResolver, setBooleanValue, setMenuWeight, setName, setState, toString
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INVOKED_FROM

public static final java.lang.String INVOKED_FROM
Key which may be set on the action to specify where it was invoked from. The value of this action property will be cleared when the action has been invoked.

Since:
11.1.1.0.0
See Also:
Constant Field Values

ORIGINAL_ACTION_NAME

public static final java.lang.String ORIGINAL_ACTION_NAME
Internal use only. Saves the original action's name.

See Also:
Constant Field Values

LAST_TOOLTIP_SUFFIX

public static final java.lang.String LAST_TOOLTIP_SUFFIX
Internal use only. May change without notice.

See Also:
Constant Field Values

CONTROLLER_HANDLING_UPDATE

public static final java.lang.String CONTROLLER_HANDLING_UPDATE
Internal use only. May change without notice.

See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG
Internal use only. May change without notice.

Constructor Detail

IdeAction

protected IdeAction()
Deprecated. Do not use. This constructor just throws an exception.

Internal only. Do not use.

Method Detail

get

public static IdeAction get(int cmdId,
                            java.lang.String cmdClass,
                            java.lang.String name)
Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
cmdClass - command class name
name - command label.
Returns:
an action.

get

public static IdeAction get(int cmdId,
                            java.lang.String cmdClass,
                            java.lang.String name,
                            ArrayResourceBundle bundle,
                            int key)
Deprecated. since 11.0. Declare actions in an extension manifest, or use one of the get methods that takes an Icon directly. Note for internal JDEVADF developers: The addin policy that icons must not be loaded during product startup is still in effect. You should avoid incurring the cost of icon loading during product startup by using the OracleIcons API.

Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
cmdClass - command class name
name - command label.
bundle - the resource bundle to be used to look up the icon resource pointed to by the key parameter.
key - resource key used to look up and load the icon resource.
Returns:
an action.

get

public static IdeAction get(int cmdId,
                            java.lang.String cmdClass,
                            java.lang.String name,
                            java.lang.String sCategory,
                            java.lang.Integer mnemonic,
                            javax.swing.Icon icon,
                            java.lang.Object data,
                            boolean enabled)
Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action. Use this method to group your actions by category. Your actions will appear in the Preferences | Accelerators panel under the specified category. This allows users to customize the action.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
cmdClass - command class name.
name - command label.
sCategory - the category this command belongs to. Categories group actions functionally. Existing categories include: Code Editor, Debug, Edit, File, Help, Model, Project, Run, Search, Tools, View, Window, Others.
mnemonic - mnemonic to appear in the command label.
icon - name the icon to display along side label.
data - user data associated with this action.
enabled - indicates whether this action is available.
Returns:
an action.

getEnabled

public static IdeAction getEnabled(int cmdId,
                                   java.lang.String name)

getEnabled

public static IdeAction getEnabled(int cmdId,
                                   java.lang.String name,
                                   java.lang.String category)

getEnabled

public static IdeAction getEnabled(int cmdId,
                                   java.lang.String name,
                                   javax.swing.Icon icon)

get

public static IdeAction get(int cmdId,
                            java.lang.String cmdClass,
                            java.lang.String name,
                            java.lang.String sCategory,
                            java.lang.Integer mnemonic,
                            ArrayResourceBundle bundle,
                            int key,
                            java.lang.Object data,
                            boolean enabled)
Deprecated. since 11.0. Declare actions in an extension manifest, or use one of the get methods that takes an Icon directly. Note for internal JDEVADF developers: The addin policy that icons must not be loaded during product startup is still in effect. You should avoid incurring the cost of icon loading during product startup by using the OracleIcons API.

Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action. Use this method to lazily load the icon resource. The icon loading will be delayed until the moment that is needed for display.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
cmdClass - command class name.
name - command label.
sCategory - the category this command belongs to. Categories group actions functionally. Existing categories include: Code Editor, Debug, Edit, File, Help, Model, Project, Run, Search, Tools, View, Window, Others.
mnemonic - mnemonic to appear in the command label.
bundle - the resource bundle to be used to look up the icon resource pointed to by the key parameter.
key - resource key used to look up and load the icon resource.
data - user data associated with this action.
enabled - indicates whether this action is available.
Returns:
an action.

get

public static IdeAction get(int cmdId,
                            java.lang.String cmdClass,
                            java.lang.String name,
                            java.lang.String sCategory,
                            java.lang.Integer mnemonic,
                            java.util.ResourceBundle bundle,
                            java.lang.String key,
                            java.lang.Object data,
                            boolean enabled)
Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action. Use this method to lazily load the icon resource. The icon loading will be delayed until the moment that is needed for display.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
cmdClass - command class name.
name - command label.
sCategory - the category this command belongs to. Categories group actions functionally. Existing categories include: Code Editor, Debug, Edit, File, Help, Model, Project, Run, Search, Tools, View, Window, Others.
mnemonic - mnemonic to appear in the command label.
bundle - the resource bundle to be used to look up the icon resource pointed to by the key parameter.
key - resource key used to look up and load the icon resource.
data - user data associated with this action.
enabled - indicates whether this action is available.
Returns:
an action.

getEnabled

public static IdeAction getEnabled(int cmdId,
                                   java.lang.String name,
                                   java.util.ResourceBundle bundle)

get

public static IdeAction get(int cmdId)
Gets the action associated with the specified command id if it already exists. Otherwise, creates a new action.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
Returns:
an action.

get

public static IdeAction get(int cmdId,
                            java.lang.String name,
                            java.lang.Integer mnemonic)
Gets the action associated with the specified command if it already exists. Otherwise, it creates a new action.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
name - command label.
mnemonic - mnemonic to appear in the command label.
Returns:
an action.

find

public static IdeAction find(int cmdId)
Finds the action associated with the specified command if it already exists.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.findOrCreateCmdID(String).
Returns:
the action if found, otherwise, null.

find

public static IdeAction find(java.lang.String commandName)
Finds the action associated with the specified command name if it already exists.

Parameters:
commandName -
Returns:
the action if found, otherwise, null.
Since:
11.0

remove

public static void remove(int cmdId)
Removes the action associated with the specified command, if it exists, from the IdeActionMap.

Parameters:
cmdId - command name identifier.

findGroup

public static IdeAction[] findGroup(java.lang.String groupName)
Finds the actions associated with the specified groupName.

Parameters:
groupName - identifies the group whose actions want to be found.
Returns:
an array of actions.

actionPerformed

public final void actionPerformed(java.awt.event.ActionEvent event)
This method is called when the user clicks on a menu or toolbar button associated with this action.

It first checks if this action has a preferred controller, if it does, that controller is used. Otherwise, the method gets the active view controller and tells it to handle the command. If no view is active, it delegates to the Ide controller.

If no controller handled the command, as a last resort, the command processor is used to handle the command. The command processor will use the action command class to instantiate a command and execute it.

Parameters:
event - an action event.

performAction

public final void performAction()
                         throws java.lang.Exception
Throws:
java.lang.Exception

performAction

public final void performAction(Context context)
                         throws java.lang.Exception
Throws:
java.lang.Exception

updateAction

public final void updateAction()

updateAction

public final void updateAction(Context context)

setLabelUpdater

public void setLabelUpdater(LabelUpdater labelUpdater)

getLabelUpdater

public LabelUpdater getLabelUpdater()

getValue

public java.lang.Object getValue(java.lang.String key)
Gets the Object associated with the specified key.
Overriddden to handle the special case when a LabelUpdater may need to update the action's name and updateAction() has not been called yet.

Specified by:
getValue in interface javax.swing.Action
Overrides:
getValue in class ToggleAction
Parameters:
key - a string containing the specified key
Returns:
the binding Object stored with this key; if there are no keys, it will return null
See Also:
Action.getValue(java.lang.String)

addController

public final void addController(Controller controller)
Adds the specified controller to the list of controllers that manage this IdeAction.


addControllerLast

public final void addControllerLast(Controller controller)

addController

public static void addController(int actionID,
                                 Controller controller)
Convenience method for looking up the specified IdeAction by its action ID and, if found, adding the specified controller to it.


removeController

public final void removeController(Controller controller)
Removes the specified controller from the list of controllers that manage this IdeAction.


removeController

public static void removeController(int actionID,
                                    Controller controller)
Convenience method for looking up the specified IdeAction by its action ID and, if found, removing the specified controller from it.


getCommand

public final java.lang.String getCommand()
Gets the action command.

Returns:
the action command.

setCommand

public final void setCommand(java.lang.String command)
Sets the action command.

Parameters:
command - the action command.

setCommandId

public final void setCommandId(int commandId)
Sets the command id data.

Parameters:
commandId - command id.

getCommandId

public final int getCommandId()
Gets the action data.

Returns:
the action data.

putValueDirectly

public final void putValueDirectly(java.lang.String key,
                                   java.lang.Object value)
This method has the same effect of calling putValue, except that it does not propagate the value to any linked IdeAction. This usually only matters in the case of a LocalAction, in which putValue assigns the value to both the LocalAction and its global IdeAction.


newLocalAction

public static IdeAction newLocalAction(int cmdId,
                                       View view)
Creates a new local IdeAction for the specified cmdId and for the specified View. If the cmdId does not exist, this method returns null. If the View is null, this method throws IllegalArgumentException.


newLocalAction

public IdeAction newLocalAction(View view)
Creates a new local IdeAction for the specified View. The local action is linked to this IdeAction. If the View is null, this method throws IllegalArgumentException.


isLocalAction

public final boolean isLocalAction()
Returns true if this IdeAction is a local action, false if global.


isHandlerInProgress

public static boolean isHandlerInProgress()
Internal only. Do not use.


setClassloader

public void setClassloader(java.lang.ClassLoader classloader)

getClassloader

public java.lang.ClassLoader getClassloader()

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.