Search code examples
javaeclipse-pluginworking-set

How to create multi-page working-set wizards


I'm developing an Eclipse Plug-in that is working with custom working sets. Right now the user can create those working-sets by starting a multi-page wizard via File > New > Other... > Custom Working Set.

By default, working-sets can also be created through the working-set selection dialog via Project Explorer > Select Working Set... > New. Those working set "wizards" (e.g. Java Working-Set, Resource Working-Set, ...) all consist of a single page. Technically there is a next button, but it's disabled after working-set type selection.

Is there any way to override that behavior to enable multi-page wizards? I believe that I have to work with the WorkingSetNewWizard class or with the IWorkingSetNewWizard interface, but I'm not sure how.


Solution

  • So I managed to get this thing working!

    Just as greg-449 pointed out, adding a custom working-set can be accomplished by defining it at the extension point org.eclipse.ui.workingSets and implementing a page class that extends "WizardPage" implements org.eclipse.ui.dialogs.IWorkingSetPage.

    The class that's handling the working-set creation is WorkingSetNewWizard. By default, it creates a wizard that consists of two pages - the working-set type selection and the defined working-set page, corresponding to the selection of the user (That's why there is a Next button in that GUI).

    To add another page, you have to override WizardPage.getNextPage (Thanks again to greg-449) in this page class. Passing the desired page does not work out of the box, because you have to add the creation wizard to the new IWizardPage:

    @Override
    public IWizardPage getNextPage() {
        IWizardPage page = new WizardPage2();
        page.setWizard(getWizard());
        return page;
    }
    

    Doing it this way, the second page does not have to implement IWorkingSetPage, because pressing the finish button will trigger the finish() function of the first page.