Search code examples
eclipse-rcpeclipse-gef

How to display gef editor?


I am trying to use GEF for displaying and editing a flow diagram in an RCP. I have used GraphicalEditorWithFlyoutPalette as my editor looking at various examples on the internet. I n all those examples I dont find tips on how to show this editor when my RCP application starts first. previously I used a ViewPart to display the flow diagram and it worked fine. Now I am struck without knowing how to open the same on the editor which I designed.


Solution

  • The IDE class has several methods for opening an editor, for example:

    IFile file = ... file you want to open
    
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    
    IEditorInput input = new FileEditorInput(file);
    
    IDE.openEditor(page, input, "editor id");
    

    You can use the org.eclipse.ui.startup extension point to run code early in the Eclipse start up but the code above will not run so early in the start up. But you can schedule a UIJob to run the code:

    @Override
    public void earlyStartup()
    {
      new StartJob().schedule();
    }
    
    
    class StartJob extends UIJob
    {
      public StartJob()
      {
        super("Start Job");
      }
    
      @Override
      public IStatus runInUIThread(final IProgressMonitor monitor)
      {
        .. open editor code   
    
        return Status.OK_STATUS;
      }
    }