Class Wizard

java.lang.Object
org.eclipse.jface.wizard.Wizard
All Implemented Interfaces:
IShellProvider, IWizard
Direct Known Subclasses:
BasicNewResourceWizard, ExternalProjectImportWizard, FileSystemExportWizard, FileSystemImportWizard, ParticipantSynchronizeWizard, RefactoringHistoryWizard, RefactoringWizard, ZipFileExportWizard, ZipFileImportWizard

public abstract class Wizard extends Object implements IWizard, IShellProvider
An abstract base implementation of a wizard. A typical client subclasses Wizard to implement a particular wizard.

Subclasses may call the following methods to configure the wizard:

  • addPage
  • setHelpAvailable
  • setDefaultPageImageDescriptor
  • setDialogSettings
  • setNeedsProgressMonitor
  • setTitleBarColor
  • setWindowTitle

Subclasses may override these methods if required:

  • reimplement createPageControls
  • reimplement performCancel
  • extend addPages
  • reimplement performFinish
  • extend dispose

Note that clients are free to implement IWizard from scratch instead of subclassing Wizard. Correct implementations of IWizard will work with any correct implementation of IWizardPage.

  • Field Details

    • DEFAULT_IMAGE

      public static final String DEFAULT_IMAGE
      Image registry key of the default image for wizard pages (value "org.eclipse.jface.wizard.Wizard.pageImage").
      See Also:
  • Constructor Details

    • Wizard

      protected Wizard()
      Creates a new empty wizard.
  • Method Details

    • addPage

      public void addPage(IWizardPage page)
      Adds a new page to this wizard. The page is inserted at the end of the page list.
      Parameters:
      page - the new page
    • addPages

      public void addPages()
      The Wizard implementation of this IWizard method does nothing. Subclasses should extend if extra pages need to be added before the wizard opens. New pages should be added by calling addPage.
      Specified by:
      addPages in interface IWizard
    • canFinish

      public boolean canFinish()
      Description copied from interface: IWizard
      Returns whether this wizard could be finished without further user interaction.

      The result of this method is typically used by the wizard container to enable or disable the Finish button.

      Specified by:
      canFinish in interface IWizard
      Returns:
      true if the wizard could be finished, and false otherwise
    • createPageControls

      public void createPageControls(Composite pageContainer)
      The Wizard implementation of this IWizard method creates all the pages controls using IDialogPage.createControl. Subclasses should reimplement this method if they want to delay creating one or more of the pages lazily. The framework ensures that the contents of a page will be created before attempting to show it.
      Specified by:
      createPageControls in interface IWizard
      Parameters:
      pageContainer - the parent control
    • dispose

      public void dispose()
      The Wizard implementation of this IWizard method disposes all the pages controls using DialogPage.dispose. Subclasses should extend this method if the wizard instance maintains addition SWT resource that need to be disposed.
      Specified by:
      dispose in interface IWizard
    • getContainer

      public IWizardContainer getContainer()
      Description copied from interface: IWizard
      Returns the container of this wizard.
      Specified by:
      getContainer in interface IWizard
      Returns:
      the wizard container, or null if this wizard has yet to be added to a container
    • getDefaultPageImage

      public Image getDefaultPageImage()
      Description copied from interface: IWizard
      Returns the default page image for this wizard.

      This image can be used for pages which do not supply their own image.

      Specified by:
      getDefaultPageImage in interface IWizard
      Returns:
      the default page image
    • getDialogSettings

      public IDialogSettings getDialogSettings()
      Description copied from interface: IWizard
      Returns the dialog settings for this wizard.

      The dialog store is used to record state between wizard invocations (for example, radio button selections, last directory, etc.).

      Specified by:
      getDialogSettings in interface IWizard
      Returns:
      the dialog settings, or null if none
    • getNextPage

      public IWizardPage getNextPage(IWizardPage page)
      Description copied from interface: IWizard
      Returns the successor of the given page.

      This method is typically called by a wizard page

      Specified by:
      getNextPage in interface IWizard
      Parameters:
      page - the page
      Returns:
      the next page, or null if none
    • getPage

      public IWizardPage getPage(String name)
      Description copied from interface: IWizard
      Returns the wizard page with the given name belonging to this wizard.
      Specified by:
      getPage in interface IWizard
      Parameters:
      name - the name of the wizard page
      Returns:
      the wizard page with the given name, or null if none
    • getPageCount

      public int getPageCount()
      Description copied from interface: IWizard
      Returns the number of pages in this wizard.
      Specified by:
      getPageCount in interface IWizard
      Returns:
      the number of wizard pages
    • getPages

      public IWizardPage[] getPages()
      Description copied from interface: IWizard
      Returns all the pages in this wizard.
      Specified by:
      getPages in interface IWizard
      Returns:
      a list of pages
    • getPreviousPage

      public IWizardPage getPreviousPage(IWizardPage page)
      Description copied from interface: IWizard
      Returns the predecessor of the given page.

      This method is typically called by a wizard page

      Specified by:
      getPreviousPage in interface IWizard
      Parameters:
      page - the page
      Returns:
      the previous page, or null if none
    • getShell

      public Shell getShell()
      Returns the wizard's shell if the wizard is visible. Otherwise null is returned.
      Specified by:
      getShell in interface IShellProvider
      Returns:
      Shell
    • getStartingPage

      public IWizardPage getStartingPage()
      Description copied from interface: IWizard
      Returns the first page to be shown in this wizard.
      Specified by:
      getStartingPage in interface IWizard
      Returns:
      the first wizard page
    • getTitleBarColor

      public RGB getTitleBarColor()
      Description copied from interface: IWizard
      Returns the title bar color for this wizard.
      Specified by:
      getTitleBarColor in interface IWizard
      Returns:
      the title bar color
    • getWindowTitle

      public String getWindowTitle()
      Description copied from interface: IWizard
      Returns the window title string for this wizard.
      Specified by:
      getWindowTitle in interface IWizard
      Returns:
      the window title string, or null for no title
    • getMinimumWizardSize

      public Point getMinimumWizardSize()
      Description copied from interface: IWizard
      Returns the minimum size of this wizard. The minimum size is calculated using the minimum page sizes of all wizard pages. May return null if none of the wizard pages specify a minimum size.
      Specified by:
      getMinimumWizardSize in interface IWizard
      Returns:
      the minimum size encoded as new Point(width,height)
      See Also:
    • isHelpAvailable

      public boolean isHelpAvailable()
      Description copied from interface: IWizard
      Returns whether help is available for this wizard.

      The result of this method is typically used by the container to show or hide a button labeled "Help".

      Note: This wizard's container might be a TrayDialog which provides its own help support that is independent of this property.

      Note 2: In the default WizardDialog implementation, the "Help" button only works when IDialogPage.performHelp() is implemented.

      Specified by:
      isHelpAvailable in interface IWizard
      Returns:
      true if help is available, false otherwise
      See Also:
    • needsPreviousAndNextButtons

      public boolean needsPreviousAndNextButtons()
      Description copied from interface: IWizard
      Returns whether this wizard needs Previous and Next buttons.

      The result of this method is typically used by the container.

      Specified by:
      needsPreviousAndNextButtons in interface IWizard
      Returns:
      true if Previous and Next buttons are required, and false if none are needed
    • needsProgressMonitor

      public boolean needsProgressMonitor()
      Description copied from interface: IWizard
      Returns whether this wizard needs a progress monitor.

      The result of this method is typically used by the container.

      Specified by:
      needsProgressMonitor in interface IWizard
      Returns:
      true if a progress monitor is required, and false if none is needed
    • performCancel

      public boolean performCancel()
      The Wizard implementation of this IWizard method does nothing and returns true. Subclasses should reimplement this method if they need to perform any special cancel processing for their wizard.
      Specified by:
      performCancel in interface IWizard
      Returns:
      true to indicate the cancel request was accepted, and false to indicate that the cancel request was refused
    • performFinish

      public abstract boolean performFinish()
      Subclasses must implement this IWizard method to perform any special finish processing for their wizard.
      Specified by:
      performFinish in interface IWizard
      Returns:
      true to indicate the finish request was accepted, and false to indicate that the finish request was refused
    • setContainer

      public void setContainer(IWizardContainer wizardContainer)
      Description copied from interface: IWizard
      Sets or clears the container of this wizard.
      Specified by:
      setContainer in interface IWizard
      Parameters:
      wizardContainer - the wizard container, or null
    • setDefaultPageImageDescriptor

      public void setDefaultPageImageDescriptor(ImageDescriptor imageDescriptor)
      Sets the default page image descriptor for this wizard.

      This image descriptor will be used to generate an image for a page with no image of its own; the image will be computed once and cached.

      Parameters:
      imageDescriptor - the default page image descriptor
    • setDialogSettings

      public void setDialogSettings(IDialogSettings settings)
      Sets the dialog settings for this wizard.

      The dialog settings is used to record state between wizard invocations (for example, radio button selection, last import directory, etc.)

      Parameters:
      settings - the dialog settings, or null if none
      See Also:
    • setForcePreviousAndNextButtons

      public void setForcePreviousAndNextButtons(boolean b)
      Controls whether the wizard needs Previous and Next buttons even if it currently contains only one page.

      This flag should be set on wizards where the first wizard page adds follow-on wizard pages based on user input.

      Parameters:
      b - true to always show Next and Previous buttons, and false to suppress Next and Previous buttons for single page wizards
    • setHelpAvailable

      public void setHelpAvailable(boolean b)
      Sets whether help is available for this wizard.

      The result of this method is typically used by the container to show or hide the button labeled "Help".

      Note: This wizard's container might be a TrayDialog which provides its own help support that is independent of this property.

      Note 2: In the default WizardDialog implementation, the "Help" button only works when IDialogPage.performHelp() is implemented.

      Parameters:
      b - true if help is available, false otherwise
      See Also:
    • setNeedsProgressMonitor

      public void setNeedsProgressMonitor(boolean b)
      Sets whether this wizard needs a progress monitor.
      Parameters:
      b - true if a progress monitor is required, and false if none is needed
      See Also:
    • setTitleBarColor

      public void setTitleBarColor(RGB color)
      Sets the title bar color for this wizard.
      Parameters:
      color - the title bar color
    • setWindowTitle

      public void setWindowTitle(String newTitle)
      Sets the window title for the container that hosts this page to the given string.
      Parameters:
      newTitle - the window title for the container