Eclipse Platform
2.0

org.eclipse.jface.wizard
Class WizardDialog

java.lang.Object
  |
  +--org.eclipse.jface.window.Window
        |
        +--org.eclipse.jface.dialogs.Dialog
              |
              +--org.eclipse.jface.dialogs.TitleAreaDialog
                    |
                    +--org.eclipse.jface.wizard.WizardDialog
All Implemented Interfaces:
IRunnableContext, IWizardContainer

public class WizardDialog
extends TitleAreaDialog
implements IWizardContainer

A dialog to show a wizard to the end user.

In typical usage, the client instantiates this class with a particular wizard. The dialog serves as the wizard container and orchestrates the presentation of its pages.

The standard layout is roughly as follows: it has an area at the top containing both the wizard's title, description, and image; the actual wizard page appears in the middle; below that is a progress indicator (which is made visible if needed); and at the bottom of the page is message line and a button bar containing Help, Next, Back, Finish, and Cancel buttons (or some subset).

Clients may subclass WizardDialog, although this is rarely required.


Nested Class Summary
protected  class WizardDialog.PageContainerFillLayout
          A layout for a container which includes several pages, like a notebook, wizard, or preference dialog.
 
Nested classes inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
 
Field Summary
static String WIZ_IMG_ERROR
          Image registry key for error message image (value "dialog_title_error_image").
 
Fields inherited from class org.eclipse.jface.dialogs.TitleAreaDialog
DLG_IMG_TITLE_BANNER, DLG_IMG_TITLE_ERROR, INFO_MESSAGE, WARNING_MESSAGE
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
WizardDialog(Shell parentShell, IWizard newWizard)
          Creates a new wizard dialog for the given wizard.
 
Method Summary
protected  void backPressed()
          The Back button has been pressed.
protected  void buttonPressed(int buttonId)
          Notifies that this dialog's button with the given id has been pressed.
protected  void cancelPressed()
          Notifies that the cancel button of this dialog has been pressed.
 boolean close()
          Closes this window, disposes its shell, and removes this window from its window manager (if it has one).
protected  void configureShell(Shell newShell)
          Configures the given shell in preparation for opening this window in it.
protected  Control createButtonBar(Composite parent)
          Creates and returns the contents of this dialog's button bar.
protected  void createButtonsForButtonBar(Composite parent)
          Adds buttons to this dialog's button bar.
protected  Control createContents(Composite parent)
          The WizardDialog implementation of this Window method calls call IWizard.addPages to allow the current wizard to add extra pages, then super.createContents to create the controls.
protected  Control createDialogArea(Composite parent)
          Creates and returns the contents of the upper part of this dialog (above the button bar).
protected  void finishPressed()
          The Finish button has been pressed.
 IWizardPage getCurrentPage()
          Returns the current wizard page for this container.
protected  IProgressMonitor getProgressMonitor()
          Returns the progress monitor for this wizard dialog (if it has one).
protected  IWizard getWizard()
          Returns the wizard this dialog is currently displaying.
protected  void helpPressed()
          The Help button has been pressed.
protected  void nextPressed()
          The Next button has been pressed.
 void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
          Runs the given IRunnableWithProgress in this context.
 void setMinimumPageSize(int minWidth, int minHeight)
          Sets the minimum page size used for the pages.
 void setMinimumPageSize(Point size)
          Sets the minimum page size used for the pages.
 void setPageSize(int width, int height)
          Sets the size of all pages.
 void setPageSize(Point size)
          Sets the size of all pages.
protected  void setWizard(IWizard newWizard)
          Sets the wizard this dialog is currently displaying.
 void showPage(IWizardPage page)
          Makes the given page visible.
protected  void update()
          Updates this dialog's controls to reflect the current page.
 void updateButtons()
          Adjusts the enable state of the Back, Next, and Finish buttons to reflect the state of the currently active page in this container.
 void updateMessage()
          Updates the message (or error message) shown in the message line to reflect the state of the currently active page in this container.
protected  void updateSize(IWizardPage page)
          Computes the correct dialog size for the current page and resizes its shell if nessessary.
 void updateTitleBar()
          Updates the title bar (title, description, and image) to reflect the state of the currently active page in this container.
 void updateWindowTitle()
          Updates the window title to reflect the state of the current wizard.
 
Methods inherited from class org.eclipse.jface.dialogs.TitleAreaDialog
getInitialSize, getTitleArea, getTitleImageLabel, setErrorMessage, setMessage, setMessage, setTitle, setTitleAreaColor, setTitleImage
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
constrainShellSize, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, createButton, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getOKButton, initializeDialogUnits, okPressed
 
Methods inherited from class org.eclipse.jface.window.Window
create, createShell, getContents, getDefaultImage, getInitialLocation, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, open, setBlockOnOpen, setDefaultImage, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.wizard.IWizardContainer
getShell
 

Field Detail

WIZ_IMG_ERROR

public static final String WIZ_IMG_ERROR
Image registry key for error message image (value "dialog_title_error_image").

See Also:
Constant Field Values
Constructor Detail

WizardDialog

public WizardDialog(Shell parentShell,
                    IWizard newWizard)
Creates a new wizard dialog for the given wizard.

Parameters:
parentShell - the parent shell
newWizard - the wizard this dialog is working on
Method Detail

backPressed

protected void backPressed()
The Back button has been pressed.


buttonPressed

protected void buttonPressed(int buttonId)
Description copied from class: Dialog
Notifies that this dialog's button with the given id has been pressed.

The Dialog implementation of this framework method calls okPressed if the ok button is the pressed, and cancelPressed if the cancel button is the pressed. All other button presses are ignored. Subclasses may override to handle other buttons, but should call super.buttonPressed if the default handling of the ok and cancel buttons is desired.

Overrides:
buttonPressed in class Dialog
Parameters:
buttonId - the id of the button that was pressed (see IDialogConstants.*_ID constants)

cancelPressed

protected void cancelPressed()
Description copied from class: Dialog
Notifies that the cancel button of this dialog has been pressed.

The Dialog implementation of this framework method sets this dialog's return code to Window.CANCEL and closes the dialog. Subclasses may override if desired.

Overrides:
cancelPressed in class Dialog

close

public boolean close()
Description copied from class: Window
Closes this window, disposes its shell, and removes this window from its window manager (if it has one).

This framework method may be extended (super.close must be called).

Overrides:
close in class Window
Returns:
true if the window is (or was already) closed, and false if it is still open

configureShell

protected void configureShell(Shell newShell)
Description copied from class: Window
Configures the given shell in preparation for opening this window in it.

The default implementation of this framework method sets the shell's image and gives it a grid layout. Subclasses may extend or reimplement.

Overrides:
configureShell in class Window
Parameters:
newShell - the shell

createButtonBar

protected Control createButtonBar(Composite parent)
Creates and returns the contents of this dialog's button bar.

The WizardDialog implementation of this framework method prevents the composite's columns from being made equal width in order to remove the margin between the Back and Next buttons.

Overrides:
createButtonBar in class Dialog
Parameters:
parent - the parent composite to contain the button bar
Returns:
the button bar control

createButtonsForButtonBar

protected void createButtonsForButtonBar(Composite parent)
Description copied from class: Dialog
Adds buttons to this dialog's button bar.

The Dialog implementation of this framework method adds standard ok and cancel buttons using the createButton framework method. These standard buttons will be accessible from getCancelButton, and getOKButton. Subclasses may override.

Overrides:
createButtonsForButtonBar in class Dialog
Parameters:
parent - the button bar composite

createContents

protected Control createContents(Composite parent)
The WizardDialog implementation of this Window method calls call IWizard.addPages to allow the current wizard to add extra pages, then super.createContents to create the controls. It then calls IWizard.createPageControls to allow the wizard to pre-create their page controls prior to opening, so that the wizard opens to the correct size. And finally it shows the first page.

Overrides:
createContents in class Dialog
Returns:
the control

createDialogArea

protected Control createDialogArea(Composite parent)
Description copied from class: TitleAreaDialog
Creates and returns the contents of the upper part of this dialog (above the button bar).

The Dialog implementation of this framework method creates and returns a new Composite with standard margins and spacing. Subclasses should override.

Overrides:
createDialogArea in class TitleAreaDialog
Returns:
the dialog area control

finishPressed

protected void finishPressed()
The Finish button has been pressed.


getCurrentPage

public IWizardPage getCurrentPage()
Description copied from interface: IWizardContainer
Returns the current wizard page for this container.

Specified by:
getCurrentPage in interface IWizardContainer
Returns:
the current wizard page, or null if the container is not yet showing the wizard
See Also:
IWizardContainer.showPage(org.eclipse.jface.wizard.IWizardPage)

getProgressMonitor

protected IProgressMonitor getProgressMonitor()
Returns the progress monitor for this wizard dialog (if it has one).

Returns:
the progress monitor, or null if this wizard dialog does not have one

getWizard

protected IWizard getWizard()
Returns the wizard this dialog is currently displaying.

Returns:
the current wizard

helpPressed

protected void helpPressed()
The Help button has been pressed.


nextPressed

protected void nextPressed()
The Next button has been pressed.


run

public void run(boolean fork,
                boolean cancelable,
                IRunnableWithProgress runnable)
         throws InvocationTargetException,
                InterruptedException
Description copied from interface: IRunnableContext
Runs the given IRunnableWithProgress in this context. For example, if this is a ProgressMonitorDialog then the runnable is run using this dialog's progress monitor.

Specified by:
run in interface IRunnableContext
Parameters:
fork - true if the runnable should be run in a separate thread, and false to run in the same thread
cancelable - true to enable the cancelation, and false to make the operation uncancellable
runnable - the runnable to run
Throws:
InvocationTargetException - wraps any exception or error which occurs while running the runnable
InterruptedException - propagated by the context if the runnable acknowledges cancelation by throwing this exception

setMinimumPageSize

public void setMinimumPageSize(int minWidth,
                               int minHeight)
Sets the minimum page size used for the pages.

Parameters:
minWidth - the minimum page width
minHeight - the minimum page height
See Also:
setMinimumPageSize(org.eclipse.swt.graphics.Point)

setMinimumPageSize

public void setMinimumPageSize(Point size)
Sets the minimum page size used for the pages.

Parameters:
size - the page size encoded as new Point(width,height)
See Also:
setMinimumPageSize(int,int)

setPageSize

public void setPageSize(int width,
                        int height)
Sets the size of all pages. The given size takes precedence over computed sizes.

Parameters:
width - the page width
height - the page height
See Also:
setPageSize(org.eclipse.swt.graphics.Point)

setPageSize

public void setPageSize(Point size)
Sets the size of all pages. The given size takes precedence over computed sizes.

Parameters:
size - the page size encoded as new Point(width,height)
See Also:
setPageSize(int,int)

setWizard

protected void setWizard(IWizard newWizard)
Sets the wizard this dialog is currently displaying.

Parameters:
newWizard - the wizard

showPage

public void showPage(IWizardPage page)
Description copied from interface: IWizardContainer
Makes the given page visible.

This method should not be use for normal page sequencing (back, next) which is handled by the container itself. It may, however, be used to move to another page in response to some custom action such as double clicking in a list.

Specified by:
showPage in interface IWizardContainer
Parameters:
page - the page to show
See Also:
IWizardContainer.getCurrentPage()

update

protected void update()
Updates this dialog's controls to reflect the current page.


updateButtons

public void updateButtons()
Description copied from interface: IWizardContainer
Adjusts the enable state of the Back, Next, and Finish buttons to reflect the state of the currently active page in this container.

This method is called by the container itself when its wizard page changes and may be called by the page at other times to force a button state update.

Specified by:
updateButtons in interface IWizardContainer

updateMessage

public void updateMessage()
Description copied from interface: IWizardContainer
Updates the message (or error message) shown in the message line to reflect the state of the currently active page in this container.

This method is called by the container itself when its wizard page changes and may be called by the page at other times to force a message update.

Specified by:
updateMessage in interface IWizardContainer

updateSize

protected void updateSize(IWizardPage page)
Computes the correct dialog size for the current page and resizes its shell if nessessary. Also causes the container to refresh its layout.

Parameters:
page - the wizard page to use to resize the dialog
Since:
2.0

updateTitleBar

public void updateTitleBar()
Description copied from interface: IWizardContainer
Updates the title bar (title, description, and image) to reflect the state of the currently active page in this container.

This method is called by the container itself when its wizard page changes and may be called by the page at other times to force a title bar update.

Specified by:
updateTitleBar in interface IWizardContainer

updateWindowTitle

public void updateWindowTitle()
Description copied from interface: IWizardContainer
Updates the window title to reflect the state of the current wizard.

This method is called by the container itself when its wizard changes and may be called by the wizard at other times to force a window title change.

Specified by:
updateWindowTitle in interface IWizardContainer

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.