Kuzniarz
Kuzniarz

Reputation: 70

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.

Upvotes: 0

Views: 136

Answers (2)

Kuzniarz
Kuzniarz

Reputation: 70

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.

Upvotes: 0

greg-449
greg-449

Reputation: 111217

The workingSet element of the org.eclipse.ui.workingSets extension point used for defining a new working set type has a pageClass attribute which is used to specify the class implementing the second page of the new working set wizard.

The page class must implement org.eclipse.ui.dialogs.IWorkingSetPage.

The example in the Eclipse help:

<extension point="org.eclipse.ui.workingSets">
    <workingSet
        id="org.eclipse.ui.resourceWorkingSetPage"
        name="Resource"
        description="Contains basic resources (files, folders, and projects)"
        icon="icons/resworkset.png"
        pageClass="org.eclipse.ui.internal.dialogs.ResourceWorkingSetPage"
        updaterClass="org.eclipse.ui.internal.workingsets.ResourceWorkingSetUpdater"
        elementAdapterClass="org.eclipse.ui.internal.workingsets.ResourceWorkingSetElementAdapter">
    </workingSet>
 </extension>

Note: WorkingSetNewWizard is an internal class so you must not reference it in your code.

Upvotes: 1

Related Questions