|
|||||||||
| Home >> All >> org >> eclipse >> ui >> [ actions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.ui.actions
Class BaseSelectionListenerAction

java.lang.Objectorg.eclipse.jface.action.Action
org.eclipse.ui.actions.BaseSelectionListenerAction
- All Implemented Interfaces:
- org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelectionChangedListener
- Direct Known Subclasses:
- ExportResourcesAction, ImportResourcesAction, SelectionListenerAction
- public abstract class BaseSelectionListenerAction
- extends org.eclipse.jface.action.Action
- implements org.eclipse.jface.viewers.ISelectionChangedListener
- extends org.eclipse.jface.action.Action
The abstract superclass for actions that listen to selection change events.
This implementation tracks the current selection (see
getStructuredSelection) and provides a convenient place to
monitor selection changes that could affect the availability of the action.
Subclasses must implement the following IAction method:
run- to do the action's work
Subclasses may extend the updateSelection method to update
the action determine its availability based on the current selection.
The object instantiating the subclass is responsible for registering the instance with a selection provider. Alternatively, the object can notify the subclass instance directly of a selection change using the methods:
selectionChanged(IStructuredSelection)- passing the selectionselectionChanged(ISelectionChangedEvent)- passing the selection change event
- Since:
- 3.0
| Field Summary | |
private org.eclipse.jface.viewers.IStructuredSelection |
deferredSelection
The deferred selection. |
private boolean |
running
Running flag: true iff the action is running. |
private org.eclipse.jface.viewers.IStructuredSelection |
selection
The current selection. |
| Fields inherited from class org.eclipse.jface.action.Action |
|
| 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, RESULT, TEXT, TOOL_TIP_TEXT |
| Constructor Summary | |
protected |
BaseSelectionListenerAction(java.lang.String text)
Creates a new action with the given text. |
| Method Summary | |
protected void |
clearCache()
Clears any cached state associated with the selection. |
org.eclipse.jface.viewers.IStructuredSelection |
getStructuredSelection()
Returns the current structured selection in the workbench, or an empty selection if nothing is selected or if selection does not include objects (for example, raw text). |
void |
runWithEvent(org.eclipse.swt.widgets.Event event)
The default implementation of this IAction method
ignores the event argument, and simply calls run(). |
void |
selectionChanged(org.eclipse.jface.viewers.IStructuredSelection selection)
Notifies this action that the given structured selection has changed. |
void |
selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
The BaseSelectionListenerAction implementation of this
ISelectionChangedListener method calls
selectionChanged(IStructuredSelection) assuming the selection is
a structured one. |
protected boolean |
updateSelection(org.eclipse.jface.viewers.IStructuredSelection selection)
Updates this action in response to the given selection. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
selection
private org.eclipse.jface.viewers.IStructuredSelection selection
- The current selection.
running
private boolean running
- Running flag:
trueiff the action is running.
deferredSelection
private org.eclipse.jface.viewers.IStructuredSelection deferredSelection
- The deferred selection. Any selection change that occurs
while the action is running is held here until the run is complete.
| Constructor Detail |
BaseSelectionListenerAction
protected BaseSelectionListenerAction(java.lang.String text)
- Creates a new action with the given text.
| Method Detail |
clearCache
protected void clearCache()
- Clears any cached state associated with the selection.
Called when the selection changes.
The
BaseSelectionListenerActionimplementation of this method does nothing. Subclasses may override.
getStructuredSelection
public org.eclipse.jface.viewers.IStructuredSelection getStructuredSelection()
- Returns the current structured selection in the workbench, or an empty
selection if nothing is selected or if selection does not include
objects (for example, raw text).
selectionChanged
public final void selectionChanged(org.eclipse.jface.viewers.IStructuredSelection selection)
- Notifies this action that the given structured selection has changed.
The
BaseSelectionListenerActionimplementation of this method records the given selection for future reference and callsupdateSelection, updating the enable state of this action based on the outcome. Subclasses should overrideupdateSelectionto react to selection changes.
selectionChanged
public final void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
- The
BaseSelectionListenerActionimplementation of thisISelectionChangedListenermethod callsselectionChanged(IStructuredSelection)assuming the selection is a structured one. Subclasses should override theupdateSelectionmethod to react to selection changes.- Specified by:
selectionChangedin interfaceorg.eclipse.jface.viewers.ISelectionChangedListener
updateSelection
protected boolean updateSelection(org.eclipse.jface.viewers.IStructuredSelection selection)
- Updates this action in response to the given selection.
The
BaseSelectionListenerActionimplementation of this method returnstrue. Subclasses may extend to react to selection changes; however, if the super method returnsfalse, the overriding method must also returnfalse.
runWithEvent
public void runWithEvent(org.eclipse.swt.widgets.Event event)
- Description copied from class:
org.eclipse.jface.action.Action - The default implementation of this
IActionmethod 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:
runWithEventin interfaceorg.eclipse.jface.action.IAction
|
|||||||||
| Home >> All >> org >> eclipse >> ui >> [ actions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC