public abstract class SelectionListenerAction extends BaseSelectionListenerAction
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 eventAS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
Modifier | Constructor and Description |
---|---|
protected |
SelectionListenerAction(String text)
Creates a new action with the given text.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearCache()
The
SelectionListenerAction implementation of this
BaseSelectionListenerAction method clears the cached
resources and non-resources. |
protected List<?> |
getSelectedNonResources()
Returns the elements in the current selection that are not
IResource s. |
protected List<? extends IResource> |
getSelectedResources()
Returns the elements in the current selection that are
IResource s. |
protected boolean |
resourceIsType(IResource resource,
int resourceMask)
Returns whether the type of the given resource is among those in the
given resource type mask.
|
protected boolean |
selectionIsOfType(int resourceMask)
Returns whether the current selection consists entirely of resources
whose types are among those in the given resource type mask.
|
getStructuredSelection, runWithEvent, selectionChanged, selectionChanged, updateSelection
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, run, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
protected SelectionListenerAction(String text)
text
- the string used as the text for the action, or
null
if there is no textprotected void clearCache()
SelectionListenerAction
implementation of this
BaseSelectionListenerAction
method clears the cached
resources and non-resources.clearCache
in class BaseSelectionListenerAction
protected List<?> getSelectedNonResources()
IResource
s.Object
)protected List<? extends IResource> getSelectedResources()
IResource
s.IResource
)protected boolean resourceIsType(IResource resource, int resourceMask)
resource
- the resourceresourceMask
- a bitwise OR of resource types: IResource
.{FILE
,
FOLDER
, PROJECT
,
ROOT
}true
if the resource type matches, and
false
otherwiseIResource
protected boolean selectionIsOfType(int resourceMask)
resourceMask
- a bitwise OR of resource types: IResource
.{FILE
,
FOLDER
, PROJECT
,
ROOT
}true
if all resources in the current selection are
of the specified types or if the current selection is empty, and
false
if some elements are resources of a
different type or not resourcesIResource
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.