Search code examples
eclipseeclipse-rcpe4

How to open the default p2 install wizard from an e4 RCP application?


I'm trying to open the default p2 install wizard if a button inside my e4 RCP application gets clicked.

I'm calling ProvisioningUI.getDefaultUI().openInstallWizard inside my click handler to open the wizard.

Clicking this button throws:

java.lang.IllegalStateException: Workbench has not been created yet.
  at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
  at org.eclipse.equinox.internal.p2.ui.ProvUI.getDefaultParentShell(ProvUI.java:155) 
  ...

The stacktrace shows, that p2 tries to call PlatformUI.getWorkbench, but as far as I know this is not supported in e4 applications, dependency injection has to be used.

How to open the default p2 install wizard from an e4 RCP application?

Thank you in advance.


Solution

  • Since the p2 UI depends on Eclipse 3.x compatibility mode code such as PlatformUI.getWorkbench it can't be used in a pure e4 application.

    You can use the non-UI p2 operations as they don't need the compatibility mode code.