|
Eclipse Platform 2.1 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.eclipse.jface.action.Action
The standard abstract implementation of an action.
Subclasses must implement the IAction.run method to carry out
the action's semantics.
| Fields inherited from interface org.eclipse.jface.action.IAction |
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, IMAGE, TEXT, TOOL_TIP_TEXT |
| Constructor Summary | |
protected |
Action()
Creates a new action with no text and no image. |
protected |
Action(String text)
Creates a new action with the given text and no image. |
protected |
Action(String text,
ImageDescriptor image)
Creates a new action with the given text and image. |
protected |
Action(String text,
int style)
Creates a new action with the given text and style. |
| Method Summary | |
void |
addPropertyChangeListener(IPropertyChangeListener listener)
Adds a property change listener to this action. |
static String |
convertAccelerator(int keyCode)
Converts an accelerator key code to a string representation. |
static int |
convertAccelerator(String acceleratorText)
Parses the given accelerator text, and converts it to an accelerator key code. |
static int |
findKeyCode(String token)
Maps a standard keyboard key name to an SWT key code. |
static String |
findKeyString(int keyCode)
Maps an SWT key code to a standard keyboard key name. |
static int |
findModifier(String token)
Maps standard keyboard modifier key names to the corresponding SWT modifier bit. |
static String |
findModifierString(int keyCode)
Returns a string representation of an SWT modifier bit (SWT.CTRL, SWT.ALT, SWT.SHIFT, and SWT.COMMAND). |
protected void |
firePropertyChange(PropertyChangeEvent event)
Notifies any property change listeners that a property has changed. |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Notifies any property change listeners that a property has changed. |
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. |
static String |
removeAcceleratorText(String text)
Convenience method for removing any optional accelerator text from the given string. |
void |
removePropertyChangeListener(IPropertyChangeListener listener)
Removes the given listener from this action. |
void |
run()
The default implementation of this IAction method
does nothing. |
void |
runWithEvent(Event event)
The default implementation of this IAction method
ignores the event argument, and simply calls run(). |
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 toolTipText)
Sets the tool tip text for this action. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected Action()
Configure the action later using the set methods.
protected Action(String text)
setText.text - the string used as the text for the action,
or null if there is no textsetText(java.lang.String)
protected Action(String text,
ImageDescriptor image)
setText and setImageDescriptor.text - the action's text, or null if there is no textimage - the action's image, or null if there is no imagesetText(java.lang.String),
setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
protected Action(String text,
int style)
text - the action's text, or null if there is no textstyle - one of AS_PUSH_BUTTON, AS_CHECK_BOX,
AS_DROP_DOWN_MENU, AS_RADIO_BUTTON, and
AS_UNSPECIFIED.| Method Detail |
public void addPropertyChangeListener(IPropertyChangeListener listener)
IActionaddPropertyChangeListener in interface IActionorg.eclipse.jface.action.IActionlistener - a property change listenerpublic static int convertAccelerator(String acceleratorText)
acceleratorText - the accelerator textpublic static String convertAccelerator(int keyCode)
keyCode - the key code to be translatedpublic static int findKeyCode(String token)
The following key names are known (case is ignored):
"BACKSPACE""TAB""RETURN""ENTER""ESC""ESCAPE""DELETE""SPACE""ARROW_UP", "ARROW_DOWN",
"ARROW_LEFT", and "ARROW_RIGHT""PAGE_UP" and "PAGE_DOWN""HOME""END""INSERT""F1", "F2" through "F12"token - the key name-1 if no match was foundSWTpublic static String findKeyString(int keyCode)
keyCode - the key code to be translatedSWTpublic static int findModifier(String token)
"CTRL", "SHIFT",
"ALT", and "COMMAND".
The given modifier key name is converted to upper case before comparison.token - the modifier key name0 if no match was foundSWTpublic static String findModifierString(int keyCode)
null if the key code
is not an SWT modifier bit.keyCode - the SWT modifier bit to be translatednull if the key code was not an SWT modifier bitSWT
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
firePropertyChange(PropertyChangeEvent) if there are.propertyName - the name of the property that has changedoldValue - the old value of the property, or null if nonenewValue - the new value of the property, or null if noneIPropertyChangeListener.propertyChange(org.eclipse.jface.util.PropertyChangeEvent)protected void firePropertyChange(PropertyChangeEvent event)
event - the property change eventIPropertyChangeListener.propertyChange(org.eclipse.jface.util.PropertyChangeEvent)public int getAccelerator()
IActionMenuItem.getAccelerator.getAccelerator in interface IActionorg.eclipse.jface.action.IActionMenuItem.getAccelerator()public String getActionDefinitionId()
IActiongetActionDefinitionId in interface IActionorg.eclipse.jface.action.IActionnull if nonepublic String getDescription()
IActiongetToolTipText().getDescription in interface IActionpublic ImageDescriptor getDisabledImageDescriptor()
IAction
This method is associated with the IMAGE property;
property change events are reported when its value changes.
getDisabledImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnull if this action has no imageIAction.IMAGEpublic HelpListener getHelpListener()
IActiongetHelpListener in interface IActionorg.eclipse.jface.action.IActionpublic ImageDescriptor getHoverImageDescriptor()
IAction
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.
getHoverImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnull if this action has no imageIAction.IMAGEpublic String getId()
IActionnull if it has
none.getId in interface IActionorg.eclipse.jface.action.IActionnull if nonepublic ImageDescriptor getImageDescriptor()
IAction
This method is associated with the IMAGE property;
property change events are reported when its value changes.
getImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnull if this action has no imageIAction.IMAGEpublic IMenuCreator getMenuCreator()
IActiongetMenuCreator in interface IActionorg.eclipse.jface.action.IActionnull if nonepublic int getStyle()
IActiongetStyle in interface IActionorg.eclipse.jface.action.IActionAS_PUSH_BUTTON, AS_CHECK_BOX,
AS_RADIO_BUTTON and AS_DROP_DOWN_MENU.public String getText()
IAction
This method is associated with the TEXT property;
property change events are reported when its value changes.
getText in interface IActionorg.eclipse.jface.action.IActionnull if noneIAction.TEXTpublic String getToolTipText()
IAction
This method is associated with the TOOL_TIP_TEXT property;
property change events are reported when its value changes.
getToolTipText in interface IActionorg.eclipse.jface.action.IActionnull if noneIAction.TOOL_TIP_TEXTpublic boolean isChecked()
IActionAS_CHECK_BOX or AS_RADIO_BUTTON.
This method is associated with the CHECKED property;
property change events are reported when its value changes.
isChecked in interface IActionorg.eclipse.jface.action.IActionIAction.CHECKEDpublic boolean isEnabled()
IAction
This method is associated with the ENABLED property;
property change events are reported when its value changes.
isEnabled in interface IActionorg.eclipse.jface.action.IActiontrue if enabled, and
false if disabledIAction.ENABLEDpublic static String removeAcceleratorText(String text)
'\t'.text - the textpublic void removePropertyChangeListener(IPropertyChangeListener listener)
IActionremovePropertyChangeListener in interface IActionorg.eclipse.jface.action.IActionlistener - a property change listenerpublic void run()
IAction method
does nothing. Subclasses should override this method
if they do not need information from the triggering event,
or override runWithEvent(Event) if they do.run in interface IActionpublic void runWithEvent(Event event)
IAction method
ignores the event argument, and simply calls run().
Subclasses should override this method if they need information
from the triggering event, or override run() if not.
NOTE: This is experimental API, which may change in the future.runWithEvent in interface IActionpublic void setActionDefinitionId(String id)
IActionsetActionDefinitionId in interface IActionorg.eclipse.jface.action.IActionid - the action definition idpublic void setChecked(boolean checked)
IActionAS_CHECK_BOX or AS_RADIO_BUTTON.
Fires a property change event for the CHECKED property
if the checked status actually changes as a consequence.
setChecked in interface IActionorg.eclipse.jface.action.IActionchecked - the new checked statusIAction.CHECKEDpublic void setDescription(String text)
IAction
Fires a property change event for the DESCRIPTION property
if the description actually changes as a consequence.
setDescription in interface IActionorg.eclipse.jface.action.IActiontext - the description, or null to clear the descriptionIAction.DESCRIPTIONpublic void setDisabledImageDescriptor(ImageDescriptor newImage)
IAction
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.
setDisabledImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnewImage - the image, or null if this
action should not have an imageIAction.IMAGEpublic void setEnabled(boolean enabled)
IAction
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.
setEnabled in interface IActionorg.eclipse.jface.action.IActionenabled - true to enable, and
false to disableIAction.ENABLEDpublic void setHelpListener(HelpListener listener)
IActionsetHelpListener in interface IActionorg.eclipse.jface.action.IActionlistener - a help listener for this actionpublic void setHoverImageDescriptor(ImageDescriptor newImage)
IAction
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.
setHoverImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnewImage - the image, or null if this
action should not have an imageIAction.IMAGEpublic void setId(String id)
IActionsetId in interface IActionorg.eclipse.jface.action.IActionid - the action idActionContributionItem,
IContributionItem.getId()public void setImageDescriptor(ImageDescriptor newImage)
IAction
Fires a property change event for the IMAGE property
if the image actually changes as a consequence.
setImageDescriptor in interface IActionorg.eclipse.jface.action.IActionnewImage - the image, or null if this
action should not have an imageIAction.IMAGEpublic void setMenuCreator(IMenuCreator creator)
Note that if this method is called, it overrides the check status.
setMenuCreator in interface IActioncreator - the menu creator, or null if nonepublic void setText(String text)
Fires a property change event for the TEXT property
if the text actually changes as a consequence.
setText in interface IActiontext - the text, or null if nonepublic void setToolTipText(String toolTipText)
Fires a property change event for the TOOL_TIP_TEXT property
if the tool tip text actually changes as a consequence.
setToolTipText in interface IActiontoolTipText - the tool tip text, or null if nonepublic void setAccelerator(int keycode)
IActionSWT.CTRL | 'Z'.
Use 0 for no accelerator.setAccelerator in interface IActionorg.eclipse.jface.action.IActionint - the keycode to be accepted.
|
Eclipse Platform 2.1 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||