Possible to run the import wizard programmatically?

I have an eclipse plugin that can automatically open the buildship import-project wizard. The relevant part of the code looks something like this:

IWizardDescriptor buildshipImportWizardDescriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard("org.eclipse.buildship.ui.wizards.project.import");
PlatformUI.getWorkbench().getDisplay().asyncExec(() ->
  Shell activeShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    IWizard wizard = buildshipImportWizardDescriptor.createWizard();
    WizardDialog wd = new WizardDialog(activeShell, wizard);
  catch (Exception ex)
    // ..

Under certain conditions (workspace root has certain subdirectories, list of projects currently in the workspace is empty) I want to use this import wizard to automatically import a gradle project, without the user having to click or type. Is this possible? If not, is it possible to at least pre-fill the proper value for the project root directory?

I have now also asked this on stackoverflow; Buildship in Eclipse - Possible to run the project import wizard programmatically? - Stack Overflow

The wizards were not designed for programmatic invocation. I’m not sure you can open them this way at the moment.

We consider the import wizard an internal API and we won’t officially support this use-case. At the same time, if you provide a PR that unblocks your use-case I’m happy to take a look.

1 Like