Blog

Restarting an e4 application with the intial workbench.e4xmi

e4 applications by default remember the state when getting shutdown and restore that state on the next restart. This is the behavior most people expect from an application but there are situations people would like to reset the application into its original state or maybe the developer wants that e.g. after having installed/uninstalled certain new bundles. Unfortunately the workbench currently does not provide a way restart and clear the current state. So I've implemented a small library you can make use of in your e4 applications. There are 2 parts:

  1. a service called RestartService which has a method restart(boolean)
  2. a Lifecycle-Addon you can reuse or copy the code from min to yours

Useage is very simple e.g. in your handler:

import org.eclipse.e4.core.di.annotations.Execute;

import at.bestsolution.e4.extensions.core.services.RestartService;

public class RestartHandler {
  @Execute
  public void restart(RestartService service) {
    service.restart(true);
  }
}

and to enable the addon you make your plugin.xml look like this:

<?xml version="1.0" encoding="UTF-8"?>
<plugin>
  <extension
    id="product"
    point="org.eclipse.core.runtime.products">
    <product
      name="SampleProject"
      application="org.eclipse.e4.ui.workbench.swt.E4Application">
      <property
        name="applicationCSS"
        value="platform:/plugin/SampleProject/css/default.css">
      </property>
      <property
        name="lifeCycleURI"
        value="bundleclass://at.bestsolution.e4.extensions.lifecycle/at.bestsolution.e4.extensions.lifecycle.ExtensibleLifecycle">
      </property>
      <property
        name="appName"
        value="SampleProject">
      </property>
    </product>
  </extension>
</plugin>

If you want to make use of it you can find the p2-repo at http://downloads.foss.bestsolution.at/e4-extensions/nightly/ or if you prefer the source it is hosted at the github account of BestSolution.at at https://github.com/BestSolution-at/e4-extensions.

published on
Previous
JFace Viewers in a Java8 world - Part 1 ListViewer