Class WizardDialog
- All Implemented Interfaces:
IPageChangeProvider
,IRunnableContext
,IShellProvider
,IWizardContainer
,IWizardContainer2
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
Modifier and TypeClassDescriptionprotected class
A layout for a container which includes several pages, like a notebook, wizard, or preference dialog.Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
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
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, dialogArea, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK, resizeHasOccurred
-
Constructor Summary
ConstructorDescriptionWizardDialog
(Shell parentShell, IWizard newWizard) Creates a new wizard dialog for the given wizard. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPageChangedListener
(IPageChangedListener listener) Adds a listener for page changes in this page change provider.void
addPageChangingListener
(IPageChangingListener listener) Adds a listener for page changes to the list of page changing listeners registered for this dialog.protected void
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
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 void
createButtonsForButtonBar
(Composite parent) Creates the buttons for this dialog's button bar.protected Control
createContents
(Composite parent) TheWizardDialog
implementation of thisWindow
method calls callIWizard.addPages
to allow the current wizard to add extra pages, thensuper.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 ProgressMonitorPart
createProgressMonitorPart
(Composite composite, GridLayout pmlayout) Hook method for subclasses to create a custom progress monitor part.protected void
The Finish button has been pressed.protected void
firePageChanged
(PageChangedEvent event) Notifies any selection changed listeners that the selected page has changed.protected void
Notifies any page changing listeners that the currently selected dialog page is changing.protected Button
getButton
(int id) Return the cancel button if the id is a the cancel id.Returns the current wizard page for this container.protected IDialogSettings
Gets the dialog settings that should be used for remembering the bounds of of the dialog, according to the dialog bounds strategy.protected IProgressMonitor
Returns the progress monitor for this wizard dialog (if it has one).Returns the currently selected page in the dialog.int
Returns the shell style bits.protected IWizard
Returns the wizard this dialog is currently displaying.protected void
The Help button has been pressed.boolean
isModal()
protected void
The Next button has been pressed.void
Removes the given page change listener from this page change provider.void
Removes the provided page changing listener from the list of page changing listeners registered for the dialog.void
run
(boolean fork, boolean cancelable, IRunnableWithProgress runnable) This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable has been run, regardless of the value offork
.protected void
setButtonLayoutData
(Button button) Set the layout data of the button to a GridData with appropriate heights and widths.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.setModal
(boolean modal) Option to set the modality of the WizardDialog.void
setPageSize
(int width, int height) Sets the size of all pages.void
setPageSize
(Point size) Sets the size of all pages.void
setShellStyle
(int newShellStyle) Sets the shell style of the wizard dialog.protected void
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
Adjusts the enable state of the Back, Next, and Finish buttons to reflect the state of the currently active page in this container.void
Updates the message (or error message) shown in the message line to reflect the state of the currently active page in this container.void
Updates the window size to reflect the state of the current wizard.protected void
updateSize
(IWizardPage page) Computes the correct dialog size for the current page and resizes its shell if necessary.void
Updates the title bar (title, description, and image) to reflect the state of the currently active page in this container.void
Updates the window title to reflect the state of the current wizard.Methods inherited from class org.eclipse.jface.dialogs.TitleAreaDialog
getErrorMessage, getInitialSize, getMessage, getTitleArea, getTitleImageLabel, setErrorMessage, setMessage, setMessage, setTitle, setTitleAreaColor, setTitleImage
Methods inherited from class org.eclipse.jface.dialogs.TrayDialog
closeTray, createButtonBar, createHelpControl, getLayout, getTray, handleShellCloseEvent, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailable
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, dialogFontIsDefault, getBlockedHandler, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsStrategy, getImage, getInitialLocation, getOKButton, initializeBounds, initializeDialogUnits, isResizable, okPressed, setBlockedHandler, setButtonLayoutFormData, shortenText
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getParentShell, getReturnCode, getShell, getShellListener, getWindowManager, handleFontChange, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, 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 Details
-
WIZ_IMG_ERROR
Image registry key for error message image (value"dialog_title_error_image"
).- See Also:
-
-
Constructor Details
-
WizardDialog
Creates a new wizard dialog for the given wizard.- Parameters:
parentShell
- the parent shellnewWizard
- the wizard this dialog is working on
-
-
Method Details
-
setShellStyle
public void setShellStyle(int newShellStyle) Sets the shell style of the wizard dialog.Examples:
To use the default style without the SWT.PRIMARY_MODAL bit:
setShellStyle(getShellStyle() & ~SWT.PRIMARY_MODAL)
To use the default style without the SWT.RESIZE bit:
setShellStyle(getShellStyle() & ~SWT.RESIZE)
Sets the shell style bits. This method has no effect after the shell is created.
The shell style bits are used by the framework method
createShell
when creating this window's shell.- Overrides:
setShellStyle
in classWindow
- Parameters:
newShellStyle
- the new shell style bits- See Also:
-
getShellStyle
public int getShellStyle()Description copied from class:Window
Returns the shell style bits.The default value is
SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE
. Subclasses should callsetShellStyle
to change this value, rather than overriding this method.- Overrides:
getShellStyle
in classWindow
- Returns:
- the shell style bits
-
setModal
Option to set the modality of the WizardDialog. This method must be called before the dialog's shell is created, e.g. before you callWindow.open()
for the first time.- Parameters:
modal
- true (default) if the WizardDialog should block the underlying window.- Returns:
- this WizardDialog
- Since:
- 3.16
-
isModal
public boolean isModal()- Returns:
false
if the user interface blocks the underlying window (modal) ortrue
if the underlying window is not blocked.- Since:
- 3.16
- See Also:
-
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 callsokPressed
if the ok button is the pressed, andcancelPressed
if the cancel button is the pressed. All other button presses are ignored. Subclasses may override to handle other buttons, but should callsuper.buttonPressed
if the default handling of the ok and cancel buttons is desired.- Overrides:
buttonPressed
in classDialog
- Parameters:
buttonId
- the id of the button that was pressed (seeIDialogConstants.*_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 toWindow.CANCEL
and closes the dialog. Subclasses may override if desired.- Overrides:
cancelPressed
in classDialog
-
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).Note that in order to prevent recursive calls to this method it does not call
Shell#close()
. As a resultShellListener
s will not receive ashellClosed
event. -
configureShell
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 classWindow
- Parameters:
newShell
- the shell
-
createButtonsForButtonBar
Creates the buttons for this dialog's button bar.The
WizardDialog
implementation of this framework method prevents the parent composite's columns from being made equal width in order to remove the margin between the Back and Next buttons.- Overrides:
createButtonsForButtonBar
in classDialog
- Parameters:
parent
- the parent composite to contain the buttons
-
setButtonLayoutData
Description copied from class:Dialog
Set the layout data of the button to a GridData with appropriate heights and widths.- Overrides:
setButtonLayoutData
in classDialog
- Parameters:
button
- The button which layout data is to be set.
-
getButton
Return the cancel button if the id is a the cancel id. -
createContents
TheWizardDialog
implementation of thisWindow
method calls callIWizard.addPages
to allow the current wizard to add extra pages, thensuper.createContents
to create the controls. It then callsIWizard.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 classTitleAreaDialog
- Parameters:
parent
- the parent composite for the controls in this window. The type of layout used is determined by getLayout()- Returns:
- the control that will be returned by subsequent calls to getContents()
-
createDialogArea
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 newComposite
with no margins and spacing. Subclasses should override.- Overrides:
createDialogArea
in classTitleAreaDialog
- Parameters:
parent
- The parent composite to contain the dialog area- Returns:
- the dialog area control
-
createProgressMonitorPart
Hook method for subclasses to create a custom progress monitor part.The default implementation creates a progress monitor with a stop button will be created.
- Parameters:
composite
- the parent compositepmlayout
- the layout- Returns:
- ProgressMonitorPart the progress monitor part
-
finishPressed
protected void finishPressed()The Finish button has been pressed. -
getCurrentPage
Description copied from interface:IWizardContainer
Returns the current wizard page for this container.- Specified by:
getCurrentPage
in interfaceIWizardContainer
- Returns:
- the current wizard page, or
null
if the container is not yet showing the wizard - See Also:
-
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
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 This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable has been run, regardless of the value offork
. It is recommended thatfork
is set to true in most cases. Iffork
is set tofalse
, the runnable will run in the UI thread and it is the runnable's responsibility to callDisplay.readAndDispatch()
to ensure UI responsiveness. UI state is saved prior to executing the long-running operation and is restored after the long-running operation completes executing. Any attempt to change the UI state of the wizard in the long-running operation will be nullified when original UI state is restored.- Specified by:
run
in interfaceIRunnableContext
- Parameters:
fork
-true
if the runnable should be run in a separate thread, andfalse
to run in the same threadcancelable
-true
to enable the cancelation, andfalse
to make the operation uncancellablerunnable
- the runnable to run- Throws:
InvocationTargetException
- wraps any exception or error which occurs while running the runnableInterruptedException
- propagated by the context if the runnable acknowledges cancelation by throwing this exception. This should not be thrown if cancelable isfalse
.
-
setMinimumPageSize
public void setMinimumPageSize(int minWidth, int minHeight) Sets the minimum page size used for the pages.- Parameters:
minWidth
- the minimum page widthminHeight
- the minimum page height- See Also:
-
setMinimumPageSize
Sets the minimum page size used for the pages.- Parameters:
size
- the page size encoded asnew Point(width,height)
- See Also:
-
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 widthheight
- the page height- See Also:
-
setPageSize
Sets the size of all pages. The given size takes precedence over computed sizes.- Parameters:
size
- the page size encoded asnew Point(width,height)
- See Also:
-
setWizard
Sets the wizard this dialog is currently displaying.- Parameters:
newWizard
- the wizard
-
showPage
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 interfaceIWizardContainer
- Parameters:
page
- the page to show- See Also:
-
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 interfaceIWizardContainer
-
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 interfaceIWizardContainer
-
updateSize
Computes the correct dialog size for the current page and resizes its shell if necessary. Also causes the container to refresh its layout.- Parameters:
page
- the wizard page to use to resize the dialog- Since:
- 2.0
-
updateSize
public void updateSize()Description copied from interface:IWizardContainer2
Updates the window size 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 size change.
- Specified by:
updateSize
in interfaceIWizardContainer2
-
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 interfaceIWizardContainer
-
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 interfaceIWizardContainer
-
getSelectedPage
Description copied from interface:IPageChangeProvider
Returns the currently selected page in the dialog.- Specified by:
getSelectedPage
in interfaceIPageChangeProvider
- Returns:
- the selected page in the dialog or
null
if none is selected. The type may be domain specific. In the JFace provided dialogs this will be an instance ofIDialogPage
.
-
addPageChangedListener
Description copied from interface:IPageChangeProvider
Adds a listener for page changes in this page change provider. Has no effect if an identical listener is already registered.- Specified by:
addPageChangedListener
in interfaceIPageChangeProvider
- Parameters:
listener
- a page changed listener
-
removePageChangedListener
Description copied from interface:IPageChangeProvider
Removes the given page change listener from this page change provider. Has no effect if an identical listener is not registered.- Specified by:
removePageChangedListener
in interfaceIPageChangeProvider
- Parameters:
listener
- a page changed listener
-
firePageChanged
Notifies any selection changed listeners that the selected page has changed. Only listeners registered at the time this method is called are notified.- Parameters:
event
- a selection changed event- Since:
- 3.1
- See Also:
-
addPageChangingListener
Adds a listener for page changes to the list of page changing listeners registered for this dialog. Has no effect if an identical listener is already registered.- Parameters:
listener
- a page changing listener- Since:
- 3.3
-
removePageChangingListener
Removes the provided page changing listener from the list of page changing listeners registered for the dialog.- Parameters:
listener
- a page changing listener- Since:
- 3.3
-
firePageChanging
Notifies any page changing listeners that the currently selected dialog page is changing. Only listeners registered at the time this method is called are notified.- Parameters:
event
- a selection changing event- Since:
- 3.3
- See Also:
-
getDialogBoundsSettings
Description copied from class:Dialog
Gets the dialog settings that should be used for remembering the bounds of of the dialog, according to the dialog bounds strategy.- Overrides:
getDialogBoundsSettings
in classDialog
- Returns:
- settings the dialog settings used to store the dialog's location
and/or size, or
null
if the dialog's bounds should never be stored. - See Also:
-