Class OpenHelper


  • public class OpenHelper
    extends Object
    Provides helpers for opening and activating editors.
    • Constructor Summary

      Constructors 
      Constructor Description
      OpenHelper()
      Creates OpenHelper using the active page in the active workbench.
      OpenHelper​(org.eclipse.ui.IWorkbenchPage workbenchPage)
      Creates OpenHelper for provided IWorkbenchPage.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean activateEditor​(org.eclipse.core.resources.IFile file)
      Activates the editor for a given IFile, if any.
      boolean activateEditor​(org.eclipse.emf.common.util.URI uri, ISelection selection)
      Activates the editor for a given uri.
      boolean activateEditor​(org.eclipse.emf.ecore.EObject model)
      Activates the editor for a given model, if any.
      boolean activateEditor​(org.eclipse.emf.ecore.EObject model, org.eclipse.emf.ecore.EStructuralFeature feature)
      Activates the editor for a given model and feature, if any.
      boolean activateEditor​(org.eclipse.emf.ecore.EObject model, org.eclipse.emf.ecore.EStructuralFeature feature, ISelection selection)
      Activates the editor for a given model, feature and selection, if any.
      boolean activateEditor​(org.eclipse.ui.model.IWorkbenchAdapter workbenchAdapter)
      Activates the editor for a given IWorkbenchAdapter, if any.
      static org.eclipse.ui.IEditorInput createEObjectEditorInput​(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature)
      Deprecated. 
      String getEditorId​(org.eclipse.ui.IEditorInput input)
      Returns editor id by IEditorInput given input.
      org.eclipse.ui.IEditorInput getEditorInput​(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature, ISelection selection)
      Returns appropriate (for DT editors) editor input for given model, feature and selection.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.core.resources.IFile file, ISelection selection)
      Opens an editor for a given IFile.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.common.util.URI uri, ISelection selection)
      Opens an editor for a given uri.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model)
      Opens an editor for a given model.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model, org.eclipse.emf.ecore.EStructuralFeature feature)
      Opens an editor for a given model and feature.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model, org.eclipse.emf.ecore.EStructuralFeature feature, ISelection selection)
      Opens an editor for a given model, feature and selection.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.ui.model.IWorkbenchAdapter workbenchAdapter)
      Opens an editor for a given IWorkbenchAdapter.
    • Constructor Detail

      • OpenHelper

        public OpenHelper()
        Creates OpenHelper using the active page in the active workbench.
      • OpenHelper

        public OpenHelper​(org.eclipse.ui.IWorkbenchPage workbenchPage)
        Creates OpenHelper for provided IWorkbenchPage.
        Parameters:
        workbenchPage - page to create helper for or null to use active page in the active workbench
    • Method Detail

      • createEObjectEditorInput

        @Deprecated
        public static org.eclipse.ui.IEditorInput createEObjectEditorInput​(org.eclipse.emf.ecore.EObject object,
                                                                           org.eclipse.emf.ecore.EStructuralFeature feature)
        Deprecated.
        Creates editor input for given object and its feature.
        Parameters:
        object - object to create editor input for.
        feature - feature to create editor input for.
        Returns:
        create editor input or null if it was not created.
      • activateEditor

        public boolean activateEditor​(org.eclipse.emf.ecore.EObject model)
        Activates the editor for a given model, if any.
        Parameters:
        model - model to activate editor for.
        Returns:
        true if activated, false otherwise.
      • activateEditor

        public boolean activateEditor​(org.eclipse.emf.ecore.EObject model,
                                      org.eclipse.emf.ecore.EStructuralFeature feature)
        Activates the editor for a given model and feature, if any.
        Parameters:
        model - model to activate editor for.
        feature - feature to activate page/controls for.
        Returns:
        true if activated, false otherwise.
      • activateEditor

        public boolean activateEditor​(org.eclipse.emf.ecore.EObject model,
                                      org.eclipse.emf.ecore.EStructuralFeature feature,
                                      ISelection selection)
        Activates the editor for a given model, feature and selection, if any.
        Parameters:
        model - model to activate editor for.
        feature - feature to activate page/controls for.
        selection - selection to set.
        Returns:
        true if activated, false otherwise.
      • activateEditor

        public boolean activateEditor​(org.eclipse.emf.common.util.URI uri,
                                      ISelection selection)
        Activates the editor for a given uri.
        Parameters:
        uri - uri for open editor, can't be null
        selection - selection to set, can be null
        Returns:
        true if activated, false otherwise.
      • activateEditor

        public boolean activateEditor​(org.eclipse.ui.model.IWorkbenchAdapter workbenchAdapter)
        Activates the editor for a given IWorkbenchAdapter, if any.
        Parameters:
        workbenchAdapter - workbench adapter to activate editor for.
        Returns:
        true if activated, false otherwise.
      • activateEditor

        public boolean activateEditor​(org.eclipse.core.resources.IFile file)
        Activates the editor for a given IFile, if any.
        Parameters:
        file - file to activate editor for.
        Returns:
        true if activated, false otherwise.
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model)
        Opens an editor for a given model.
        Parameters:
        model - model to open editor for.
        Returns:
        an open editor or null if editor wasn't opened
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model,
                                                     org.eclipse.emf.ecore.EStructuralFeature feature)
        Opens an editor for a given model and feature.
        Parameters:
        model - model to open editor for.
        feature - feature to activate page/controls for.
        Returns:
        an open editor or null if editor wasn't opened
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.ecore.EObject model,
                                                     org.eclipse.emf.ecore.EStructuralFeature feature,
                                                     ISelection selection)
        Opens an editor for a given model, feature and selection.
        Parameters:
        model - model to open editor for.
        feature - feature to activate page/controls for.
        selection - selection to set.
        Returns:
        an open editor or null if editor wasn't opened
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.emf.common.util.URI uri,
                                                     ISelection selection)
        Opens an editor for a given uri.
        Parameters:
        uri - uri for open editor, can't be null
        selection - selection to set, can be null
        Returns:
        an open editor or null if editor wasn't opened
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.ui.model.IWorkbenchAdapter workbenchAdapter)
        Opens an editor for a given IWorkbenchAdapter.
        Parameters:
        workbenchAdapter - workbenchAdapter returned from the navigator content provider.
        Returns:
        an open editor or null if editor wasn't opened
      • openEditor

        public org.eclipse.ui.IEditorPart openEditor​(org.eclipse.core.resources.IFile file,
                                                     ISelection selection)
        Opens an editor for a given IFile.
        Parameters:
        file - file to open and editor for.
        Returns:
        an open editor or null if editor wasn't opened
      • getEditorInput

        public org.eclipse.ui.IEditorInput getEditorInput​(org.eclipse.emf.ecore.EObject object,
                                                          org.eclipse.emf.ecore.EStructuralFeature feature,
                                                          ISelection selection)
        Returns appropriate (for DT editors) editor input for given model, feature and selection.
        Parameters:
        model - model to activate editor for, cannot be null
        feature - feature to activate page/controls for, can be null, than will not be used for input instantiation
        selection - selection to set, can be null, than will not be used for input instantiation
        Returns:
        editor input, never null
      • getEditorId

        public String getEditorId​(org.eclipse.ui.IEditorInput input)
        Returns editor id by IEditorInput given input.

        Can return null.

        Parameters:
        input - actual IEditorInput, cannot be null
        Returns:
        found editor id or null if editor wasn't found by IEditorInput