public class WizardDialog extends TitleAreaDialog implements IWizardContainer2, IPageChangeProvider
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.
Modifier and Type | Class and Description |
---|---|
protected class |
WizardDialog.PageContainerFillLayout
A layout for a container which includes several pages, like a notebook,
wizard, or preference dialog.
|
Window.IExceptionHandler
Modifier and Type | Field and Description |
---|---|
static String |
WIZ_IMG_ERROR
Image registry key for error message image (value
"dialog_title_error_image" ). |
DLG_IMG_TITLE_BANNER, DLG_IMG_TITLE_ERROR, INFO_MESSAGE, WARNING_MESSAGE
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
CANCEL, OK, resizeHasOccurred
Constructor and Description |
---|
WizardDialog(Shell parentShell,
IWizard newWizard)
Creates a new wizard dialog for the given wizard.
|
Modifier and Type | Method and Description |
---|---|
void |
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 |
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 void |
createButtonsForButtonBar(Composite parent)
Creates the buttons for 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 ProgressMonitorPart |
createProgressMonitorPart(Composite composite,
GridLayout pmlayout)
Hook method for subclasses to create a custom progress monitor part.
|
protected void |
finishPressed()
The Finish button has been pressed.
|
protected void |
firePageChanged(PageChangedEvent event)
Notifies any selection changed listeners that the selected page has
changed.
|
protected void |
firePageChanging(PageChangingEvent event)
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.
|
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).
|
Object |
getSelectedPage()
Returns the currently selected page in the dialog.
|
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 |
removePageChangedListener(IPageChangedListener listener)
Removes the given page change listener from this page change provider.
|
void |
removePageChangingListener(IPageChangingListener listener)
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 of
fork . |
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.
|
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.
|
void |
updateSize()
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 |
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.
|
getErrorMessage, getInitialSize, getMessage, getTitleArea, getTitleImageLabel, setErrorMessage, setMessage, setMessage, setTitle, setTitleAreaColor, setTitleImage
closeTray, createButtonBar, createHelpControl, getLayout, getTray, handleShellCloseEvent, isDialogHelpAvailable, isHelpAvailable, openTray, setDialogHelpAvailable, setHelpAvailable
applyDialogFont, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, create, createButton, dialogFontIsDefault, getBlockedHandler, getButtonBar, getCancelButton, getDialogArea, getDialogBoundsSettings, getDialogBoundsStrategy, getImage, getInitialLocation, getOKButton, initializeBounds, initializeDialogUnits, isResizable, okPressed, setBlockedHandler, setButtonLayoutFormData, shortenText
canHandleShellCloseEvent, constrainShellSize, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getShell
public static final String WIZ_IMG_ERROR
"dialog_title_error_image"
).protected void backPressed()
protected void buttonPressed(int buttonId)
Dialog
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.
buttonPressed
in class Dialog
buttonId
- the id of the button that was pressed (see
IDialogConstants.*_ID
constants)protected void cancelPressed()
Dialog
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.
cancelPressed
in class Dialog
public boolean close()
Window
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 result ShellListener
s
will not receive a shellClosed
event.
close
in class Dialog
true
if the window is (or was already) closed, and
false
if it is still openWindow.close()
protected void configureShell(Shell newShell)
Window
The default implementation of this framework method sets the shell's image and gives it a grid layout. Subclasses may extend or reimplement.
configureShell
in class Window
newShell
- the shellprotected void createButtonsForButtonBar(Composite parent)
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.
createButtonsForButtonBar
in class Dialog
parent
- the parent composite to contain the buttonsprotected void setButtonLayoutData(Button button)
Dialog
setButtonLayoutData
in class Dialog
protected Button getButton(int id)
getButton
in class Dialog
id
- the button idDialog.createButton(Composite, int, String, boolean)
protected Control createContents(Composite parent)
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.createContents
in class TitleAreaDialog
parent
- the parent composite for the controls in this window. The type
of layout used is determined by getLayout()protected Control createDialogArea(Composite parent)
TitleAreaDialog
The Dialog
implementation of this framework method creates
and returns a new Composite
with no margins and spacing.
Subclasses should override.
createDialogArea
in class TitleAreaDialog
parent
- The parent composite to contain the dialog areaprotected ProgressMonitorPart createProgressMonitorPart(Composite composite, GridLayout pmlayout)
The default implementation creates a progress monitor with a stop button will be created.
composite
- the parent compositepmlayout
- the layoutprotected void finishPressed()
public IWizardPage getCurrentPage()
IWizardContainer
getCurrentPage
in interface IWizardContainer
null
if the container
is not yet showing the wizardIWizardContainer.showPage(org.eclipse.jface.wizard.IWizardPage)
protected IProgressMonitor getProgressMonitor()
null
if this wizard
dialog does not have oneprotected IWizard getWizard()
protected void helpPressed()
protected void nextPressed()
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
fork
. It is recommended that
fork
is set to true in most cases. If fork
is set to false
, the runnable will run in the UI thread
and it is the runnable's responsibility to call
Display.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.run
in interface IRunnableContext
fork
- true
if the runnable should be run in a separate thread,
and false
to run in the same threadcancelable
- true
to enable the cancelation, and
false
to make the operation uncancellablerunnable
- the runnable to runInvocationTargetException
- 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 is false
.public void setMinimumPageSize(int minWidth, int minHeight)
minWidth
- the minimum page widthminHeight
- the minimum page heightsetMinimumPageSize(Point)
public void setMinimumPageSize(Point size)
size
- the page size encoded as new Point(width,height)
setMinimumPageSize(int,int)
public void setPageSize(int width, int height)
width
- the page widthheight
- the page heightsetPageSize(Point)
public void setPageSize(Point size)
size
- the page size encoded as new Point(width,height)
setPageSize(int,int)
protected void setWizard(IWizard newWizard)
newWizard
- the wizardpublic void showPage(IWizardPage page)
IWizardContainer
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.
showPage
in interface IWizardContainer
page
- the page to showIWizardContainer.getCurrentPage()
protected void update()
public void updateButtons()
IWizardContainer
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.
updateButtons
in interface IWizardContainer
public void updateMessage()
IWizardContainer
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.
updateMessage
in interface IWizardContainer
protected void updateSize(IWizardPage page)
page
- the wizard page to use to resize the dialogpublic void updateSize()
IWizardContainer2
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.
updateSize
in interface IWizardContainer2
public void updateTitleBar()
IWizardContainer
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.
updateTitleBar
in interface IWizardContainer
public void updateWindowTitle()
IWizardContainer
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.
updateWindowTitle
in interface IWizardContainer
public Object getSelectedPage()
IPageChangeProvider
getSelectedPage
in interface IPageChangeProvider
null
if none is
selected. The type may be domain specific. In
the JFace provided dialogs this will be an instance of
IDialogPage
.public void addPageChangedListener(IPageChangedListener listener)
IPageChangeProvider
addPageChangedListener
in interface IPageChangeProvider
listener
- a page changed listenerpublic void removePageChangedListener(IPageChangedListener listener)
IPageChangeProvider
removePageChangedListener
in interface IPageChangeProvider
listener
- a page changed listenerprotected void firePageChanged(PageChangedEvent event)
event
- a selection changed eventIPageChangedListener.pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
public void addPageChangingListener(IPageChangingListener listener)
listener
- a page changing listenerpublic void removePageChangingListener(IPageChangingListener listener)
listener
- a page changing listenerprotected void firePageChanging(PageChangingEvent event)
event
- a selection changing eventIPageChangingListener.handlePageChanging(PageChangingEvent)
Copyright (c) 2000, 2016 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.