|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
Action
Field Summary | |
static int |
AS_CHECK_BOX
Action style constant (value 2 ) indicating action is
a check box. |
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 String |
CHECKED
Property name of an action's checked status (value "checked" ). |
static String |
DESCRIPTION
Property name of an action's description (value "description" ). |
static String |
ENABLED
Property name of an action's enabled state (value "enabled" ). |
static String |
IMAGE
Property name of an action's image (value "image" ). |
static String |
TEXT
Property name of an action's text (value "text" ). |
static String |
TOOL_TIP_TEXT
Property name of an action's tooltip text (value "toolTipText" ). |
Method Summary | |
void |
addPropertyChangeListener(IPropertyChangeListener listener)
Adds a property change listener to this action. |
int |
getAccelerator()
Returns the accelerator keycode for this action. |
String |
getActionDefinitionId()
Returns the action definition id of this action. |
String |
getDescription()
Returns the action's description if it has one. |
ImageDescriptor |
getDisabledImageDescriptor()
Returns the disabled image for this action as an image descriptor. |
HelpListener |
getHelpListener()
Returns a help listener for this action. |
ImageDescriptor |
getHoverImageDescriptor()
Returns the hover image for this action as an image descriptor. |
String |
getId()
Returns a unique identifier for this action, or null if it has
none. |
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. |
String |
getText()
Returns the text for this action. |
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(IPropertyChangeListener listener)
Removes the given listener from this action. |
void |
run()
Runs this action. |
void |
runWithEvent(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(String id)
Sets the action definition id of this action. |
void |
setChecked(boolean checked)
Sets the checked status of this action. |
void |
setDescription(String text)
Sets this action's description. |
void |
setDisabledImageDescriptor(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(HelpListener listener)
Sets a help listener for this action. |
void |
setHoverImageDescriptor(ImageDescriptor newImage)
Sets the hover image for this action, as an image descriptor. |
void |
setId(String id)
Sets the unique identifier for this action. |
void |
setImageDescriptor(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(String text)
Sets the text for this action. |
void |
setToolTipText(String text)
Sets the tool tip text for this action. |
Field Detail |
public static final int AS_PUSH_BUTTON
1
) indicating action is
a simple push button.
public static final int AS_CHECK_BOX
2
) indicating action is
a check box.
public static final int AS_DROP_DOWN_MENU
4
) indicating action is
a drop down menu.
public static final String TEXT
"text"
).
public static final String ENABLED
"enabled"
).
public static final String IMAGE
"image"
).
public static final String TOOL_TIP_TEXT
"toolTipText"
).
public static final String DESCRIPTION
"description"
).
Typically the description is shown as a (longer) help text in the status line.
public static final String CHECKED
"checked"
).
Method Detail |
public void addPropertyChangeListener(IPropertyChangeListener listener)
listener
- a property change listenerpublic int getAccelerator()
MenuItem.getAccelerator
.
MenuItem.getAccelerator()
public String getActionDefinitionId()
null
if nonepublic String getDescription()
getToolTipText()
.
public ImageDescriptor getDisabledImageDescriptor()
This method is associated with the IMAGE
property;
property change events are reported when its value changes.
null
if this action has no imageIMAGE
public HelpListener getHelpListener()
public ImageDescriptor getHoverImageDescriptor()
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.
null
if this action has no imageIMAGE
public String getId()
null
if it has
none.
null
if nonepublic ImageDescriptor getImageDescriptor()
This method is associated with the IMAGE
property;
property change events are reported when its value changes.
null
if this action has no imageIMAGE
public IMenuCreator getMenuCreator()
null
if nonepublic int getStyle()
AS_PUSH_BUTTON
, AS_CHECK_BOX
,
and AS_DROP_DOWN
.public String getText()
This method is associated with the TEXT
property;
property change events are reported when its value changes.
null
if noneTEXT
public String getToolTipText()
This method is associated with the TOOL_TIP_TEXT
property;
property change events are reported when its value changes.
null
if noneTOOL_TIP_TEXT
public boolean isChecked()
This method is associated with the CHECKED
property;
property change events are reported when its value changes.
CHECKED
public boolean isEnabled()
This method is associated with the ENABLED
property;
property change events are reported when its value changes.
true
if enabled, and
false
if disabledENABLED
public void removePropertyChangeListener(IPropertyChangeListener listener)
listener
- a property change listenerpublic void run()
Action
does nothing.
public void runWithEvent(Event event)
ActionContributionItem
calls this method
instead of run()
.
The default implementation of this method in Action
simply calls run()
for backwards compatibility.
NOTE: This is experimental API, which may change in the future.
event
- the SWT event which triggered this action being runpublic void setActionDefinitionId(String id)
id
- the action definition idpublic void setChecked(boolean checked)
Fires a property change event for the CHECKED
property
if the checked status actually changes as a consequence.
checked
- the new checked statusCHECKED
public void setDescription(String text)
Fires a property change event for the DESCRIPTION
property
if the description actually changes as a consequence.
text
- the description, or null
to clear the descriptionDESCRIPTION
public void setDisabledImageDescriptor(ImageDescriptor newImage)
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.
newImage
- the image, or null
if this
action should not have an imageIMAGE
public void setEnabled(boolean enabled)
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.
enabled
- true
to enable, and
false
to disableENABLED
public void setHelpListener(HelpListener listener)
listener
- a help listener for this actionpublic void setHoverImageDescriptor(ImageDescriptor newImage)
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.
newImage
- the image, or null
if this
action should not have an imageIMAGE
public void setId(String id)
id
- the action idActionContributionItem
,
IContributionItem.getId()
public void setImageDescriptor(ImageDescriptor newImage)
Fires a property change event for the IMAGE
property
if the image actually changes as a consequence.
newImage
- the image, or null
if this
action should not have an imageIMAGE
public void setMenuCreator(IMenuCreator creator)
Note that if this method is called, it overrides the check status.
creator
- the menu creator, or null
if nonepublic void setText(String text)
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.
text
- the text, or null
if noneTEXT
,
Action.findModifier(java.lang.String)
,
Action.findKeyCode(java.lang.String)
public void setToolTipText(String text)
Fires a property change event for the TOOL_TIP_TEXT
property
if the tool tip text actually changes as a consequence.
text
- the tool tip text, or null
if noneTOOL_TIP_TEXT
public void setAccelerator(int keycode)
SWT.CTRL | 'Z'
.
Use 0 for no accelerator.
|
Eclipse Platform 2.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |