Invoking an Eclipse Wizard programmatically

Sometimes I find the need to programmatically invoke an Eclipse wizard. I’ve been using various ways of doing so, but have finally ended up with a more generic function. This will search through all the wizard registries and try to find a wizard with the specified identifier. If found the wizard will be opened. The code is shown below:

I hope you’ll find this snippet useful.

17 Comments

  1. Hi Matthias.

    Well it could be that there is a better way that I have not discovered yet. However it is most common to invoke wizards using existing mechanisms. If you want to do it programmatically you normally reference the wizard directly which requires much less code. This method is intentionally quite generic.

  2. Platform UI provides commands (org.eclipse.ui.file.export, org.eclipse.ui.file.import & org.eclipse.ui.newWizard) handlers for invoking the workbench wizards. You can just invoke these commands with correct parameter ids.

  3. Hi!
    I have some questions:
    1.)I want to invoke the ecore diagram model wizard. Does anyone know how to find out its id?

    2.)I tried to invoke the ecore model wizard using the id “org.eclipse.emf.ecore.presentation.EcoreModelWizardID”. The wizard is found but as soon as the code reaches wd.open() it throws a nullPointerException and I do not know why. Can anybody help me with that?

    Thanks in advance!

  4. How can I get the ID of File –> New –> Other… wizard?
    When I invoke org.eclipse.ui.newWizard it opens Other wizard window but I need to open New Wizard window instead of it.
    Any help would be appreciated, thanks

Leave a Reply