Class EditorOpener

  • Direct Known Subclasses:
    SearchEditorOpener

    public class EditorOpener
    extends java.lang.Object
    A helper class for opening a model element in an editor.
    • Constructor Summary

      Constructors 
      Constructor Description
      EditorOpener​(org.eclipse.ui.IWorkbenchPage page, EditorUtility editorUtility)
      Constructs an editor opener with the given workbench page and the given editor utility.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EditorUtility getEditorUtility()
      Returns the editor utility for this opener.
      org.eclipse.ui.IWorkbenchPage getWorkbenchPage()
      Returns the workbench page to open the editor in.
      org.eclipse.ui.IEditorPart open​(java.lang.Object element, boolean activate, boolean reveal)
      Opens the given element in an appropriate editor.
      protected boolean shouldReuseEditor()
      Returns whether editors should be reused.
      • Methods inherited from class java.lang.Object

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

      • EditorOpener

        public EditorOpener​(org.eclipse.ui.IWorkbenchPage page,
                            EditorUtility editorUtility)
        Constructs an editor opener with the given workbench page and the given editor utility.
        Parameters:
        page - the workbench page to open the editor in (not null)
        editorUtility - the editor utility for this opener (not null)
    • Method Detail

      • getWorkbenchPage

        public final org.eclipse.ui.IWorkbenchPage getWorkbenchPage()
        Returns the workbench page to open the editor in.
        Returns:
        the workbench page to open the editor in (never null)
      • getEditorUtility

        public final EditorUtility getEditorUtility()
        Returns the editor utility for this opener.
        Returns:
        the editor utility for this opener (never null)
      • open

        public org.eclipse.ui.IEditorPart open​(java.lang.Object element,
                                               boolean activate,
                                               boolean reveal)
                                        throws org.eclipse.ui.PartInitException
        Opens the given element in an appropriate editor.

        Default implementation attempts to find a matching open editor or, failing that, opens a new editor on the corresponding editor input; it then reveals the element in the editor, if requested. If editors should be reused, tries to reuse an existing editor rather than open a new one.

        Parameters:
        element - the element to open (not null)
        activate - whether to activate the editor
        reveal - whether to reveal the element in the editor
        Returns:
        an open editor, or null if an external editor was opened
        Throws:
        org.eclipse.ui.PartInitException - if the editor could not be created or initialized
      • shouldReuseEditor

        protected boolean shouldReuseEditor()
        Returns whether editors should be reused.

        Default implementation returns false.

        Returns:
        true if editors should be reused, and false otherwise
        See Also:
        open(Object, boolean, boolean)