Extension SDK

oracle.ide
Class IdeAction

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended byoracle.ide.controls.ToggleAction
          extended byoracle.ide.IdeAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, java.awt.event.ItemListener, java.io.Serializable
Direct Known Subclasses:
LocalAction

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:
oracle.ide.Command, oracle.ide.ide.Controller, Serialized Form

Field Summary
 
Fields inherited from class oracle.ide.controls.ToggleAction
ACCELERATOR, ACTION, BUTTON_GROUP_NAME, CATEGORY, CONTEXT_INDEPENDENT_NAME, DISABLED_ICON, HIDDEN, MNEMONIC, 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, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
protected IdeAction(IdeAction action)
          Copy constructor.
protected IdeAction(java.lang.String name, javax.swing.Icon icon)
          Constructor.
 
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.
static IdeAction create(int cmdId, java.lang.String cmdClass, java.lang.String name)
          Create an action without adding the newly created action to the action table.
static IdeAction create(int cmdId, java.lang.String cmdClass, java.lang.String name, java.lang.Integer mnemonic, javax.swing.KeyStroke accelerator, javax.swing.Icon icon, java.lang.Object data, boolean enabled)
          Deprecated. Use version which takes a category rather than an accelerator.
static IdeAction create(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)
          Gets the action associated with the specified command if it already exits.
static IdeAction create(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)
          Create an action without adding the newly created action to the action table.
static IdeAction find(int cmdId)
          Finds the action associated with the specified command if it already exists.
static IdeAction[] findGroup(java.lang.String groupName)
          Finds the actions associated with the specified groupName.
static IdeAction get(int cmdId, java.lang.String name, java.lang.Integer mnemonic)
          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)
          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)
          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.Integer mnemonic, javax.swing.KeyStroke accelerator, javax.swing.Icon icon, java.lang.Object data, boolean enabled)
          Deprecated. Use version which takes a category rather than an accelerator.
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)
          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, javax.swing.Icon icon, java.lang.Object data, boolean enabled)
          Gets the action associated with the specified command if it already exits.
 java.lang.String getCommand()
          Gets the action command.
 int getCommandId()
          Gets the action data.
 Context getContext()
          Gets the context associated with this action.
 Controller getController()
          Gets the action controller.
 java.lang.Object getValue(java.lang.String key)
           
protected  View getView()
          Return the currently active View.
 void putValue(java.lang.String key, java.lang.Object newValue)
           
static void remove(int cmdId)
          Removes the action associated with the specified command, if it exists, from the IdeActionMap.
 void setCommand(java.lang.String command)
          Sets the action command.
 void setCommandId(int commandId)
          Sets the command id data.
 void setContext(Context context)
          Sets the context associated with this action.
 void setController(Controller controller)
          Sets the action controller.
 
Methods inherited from class oracle.ide.controls.ToggleAction
getBooleanValue, getState, isRadio, isToggle, itemStateChanged, setBooleanValue, setState
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, isEnabled, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdeAction

protected IdeAction(java.lang.String name,
                    javax.swing.Icon icon)
Constructor.

Parameters:
name - the label to display in menu and/or toolbar button.
icon - the icon to display in menu and/or toolbar button.

IdeAction

protected IdeAction(IdeAction action)
Copy constructor.

Parameters:
action - action to copy.
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.newCmd().
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)
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.newCmd().
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.Integer mnemonic,
                            javax.swing.KeyStroke accelerator,
                            javax.swing.Icon icon,
                            java.lang.Object data,
                            boolean enabled)
Deprecated. Use version which takes a category rather than an accelerator.

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.newCmd().
cmdClass - command class name.
name - command label.
mnemonic - mnemonic to appear in the command label.
accelerator - accelerator that triggers this action.
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.

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.newCmd().
cmdClass - command class name.
name - command label.
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.

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)
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.newCmd().
cmdClass - command class name.
name - command label.
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 name,
                            java.lang.Integer mnemonic)
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.newCmd().
name - command label.
mnemonic - mnemonic to appear in the command label.
Returns:
an action.

create

public static IdeAction create(int cmdId,
                               java.lang.String cmdClass,
                               java.lang.String name)
Create an action without adding the newly created action to the action table. These method should be used by clients that want to associate the same command to multiple actions.

Parameters:
cmdId - command name identifier.
cmdClass - command class name
name - command label.
Returns:
an action.

create

public static IdeAction create(int cmdId,
                               java.lang.String cmdClass,
                               java.lang.String name,
                               java.lang.Integer mnemonic,
                               javax.swing.KeyStroke accelerator,
                               javax.swing.Icon icon,
                               java.lang.Object data,
                               boolean enabled)
Deprecated. Use version which takes a category rather than an accelerator.

Create an action without adding the newly created action to the action table. These method should be used by clients that want to associate the same command to multiple actions.

Parameters:
cmdId - command identifier. Must be unique. A unique identifier can be generated using the method Ide.newCmd().
cmdClass - command class name.
name - command label.
mnemonic - mnemonic to appear in the command label.
accelerator - accelerator that triggers this action.
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.

create

public static IdeAction create(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)
Create an action without adding the newly created action to the action table. These method should be used by clients that want to associate the same command to multiple actions. This method to groups 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.newCmd().
cmdClass - command class name.
name - command label.
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.

create

public static IdeAction create(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)
Gets the action associated with the specified command if it already exits. Otherwise, it creates a new action. These method should be used by clients that want to associate the same command to multiple actions. This method lazily loads 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.newCmd().
cmdClass - command class name.
name - command label.
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.

find

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

Parameters:
cmdId - command name identifier.
Returns:
the action if found, otherwise, null.

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 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.

getController

public final Controller getController()
Gets the action controller.

Returns:
the action controller.

setController

public final void setController(Controller controller)
Sets the action controller.


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.


setCommandId

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


getCommandId

public final int getCommandId()
Gets the action data.

Returns:
the action data.

getContext

public final Context getContext()
Gets the context associated with this action.

Returns:
the context.

setContext

public final void setContext(Context context)
Sets the context associated with this action.


putValue

public void putValue(java.lang.String key,
                     java.lang.Object newValue)

getValue

public java.lang.Object getValue(java.lang.String key)

getView

protected View getView()
Return the currently active View. This method is called from the actionPerformed() method to determine the active view whose controller will have the first try at handling the Command associated with this Action.


Extension SDK

 

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