Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.action
Interface IAction  view IAction download IAction.java

All Known Implementing Classes:
Action

public interface IAction

An action represents the non-UI side of a command which can be triggered by the end user. Actions are typically associated with buttons, menu items, and items in tool bars. The controls for a command are built by some container, which furnished the context where these controls appear and configures them with data from properties declared by the action. When the end user triggers the command via its control, the action's run method is invoked to do the real work.

Actions support a predefined set of properties (and possibly others as well). Clients of an action may register property change listeners so that they get notified whenever the value of a property changes.

Clients should subclass the abstract base class Action to define concrete actions rather than implementing IAction from scratch.

This interface exists only to define the API for actions. It is not intended to be implemented by clients.


Field Summary
static int AS_CHECK_BOX
          Action style constant (value 2) indicating action is a check box (or a toggle button).
static int AS_DROP_DOWN_MENU
          Action style constant (value 4) indicating action is a drop down menu.
static int AS_PUSH_BUTTON
          Action style constant (value 1) indicating action is a simple push button.
static int AS_RADIO_BUTTON
          Action style constant (value 8) indicating action is a radio button.
static int AS_UNSPECIFIED
          Action style constant (value 0) indicating action style is not specified yet.
static java.lang.String CHECKED
          Property name of an action's checked status (value "checked").
static java.lang.String DESCRIPTION
          Property name of an action's description (value "description").
static java.lang.String ENABLED
          Property name of an action's enabled state (value "enabled").
static java.lang.String IMAGE
          Property name of an action's image (value "image").
static java.lang.String RESULT
          Property name of an action's success/fail result (value "result").
static java.lang.String TEXT
          Property name of an action's text (value "text").
static java.lang.String TOOL_TIP_TEXT
          Property name of an action's tooltip text (value "toolTipText").
 
Method Summary
 void addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
          Adds a property change listener to this action.
 int getAccelerator()
          Returns the accelerator keycode for this action.
 java.lang.String getActionDefinitionId()
          Returns the action definition id of this action.
 java.lang.String getDescription()
          Returns the action's description if it has one.
 org.eclipse.jface.resource.ImageDescriptor getDisabledImageDescriptor()
          Returns the disabled image for this action as an image descriptor.
 org.eclipse.swt.events.HelpListener getHelpListener()
          Returns a help listener for this action.
 org.eclipse.jface.resource.ImageDescriptor getHoverImageDescriptor()
          Returns the hover image for this action as an image descriptor.
 java.lang.String getId()
          Returns a unique identifier for this action, or null if it has none.
 org.eclipse.jface.resource.ImageDescriptor getImageDescriptor()
          Returns the image for this action as an image descriptor.
 IMenuCreator getMenuCreator()
          Returns the menu creator for this action.
 int getStyle()
          Return this action's style.
 java.lang.String getText()
          Returns the text for this action.
 java.lang.String getToolTipText()
          Returns the tool tip text for this action.
 boolean isChecked()
          Returns the checked status of this action.
 boolean isEnabled()
          Returns whether this action is enabled.
 void removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
          Removes the given listener from this action.
 void run()
          Runs this action.
 void runWithEvent(org.eclipse.swt.widgets.Event event)
          Runs this action, passing the triggering SWT event.
 void setAccelerator(int keycode)
           Sets the accelerator keycode that this action maps to.
 void setActionDefinitionId(java.lang.String id)
          Sets the action definition id of this action.
 void setChecked(boolean checked)
          Sets the checked status of this action.
 void setDescription(java.lang.String text)
          Sets this action's description.
 void setDisabledImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
          Sets the disabled image for this action, as an image descriptor.
 void setEnabled(boolean enabled)
          Sets the enabled state of this action.
 void setHelpListener(org.eclipse.swt.events.HelpListener listener)
          Sets a help listener for this action.
 void setHoverImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
          Sets the hover image for this action, as an image descriptor.
 void setId(java.lang.String id)
          Sets the unique identifier for this action.
 void setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
          Sets the image for this action, as an image descriptor.
 void setMenuCreator(IMenuCreator creator)
          Sets the menu creator for this action.
 void setText(java.lang.String text)
          Sets the text for this action.
 void setToolTipText(java.lang.String text)
          Sets the tool tip text for this action.
 

Field Detail

AS_UNSPECIFIED

public static final int AS_UNSPECIFIED
Action style constant (value 0) indicating action style is not specified yet. By default, the action will assume a push button style. If setChecked is called, then the style will change to a check box, or if setMenuCreator is called, then the style will change to a drop down menu.

Since:
2.1
See Also:
Constant Field Values

AS_PUSH_BUTTON

public static final int AS_PUSH_BUTTON
Action style constant (value 1) indicating action is a simple push button.

See Also:
Constant Field Values

AS_CHECK_BOX

public static final int AS_CHECK_BOX
Action style constant (value 2) indicating action is a check box (or a toggle button).

See Also:
Constant Field Values

AS_DROP_DOWN_MENU

public static final int AS_DROP_DOWN_MENU
Action style constant (value 4) indicating action is a drop down menu.

See Also:
Constant Field Values

AS_RADIO_BUTTON

public static final int AS_RADIO_BUTTON
Action style constant (value 8) indicating action is a radio button.

Since:
2.1
See Also:
Constant Field Values

TEXT

public static final java.lang.String TEXT
Property name of an action's text (value "text").

See Also:
Constant Field Values

ENABLED

public static final java.lang.String ENABLED
Property name of an action's enabled state (value "enabled").

See Also:
Constant Field Values

IMAGE

public static final java.lang.String IMAGE
Property name of an action's image (value "image").

See Also:
Constant Field Values

TOOL_TIP_TEXT

public static final java.lang.String TOOL_TIP_TEXT
Property name of an action's tooltip text (value "toolTipText").

See Also:
Constant Field Values

DESCRIPTION

public static final java.lang.String DESCRIPTION
Property name of an action's description (value "description"). Typically the description is shown as a (longer) help text in the status line.

See Also:
Constant Field Values

CHECKED

public static final java.lang.String CHECKED
Property name of an action's checked status (value "checked"). Applicable when the style is AS_CHECK_BOX or AS_RADIO_BUTTON.

See Also:
Constant Field Values

RESULT

public static final java.lang.String RESULT
Property name of an action's success/fail result (value "result"). The values are Boolean.TRUE if running the action succeeded and Boolean.FALSE if running the action failed or did not complete.

Not all actions report whether they succeed or fail. This property is provided for use by actions that may be invoked by clients that can take advantage of this information when present (for example, actions used in cheat sheets). Clients should always assume that running the action succeeded in the absence of notification to the contrary.

Since:
3.0
See Also:
Constant Field Values
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Adds a property change listener to this action. Has no effect if an identical listener is already registered.


getAccelerator

public int getAccelerator()
Returns the accelerator keycode for this action. The result is the bit-wise OR of zero or more modifier masks and a key, as explained in MenuItem.getAccelerator.


getActionDefinitionId

public java.lang.String getActionDefinitionId()
Returns the action definition id of this action.

Since:
2.0

getDescription

public java.lang.String getDescription()
Returns the action's description if it has one. Otherwise it returns getToolTipText().


getDisabledImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getDisabledImageDescriptor()
Returns the disabled image for this action as an image descriptor.

This method is associated with the IMAGE property; property change events are reported when its value changes.


getHelpListener

public org.eclipse.swt.events.HelpListener getHelpListener()
Returns a help listener for this action.


getHoverImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getHoverImageDescriptor()
Returns the hover image for this action as an image descriptor.

Hover images will be used on platforms that support changing the image when the user hovers over the item. This method is associated with the IMAGE property; property change events are reported when its value changes.


getId

public java.lang.String getId()
Returns a unique identifier for this action, or null if it has none.


getImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor()
Returns the image for this action as an image descriptor.

This method is associated with the IMAGE property; property change events are reported when its value changes.


getMenuCreator

public IMenuCreator getMenuCreator()
Returns the menu creator for this action.


getStyle

public int getStyle()
Return this action's style.


getText

public java.lang.String getText()
Returns the text for this action.

This method is associated with the TEXT property; property change events are reported when its value changes.


getToolTipText

public java.lang.String getToolTipText()
Returns the tool tip text for this action.

This method is associated with the TOOL_TIP_TEXT property; property change events are reported when its value changes.


isChecked

public boolean isChecked()
Returns the checked status of this action. Applicable only if the style is AS_CHECK_BOX or AS_RADIO_BUTTON.

This method is associated with the CHECKED property; property change events are reported when its value changes.


isEnabled

public boolean isEnabled()
Returns whether this action is enabled.

This method is associated with the ENABLED property; property change events are reported when its value changes.


removePropertyChangeListener

public void removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Removes the given listener from this action. Has no effect if an identical listener is not registered.


run

public void run()
Runs this action. Each action implementation must define the steps needed to carry out this action. The default implementation of this method in Action does nothing.


runWithEvent

public void runWithEvent(org.eclipse.swt.widgets.Event event)
Runs this action, passing the triggering SWT event. As of 2.0, ActionContributionItem calls this method instead of run(). The default implementation of this method in Action simply calls run() for backwards compatibility.

Since:
2.0

setActionDefinitionId

public void setActionDefinitionId(java.lang.String id)
Sets the action definition id of this action.

Since:
2.0

setChecked

public void setChecked(boolean checked)
Sets the checked status of this action. Applicable for the styles AS_CHECK_BOX or AS_RADIO_BUTTON.

Fires a property change event for the CHECKED property if the checked status actually changes as a consequence.


setDescription

public void setDescription(java.lang.String text)
Sets this action's description. Typically the description is shown as a (longer) help text in the status line.

Fires a property change event for the DESCRIPTION property if the description actually changes as a consequence.


setDisabledImageDescriptor

public void setDisabledImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
Sets the disabled image for this action, as an image descriptor.

Disabled images will be used on platforms that support changing the image when the item is disabled.Fires a property change event for the IMAGE property if the image actually changes as a consequence.


setEnabled

public void setEnabled(boolean enabled)
Sets the enabled state of this action.

When an action is in the enabled state, the control associated with it is active; triggering it will end up inkoking this action's run method.

Fires a property change event for the ENABLED property if the enabled state actually changes as a consequence.


setHelpListener

public void setHelpListener(org.eclipse.swt.events.HelpListener listener)
Sets a help listener for this action.


setHoverImageDescriptor

public void setHoverImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
Sets the hover image for this action, as an image descriptor.

Hover images will be used on platforms that support changing the image when the user hovers over the item.Fires a property change event for the IMAGE property if the image actually changes as a consequence.


setId

public void setId(java.lang.String id)
Sets the unique identifier for this action. This is used to identify actions when added to a contribution manager. It should be set when the action is created. It should not be modified once the action is part of an action contribution item.


setImageDescriptor

public void setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor newImage)
Sets the image for this action, as an image descriptor.

Fires a property change event for the IMAGE property if the image actually changes as a consequence.


setMenuCreator

public void setMenuCreator(IMenuCreator creator)
Sets the menu creator for this action. Applicable for style AS_DROP_DOWN_MENU.


setText

public void setText(java.lang.String text)
Sets the text for this action.

An accelerator specification may follow the actual text, separated from it by an '@' or a '\t' character. An accelerator specification consists of zero or more modifier tokens followed by a key code token. The tokens are separated by a '+' character.

Fires a property change event for the TEXT property if the text actually changes as a consequence.


setToolTipText

public void setToolTipText(java.lang.String text)
Sets the tool tip text for this action.

Fires a property change event for the TOOL_TIP_TEXT property if the tool tip text actually changes as a consequence.


setAccelerator

public void setAccelerator(int keycode)

Sets the accelerator keycode that this action maps to. This is a bitwise OR of zero or more SWT key modifier masks (i.e. SWT.CTRL or SWT.ALT) and a character code. For example, for Ctrl+Z, use SWT.CTRL | 'Z'. Use 0 for no accelerator.

This method should no longer be used for actions in the Eclipse workbench. IWorkbenchCommandSupport and IWorkbenchContextSupport provide all the functionality required for key bindings. If you set an accelerator using this method, then it will not work in the workbench if it conflicts any existing key binding, or if there is a different key binding defined for this action's definition id. The definition id should be used instead -- referring to the command in the workbench from which the key binding should be retrieved.