Class OpenAction

  • All Implemented Interfaces:
    org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelectionChangedListener

    public class OpenAction
    extends org.eclipse.ui.actions.BaseSelectionListenerAction
    Opens an editor on an applicable element.
    • 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

      Constructors 
      Constructor Description
      OpenAction​(EditorOpener editorOpener)
      Constructs an open action with the given editor opener.
      OpenAction​(org.eclipse.ui.IWorkbenchPage page, EditorUtility editorUtility)
      Constructs an open action with the given workbench page and the given editor utility; uses a default editor opener.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected IStatusAcceptor newStatusAcceptor()
      Returns a new instance of the status acceptor for this action.
      void run()
      For each of the currently selected elements that has a corresponding editor input, this implementation uses the editor opener to open and reveal the element in an appropriate editor; if an error occurs while opening the editor, it is reported to the status acceptor.
      protected boolean updateSelection​(org.eclipse.jface.viewers.IStructuredSelection selection)
      This implementation returns false if the given selection is null or empty, or if no editor input corresponds to a selected element; otherwise, true is returned.
      • Methods inherited from class org.eclipse.ui.actions.BaseSelectionListenerAction

        clearCache, getStructuredSelection, runWithEvent, selectionChanged, selectionChanged
      • Methods inherited from class org.eclipse.jface.action.Action

        convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
      • Methods inherited from class org.eclipse.jface.action.AbstractAction

        addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
      • Methods inherited from class org.eclipse.core.commands.common.EventManager

        addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OpenAction

        public OpenAction​(org.eclipse.ui.IWorkbenchPage page,
                          EditorUtility editorUtility)
        Constructs an open action with the given workbench page and the given editor utility; uses a default editor opener.
        Parameters:
        page - the workbench page to open the editor in (not null)
        editorUtility - the editor utility for this action (not null)
        See Also:
        OpenAction(EditorOpener)
      • OpenAction

        public OpenAction​(EditorOpener editorOpener)
        Constructs an open action with the given editor opener.
        Parameters:
        editorOpener - the editor opener for this action (not null)
    • Method Detail

      • run

        public void run()
        For each of the currently selected elements that has a corresponding editor input, this implementation uses the editor opener to open and reveal the element in an appropriate editor; if an error occurs while opening the editor, it is reported to the status acceptor.
        Specified by:
        run in interface org.eclipse.jface.action.IAction
        Overrides:
        run in class org.eclipse.jface.action.Action
        See Also:
        EditorOpener.open(Object, boolean, boolean), newStatusAcceptor()
      • updateSelection

        protected boolean updateSelection​(org.eclipse.jface.viewers.IStructuredSelection selection)
        This implementation returns false if the given selection is null or empty, or if no editor input corresponds to a selected element; otherwise, true is returned.
        Overrides:
        updateSelection in class org.eclipse.ui.actions.BaseSelectionListenerAction
      • newStatusAcceptor

        protected IStatusAcceptor newStatusAcceptor()
        Returns a new instance of the status acceptor for this action.

        A default status acceptor logs each status to the error log and displays an error dialog when done and at least one status was accepted.

        Returns:
        a new status acceptor (never null)