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 subclassesWizard
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 subclassingWizard
. Correct implementations ofIWizard
will work with any correct implementation ofIWizardPage
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_IMAGE
Image registry key of the default image for wizard pages (value"org.eclipse.jface.wizard.Wizard.pageImage"
).
-
Constructor Summary
Constructors Modifier Constructor Description protected
Wizard()
Creates a new empty wizard.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPage(IWizardPage page)
Adds a new page to this wizard.void
addPages()
TheWizard
implementation of thisIWizard
method does nothing.boolean
canFinish()
Returns whether this wizard could be finished without further user interaction.void
createPageControls(Composite pageContainer)
TheWizard
implementation of thisIWizard
method creates all the pages controls usingIDialogPage.createControl
.void
dispose()
TheWizard
implementation of thisIWizard
method disposes all the pages controls usingDialogPage.dispose
.IWizardContainer
getContainer()
Returns the container of this wizard.Image
getDefaultPageImage()
Returns the default page image for this wizard.IDialogSettings
getDialogSettings()
Returns the dialog settings for this wizard.IWizardPage
getNextPage(IWizardPage page)
Returns the successor of the given page.IWizardPage
getPage(String name)
Returns the wizard page with the given name belonging to this wizard.int
getPageCount()
Returns the number of pages in this wizard.IWizardPage[]
getPages()
Returns all the pages in this wizard.IWizardPage
getPreviousPage(IWizardPage page)
Returns the predecessor of the given page.Shell
getShell()
Returns the wizard's shell if the wizard is visible.IWizardPage
getStartingPage()
Returns the first page to be shown in this wizard.RGB
getTitleBarColor()
Returns the title bar color for this wizard.String
getWindowTitle()
Returns the window title string for this wizard.boolean
isHelpAvailable()
Returns whether help is available for this wizard.boolean
needsPreviousAndNextButtons()
Returns whether this wizard needs Previous and Next buttons.boolean
needsProgressMonitor()
Returns whether this wizard needs a progress monitor.boolean
performCancel()
TheWizard
implementation of thisIWizard
method does nothing and returnstrue
.abstract boolean
performFinish()
Subclasses must implement thisIWizard
method to perform any special finish processing for their wizard.void
setContainer(IWizardContainer wizardContainer)
Sets or clears the container of this wizard.void
setDefaultPageImageDescriptor(ImageDescriptor imageDescriptor)
Sets the default page image descriptor for this wizard.void
setDialogSettings(IDialogSettings settings)
Sets the dialog settings for this wizard.void
setForcePreviousAndNextButtons(boolean b)
Controls whether the wizard needs Previous and Next buttons even if it currently contains only one page.void
setHelpAvailable(boolean b)
Sets whether help is available for this wizard.void
setNeedsProgressMonitor(boolean b)
Sets whether this wizard needs a progress monitor.void
setTitleBarColor(RGB color)
Sets the title bar color for this wizard.void
setWindowTitle(String newTitle)
Sets the window title for the container that hosts this page to the given string.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
-
Method Detail
-
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()
TheWizard
implementation of thisIWizard
method does nothing. Subclasses should extend if extra pages need to be added before the wizard opens. New pages should be added by callingaddPage
.
-
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.
-
createPageControls
public void createPageControls(Composite pageContainer)
TheWizard
implementation of thisIWizard
method creates all the pages controls usingIDialogPage.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 interfaceIWizard
- Parameters:
pageContainer
- the parent control
-
dispose
public void dispose()
TheWizard
implementation of thisIWizard
method disposes all the pages controls usingDialogPage.dispose
. Subclasses should extend this method if the wizard instance maintains addition SWT resource that need to be disposed.
-
getContainer
public IWizardContainer getContainer()
Description copied from interface:IWizard
Returns the container of this wizard.- Specified by:
getContainer
in interfaceIWizard
- 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 interfaceIWizard
- 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 interfaceIWizard
- 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 interfaceIWizard
- 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.
-
getPageCount
public int getPageCount()
Description copied from interface:IWizard
Returns the number of pages in this wizard.- Specified by:
getPageCount
in interfaceIWizard
- Returns:
- the number of wizard pages
-
getPages
public IWizardPage[] getPages()
Description copied from interface:IWizard
Returns all the pages in this wizard.
-
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 interfaceIWizard
- 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. Otherwisenull
is returned.- Specified by:
getShell
in interfaceIShellProvider
- 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 interfaceIWizard
- 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 interfaceIWizard
- 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 interfaceIWizard
- Returns:
- the window title string, or
null
for no title
-
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 whenIDialogPage.performHelp()
is implemented.- Specified by:
isHelpAvailable
in interfaceIWizard
- Returns:
true
if help is available,false
otherwise- See Also:
TrayDialog.isHelpAvailable()
,TrayDialog.setHelpAvailable(boolean)
-
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 interfaceIWizard
- Returns:
true
if Previous and Next buttons are required, andfalse
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 interfaceIWizard
- Returns:
true
if a progress monitor is required, andfalse
if none is needed
-
performCancel
public boolean performCancel()
TheWizard
implementation of thisIWizard
method does nothing and returnstrue
. Subclasses should reimplement this method if they need to perform any special cancel processing for their wizard.- Specified by:
performCancel
in interfaceIWizard
- Returns:
true
to indicate the cancel request was accepted, andfalse
to indicate that the cancel request was refused
-
performFinish
public abstract boolean performFinish()
Subclasses must implement thisIWizard
method to perform any special finish processing for their wizard.- Specified by:
performFinish
in interfaceIWizard
- Returns:
true
to indicate the finish request was accepted, andfalse
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 interfaceIWizard
- Parameters:
wizardContainer
- the wizard container, ornull
-
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, ornull
if none- See Also:
getDialogSettings()
-
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, andfalse
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 whenIDialogPage.performHelp()
is implemented.- Parameters:
b
-true
if help is available,false
otherwise- See Also:
isHelpAvailable()
,TrayDialog.isHelpAvailable()
,TrayDialog.setHelpAvailable(boolean)
-
setNeedsProgressMonitor
public void setNeedsProgressMonitor(boolean b)
Sets whether this wizard needs a progress monitor.- Parameters:
b
-true
if a progress monitor is required, andfalse
if none is needed- See Also:
needsProgressMonitor()
-
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
-
-