Search code examples
javaeclipseeclipse-rcpstartupe4

E4 Application.class necessary?


I'm migrating a Eclipse 3 Application right now, and I wonder if I still need the Application.class.

The reason for my concern is the Quote from Marc Teufel "In the past on RCP 3.x we hooked into the Application*-Classes to popup things like login screens just before the main application came up. With e4 we don't have the Application-Classes anymore, instead there is a standard E4Application-Class which is responsible to create the Workbench Model and startup the GUI" (https://marcteufel.wordpress.com/2011/05/05/231/)

My Eclipse 3 Application.class executed the Workbench and got a RETURN CODE to decide whether to restart or not, and that's barely it...

int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
                return IApplication.EXIT_RESTART;
            }
            return IApplication.EXIT_OK;
[...]

Is this behavior included in the default "org.eclipse.e4.ui.workbench.swt.E4Application"-Application Bundle? I'm using Eclipse 4.5.1


Solution

  • Yes, similar behavior is included in the standard E4Application class. You should not use your own application class.

    To do a restart in an e4 application inject org.eclipse.e4.ui.workbench.IWorkbench and call the restart() method. Note that this is a different IWorkbench class from the 3.x org.eclipse.ui.IWorkbench class (which you should not use).