ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Eclipse Plugins Exposed, Part 3: Customizing a Wizard
Pages: 1, 2, 3, 4, 5, 6

Wizard Page Methods

As we've seen, a wizard is composed of one or more pages. These pages extend the WizardPage class and implement the IWizardPage interface. These have many methods you should know about in order to customize individual pages. Here are a few important ones:

  • Constructor: Write to initialize the page.
  • dispose(): Override to implement cleanup code.
  • createControl(Composite parent): Override to add controls to the page.
  • IWizard getWizard(): Used to get the parent wizard object. Useful to call getDialogSettings().
  • setTitle(String title): Call to provide the string that appears in the title area of the wizard.
  • setDescription(String description): Call to provide the text that appears just below the title.
  • setImageDescriptor(ImageDescriptor image): Call to provide the graphic that appears in the top right of the page instead of the default image.
  • setMessage(String message): Call to display a text message below the description string. This is used for warning or informing the user.
  • setErrorMessage(String error): Call to display a highlighted text message below the description string. This usually means the wizard can't continue until an error is fixed.
  • setPageComplete(boolean complete): If this is true, the Next button will be available.
  • performHelp(): Override to provide context-sensitive help. This is called by the wizard when the Help button is pressed.

Coding the Wizard

Armed with these many methods, it is now possible to develop wizards with infinite flexibility. We will now modify the Invokatron wizard that we created in the previous articles, and give it a page to request the initial document data. We will also add a graphic to the wizard. The new code is in bold:

public class InvokatronWizard extends Wizard
        implements INewWizard {
    private InvokatronWizardPage page;
    private InvokatronWizardPage2 page2;
    private ISelection selection;

    public InvokatronWizard() {
        ImageDescriptor image =

    public void init(IWorkbench workbench,
            IStructuredSelection selection) {
        this.selection = selection;

In the constructor, we're turning on the progress monitor and setting the image for the wizard. You can download the following new icon by right-clicking:

Invokatron Icon

to save. You have to save this icon in the Invokatron/icons folder. To facilitate the loading of this image, we use the handy-dandy AbstractUIPlugin.imageDescriptorFromPlugin() method.

Note: You should know that, although this wizard is of the type INewWizard, not all wizards are used to create new documents. For information on how to display a "standalone" wizard, refer to the resources section at the bottom of this article.

Next is the addPages() method:

    public void addPages() {
        page=new InvokatronWizardPage(selection);
        page2 = new InvokatronWizardPage2(

Pages: 1, 2, 3, 4, 5, 6

Next Pagearrow