Search code examples
javaeclipse-rcpe4

Eclipse RCP open view programmatically the e4 way


I would like to programmatically (from a context menu) open a certain view How can I do so?

I can show a view using e3 compatibility layer like this:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("viewId");

What is the e4 way to do so?


Solution

  • In e4 you open any part using EPartService:

    @Inject
    EPartService partService;
    
    
    partService.showPart("part id", PartState.ACTIVATE);
    

    The part should be in the Application.e4xmi in the place you want it to show but should have 'To Be Rendered' turned off (leave 'Visible' on).