Class SelectionAction

All Implemented Interfaces:
Disposable, UpdateAction, IAction
Direct Known Subclasses:
AlignmentAction, DeleteAction, DirectEditAction, MatchSizeAction, PasteTemplateAction

public abstract class SelectionAction extends WorkbenchPartAction
Superclass for an action needing the current selection.
  • Constructor Details

    • SelectionAction

      protected SelectionAction(IWorkbenchPart part, int style)
      Creates a SelectionAction and associates it with the given editor.
      Parameters:
      part - The workbench part associated with this action
      style - the style for this action
    • SelectionAction

      protected SelectionAction(IWorkbenchPart part)
      Creates a SelectionAction and associates it with the given workbench part.
      Parameters:
      part - the workbench part
  • Method Details

    • dispose

      public void dispose()
      Description copied from class: WorkbenchPartAction
      Disposes the action when it is no longer needed.
      Specified by:
      dispose in interface Disposable
      Overrides:
      dispose in class WorkbenchPartAction
      See Also:
    • getSelectedObjects

      protected List<Object> getSelectedObjects()
      Returns a List<EditPart containing the currently selected objects. The set method is supported but the add, addAll, remove removeAll methods are not. Changes to this list modify the internal selection.
      Returns:
      A List containing the currently selected objects.
    • getSelectedEditParts

      protected final List<EditPart> getSelectedEditParts()
      Returns a List<EditPart containing the currently selected EditParts. If elements not of type EditPart are selected, an empty list is returned. The set method is supported but the add, addAll, remove removeAll methods are not. Changes to this list modify the internal selection.
      Note: This method only checks whether the first selected element is of type EditPart and then performs a lazy cast from List<?> to List<EditPart>. It should therefore only be called when a single type of objects are selected.
      Returns:
      A List containing the currently selected EditParts.
      Since:
      3.20
    • getSelection

      protected ISelection getSelection()
      Gets the current selection.
      Returns:
      The current selection.
    • handleSelectionChanged

      protected void handleSelectionChanged()
      Called when the selection is changed.
    • setSelection

      protected void setSelection(ISelection selection)
      Sets the current selection and calls on subclasses to handle the selectionChanged event.
      Parameters:
      selection - The new selection.
    • setSelectionProvider

      public void setSelectionProvider(ISelectionProvider provider)
      May be used to provide an alternative selection source other than the workbench's selection service. Use of this method is optional. The default value is null, in which case the selection is obtained using the partsite's selection service.
      Parameters:
      provider - null or a selection provider
    • update

      public void update()
      Description copied from interface: UpdateAction
      Called to update the receiver.
      Specified by:
      update in interface UpdateAction
      Overrides:
      update in class WorkbenchPartAction
      See Also: