Class TextNavigationAction
- All Implemented Interfaces:
IAction
- Direct Known Subclasses:
AbstractTextEditor.LineEndAction
,AbstractTextEditor.LineStartAction
Action
wrapper for text widget navigation and selection actions.- Since:
- 2.0
-
Field Summary
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, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
-
Constructor Summary
ConstructorDescriptionTextNavigationAction
(StyledText textWidget, int action) Creates a newTextNavigationAction
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a property change listener to this action.protected void
Sends a selection event with the current selection to all selection listeners of the action's text widgetprotected void
fireSelectionChanged
(Point oldSelection) Fires a selection event to all selection listener of the action's text widget if the current selection differs from the given selection.int
Returns the accelerator keycode for this action.Returns the action's description if it has one.Returns the disabled image for this action as an image descriptor.Returns a help listener for this action.Returns the hover image for this action as an image descriptor.Returns the image for this action as an image descriptor.Returns the menu creator for this action.int
getStyle()
Return this action's style.getText()
Returns the text for this action.protected StyledText
Returns the text widget this actions is bound to.Returns the tool tip text for this action.boolean
Returns the checked status of this action.boolean
Returns whether this action is enabled.void
Removes the given listener from this action.void
run()
The default implementation of thisIAction
method does nothing.void
runWithEvent
(Event event) The default implementation of thisIAction
method ignores the event argument, and simply callsrun()
.void
setAccelerator
(int keycode) Sets the accelerator keycode that this action maps to.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
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
Sets the text for this action.void
setToolTipText
(String text) Sets the tool tip text for this action.Methods inherited from class org.eclipse.jface.action.Action
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getActionDefinitionId, getId, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, setActionDefinitionId, setId
Methods inherited from class org.eclipse.jface.action.AbstractAction
firePropertyChange, firePropertyChange
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Constructor Details
-
TextNavigationAction
Creates a newTextNavigationAction
.- Parameters:
textWidget
- the text widgetaction
- the styled text widget action
-
-
Method Details
-
getTextWidget
Returns the text widget this actions is bound to.- Returns:
- returns the text widget this actions is bound to
-
run
public void run()Description copied from class:Action
The default implementation of thisIAction
method does nothing. Subclasses should override this method if they do not need information from the triggering event, or overriderunWithEvent(Event)
if they do. -
fireSelectionChanged
protected void fireSelectionChanged()Sends a selection event with the current selection to all selection listeners of the action's text widget- Since:
- 3.0
-
fireSelectionChanged
Fires a selection event to all selection listener of the action's text widget if the current selection differs from the given selection.- Parameters:
oldSelection
- the old selection- Since:
- 3.0
-
runWithEvent
Description copied from class:Action
The default implementation of thisIAction
method ignores the event argument, and simply callsrun()
. Subclasses should override this method if they need information from the triggering event, or overriderun()
if not.- Specified by:
runWithEvent
in interfaceIAction
- Overrides:
runWithEvent
in classAction
- Parameters:
event
- the SWT event which triggered this action being run- See Also:
-
addPropertyChangeListener
Description copied from interface:IAction
Adds a property change listener to this action. Has no effect if an identical listener is already registered.- Specified by:
addPropertyChangeListener
in interfaceIAction
- Overrides:
addPropertyChangeListener
in classAbstractAction
- Parameters:
listener
- a property change listener
-
getAccelerator
public int getAccelerator()Description copied from interface:IAction
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 inMenuItem.getAccelerator
.- Specified by:
getAccelerator
in interfaceIAction
- Overrides:
getAccelerator
in classAction
- Returns:
- the accelerator keycode
- See Also:
-
getDescription
Description copied from interface:IAction
Returns the action's description if it has one. Otherwise it returnsgetToolTipText()
.- Specified by:
getDescription
in interfaceIAction
- Overrides:
getDescription
in classAction
- Returns:
- a description for the action; may be
null
-
getDisabledImageDescriptor
Description copied from interface:IAction
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.- Specified by:
getDisabledImageDescriptor
in interfaceIAction
- Overrides:
getDisabledImageDescriptor
in classAction
- Returns:
- the image, or
null
if this action has no image - See Also:
-
getHelpListener
Description copied from interface:IAction
Returns a help listener for this action.- Specified by:
getHelpListener
in interfaceIAction
- Overrides:
getHelpListener
in classAction
- Returns:
- a help listener for this action
-
getHoverImageDescriptor
Description copied from interface:IAction
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.- Specified by:
getHoverImageDescriptor
in interfaceIAction
- Overrides:
getHoverImageDescriptor
in classAction
- Returns:
- the image, or
null
if this action has no image - See Also:
-
getImageDescriptor
Description copied from interface:IAction
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.- Specified by:
getImageDescriptor
in interfaceIAction
- Overrides:
getImageDescriptor
in classAction
- Returns:
- the image, or
null
if this action has no image - See Also:
-
getMenuCreator
Description copied from interface:IAction
Returns the menu creator for this action.- Specified by:
getMenuCreator
in interfaceIAction
- Overrides:
getMenuCreator
in classAction
- Returns:
- the menu creator, or
null
if none
-
getStyle
public int getStyle()Description copied from interface:IAction
Return this action's style. -
getText
Description copied from interface:IAction
Returns the text for this action.This method is associated with the
TEXT
property; property change events are reported when its value changes. -
getToolTipText
Description copied from interface:IAction
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.- Specified by:
getToolTipText
in interfaceIAction
- Overrides:
getToolTipText
in classAction
- Returns:
- the tool tip text, or
null
if none - See Also:
-
isChecked
public boolean isChecked()Description copied from interface:IAction
Returns the checked status of this action. Applicable only if the style isAS_CHECK_BOX
orAS_RADIO_BUTTON
.This method is associated with the
CHECKED
property; property change events are reported when its value changes. -
isEnabled
public boolean isEnabled()Description copied from interface:IAction
Returns whether this action is enabled.This method is associated with the
ENABLED
property; property change events are reported when its value changes. -
removePropertyChangeListener
Description copied from interface:IAction
Removes the given listener from this action. Has no effect if an identical listener is not registered.- Specified by:
removePropertyChangeListener
in interfaceIAction
- Overrides:
removePropertyChangeListener
in classAbstractAction
- Parameters:
listener
- a property change listener
-
setAccelerator
public void setAccelerator(int keycode) Description copied from interface:IAction
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
andIWorkbenchContextSupport
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.- Specified by:
setAccelerator
in interfaceIAction
- Overrides:
setAccelerator
in classAction
- Parameters:
keycode
- the keycode to be accepted.
-
setChecked
public void setChecked(boolean checked) Description copied from interface:IAction
Sets the checked status of this action. Applicable for the stylesAS_CHECK_BOX
orAS_RADIO_BUTTON
.Fires a property change event for the
CHECKED
property if the checked status actually changes as a consequence.- Specified by:
setChecked
in interfaceIAction
- Overrides:
setChecked
in classAction
- Parameters:
checked
- the new checked status- See Also:
-
setDescription
Description copied from interface:IAction
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.- Specified by:
setDescription
in interfaceIAction
- Overrides:
setDescription
in classAction
- Parameters:
text
- the description, ornull
to clear the description- See Also:
-
setDisabledImageDescriptor
Description copied from interface:IAction
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.- Specified by:
setDisabledImageDescriptor
in interfaceIAction
- Overrides:
setDisabledImageDescriptor
in classAction
- Parameters:
newImage
- the image, ornull
if this action should not have an image- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:IAction
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.- Specified by:
setEnabled
in interfaceIAction
- Overrides:
setEnabled
in classAction
- Parameters:
enabled
-true
to enable, andfalse
to disable- See Also:
-
setHelpListener
Description copied from interface:IAction
Sets a help listener for this action.- Specified by:
setHelpListener
in interfaceIAction
- Overrides:
setHelpListener
in classAction
- Parameters:
listener
- a help listener for this action
-
setHoverImageDescriptor
Description copied from interface:IAction
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.- Specified by:
setHoverImageDescriptor
in interfaceIAction
- Overrides:
setHoverImageDescriptor
in classAction
- Parameters:
newImage
- the image, ornull
if this action should not have an image- See Also:
-
setImageDescriptor
Description copied from interface:IAction
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.Note: This operation is a hint and is not supported in all contexts on platforms that do not have this concept (for example, Windows NT). Furthermore, some platforms (such as GTK), cannot display both a check box and an image at the same time. Instead, they hide the image and display the check box.
- Specified by:
setImageDescriptor
in interfaceIAction
- Overrides:
setImageDescriptor
in classAction
- Parameters:
newImage
- the image, ornull
if this action should not have an image- See Also:
-
setMenuCreator
Description copied from class:Action
Sets the menu creator for this action.Note that if this method is called, it overrides the check status.
- Specified by:
setMenuCreator
in interfaceIAction
- Overrides:
setMenuCreator
in classAction
- Parameters:
creator
- the menu creator, ornull
if none
-
setText
Description copied from interface:IAction
Sets the text for this action.An accelerator is identified by the last index of a '\t' character. If there are no '\t' characters, then it is identified by the last index of an '@' character. If neither, then there is no accelerator text. Note that if you want to insert an '@' character into the text (but no accelerator), then you can simply insert an '@' or a '\t' at the end of the text.
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
Description copied from class:Action
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.- Specified by:
setToolTipText
in interfaceIAction
- Overrides:
setToolTipText
in classAction
- Parameters:
text
- the tool tip text, ornull
if none- See Also:
-