org.springframework.richclient.wizard
Class AbstractWizard

java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.wizard.AbstractWizard
All Implemented Interfaces:
TitleConfigurable, Wizard
Direct Known Subclasses:
InstallWizard, NewOwnerWizard, SetupWizard

public abstract class AbstractWizard
extends ApplicationServicesAccessor
implements Wizard, TitleConfigurable

A convenience implementation of the Wizard interface. This abstract class provides the following basic wizard functionaliy:

Author:
Keith Donald

Field Summary
static String DEFAULT_IMAGE_KEY
          The key that will be used to retrieve the default page image icon for the wizard.
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Constructor Summary
AbstractWizard()
          Creates a new uninitialized AbstractWizard.
AbstractWizard(String wizardId)
          Creates a new AbstractWizard with the given identifier.
 
Method Summary
 WizardPage addForm(Form formPage)
          Adds a new page to this wizard.
protected  void addPage(String wizardConfigurationKey, WizardPage page)
          Adds a new page to this wizard.
 void addPage(WizardPage page)
          Adds a new page to this wizard.
 void addPages()
          This implementation of Wizard.addPages() does nothing.
 void addWizardListener(WizardListener wizardListener)
          Add a listener to this wizard
 boolean canFinish()
          Returns true if all the pages of this wizard have been completed.
protected  void fireCancelPerformed(boolean result)
          Fires an onPerformCancel event to all listeners.
protected  void fireFinishedPerformed(boolean result)
          Fires an onPerformFinish event to all listeners.
 WizardContainer getContainer()
          Returns the component that contains this wizard.
 Image getDefaultPageImage()
          Returns the image stored under the key "wizard.pageIcon".
 String getId()
          Returns this wizard's identifier.
 WizardPage getNextPage(WizardPage page)
          Returns the successor of the given page.
 WizardPage getPage(String pageId)
          Returns the wizard page with the given name belonging to this wizard.
 int getPageCount()
          Returns the number of pages in this wizard.
 WizardPage[] getPages()
          Returns all the pages in this wizard.
 WizardPage getPreviousPage(WizardPage page)
          Returns the predecessor of the given page.
 WizardPage getStartingPage()
          Returns the first page to be shown in this wizard.
 String getTitle()
          Returns the window title for the container that host this wizard.
 boolean needsPreviousAndNextButtons()
          Returns whether this wizard needs Previous and Next buttons.
protected  boolean onCancel()
          Subclasses can override this method to perform processing when the wizard receives a cancel request.
protected abstract  boolean onFinish()
          Subclasses must implement this method to perform any processing when the wizard receives a finish request.
 boolean performCancel()
          Performs any required processing when the wizard is cancelled, and then fires an appropriate event to any wizard listeners listening to this wizard.
 boolean performFinish()
          Performs any required processing when the wizard receives a finish request, and then fires an appropriate event to any wizard listeners listening to this wizard.
 void removePage(WizardPage page)
          Removes the given page from this wizard.
 void removeWizardListener(WizardListener wizardListener)
          Removes the given listener from this wizard.
 void setAutoConfigureChildPages(boolean autoConfigure)
          Sets the flag that determines whether or not wizard pages will be configured as they are added to this wizard.
 void setContainer(WizardContainer container)
          Sets the component that contains this wizard.
 void setForcePreviousAndNextButtons(boolean b)
          Controls whether the wizard needs Previous and Next buttons even if it currently contains only one page.
 void setTitle(String newTitle)
          Sets the window title for the container that hosts this page to the given string.
 
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_IMAGE_KEY

public static final String DEFAULT_IMAGE_KEY
The key that will be used to retrieve the default page image icon for the wizard.

See Also:
Constant Field Values
Constructor Detail

AbstractWizard

public AbstractWizard()
Creates a new uninitialized AbstractWizard.


AbstractWizard

public AbstractWizard(String wizardId)
Creates a new AbstractWizard with the given identifier.

Parameters:
wizardId - The id used to identify this wizard.
Method Detail

getId

public String getId()
Returns this wizard's identifier.

Specified by:
getId in interface Wizard
Returns:
the identifier of this wizard, may be null.

setAutoConfigureChildPages

public void setAutoConfigureChildPages(boolean autoConfigure)
Sets the flag that determines whether or not wizard pages will be configured as they are added to this wizard.

Parameters:
autoConfigure -

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

getTitle

public String getTitle()
Returns the window title for the container that host this wizard.

Specified by:
getTitle in interface Wizard
Returns:
the wizard title, may be null.

setTitle

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

Specified by:
setTitle in interface TitleConfigurable
Parameters:
newTitle - the window title for the container

getContainer

public WizardContainer getContainer()
Returns the component that contains this wizard.

Specified by:
getContainer in interface Wizard
Returns:
the wizard container.

setContainer

public void setContainer(WizardContainer container)
Sets the component that contains this wizard.

Specified by:
setContainer in interface Wizard
Parameters:
container - the container to set

addPage

public void addPage(WizardPage page)
Adds a new page to this wizard. The page is inserted at the end of the page list.

Parameters:
page - the new page

addPage

protected void addPage(String wizardConfigurationKey,
                       WizardPage page)
Adds a new page to this wizard. The page is inserted at the end of the page list.

Parameters:
wizardConfigurationKey - the parent configuration key of the page, used for configuration, by default this wizard's id *
page - the new page

addForm

public WizardPage addForm(Form formPage)
Adds a new page to this wizard. The page is created by wrapping the form in a FormBackedWizardPage and appending it to the end of the page list.

Parameters:
formPage - The form page to be added to the wizard.
Returns:
the newly created wizard page that wraps the given form.
Throws:
IllegalArgumentException - if formPage is null.

removePage

public void removePage(WizardPage page)
Removes the given page from this wizard.

Parameters:
page - The page to be removed.

addPages

public void addPages()
This implementation of Wizard.addPages() does nothing. Subclasses should override this method if extra pages need to be added before the wizard is displayed. New pages should be added by calling addPage(WizardPage).

Specified by:
addPages in interface Wizard

canFinish

public boolean canFinish()
Returns true if all the pages of this wizard have been completed.

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

getDefaultPageImage

public Image getDefaultPageImage()
Returns the image stored under the key "wizard.pageIcon".

Specified by:
getDefaultPageImage in interface Wizard
Returns:
the default page image
See Also:
ImageSource.getImage(String)

getNextPage

public WizardPage getNextPage(WizardPage page)
Returns the successor of the given page.

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

getPage

public WizardPage getPage(String pageId)
Returns the wizard page with the given name belonging to this wizard.

Specified by:
getPage in interface Wizard
Parameters:
pageId - the name of the wizard page
Returns:
the wizard page with the given name, or null if none

getPageCount

public int getPageCount()
Returns the number of pages in this wizard.

Specified by:
getPageCount in interface Wizard
Returns:
the number of wizard pages

getPages

public WizardPage[] getPages()
Returns all the pages in this wizard.

Specified by:
getPages in interface Wizard
Returns:
a list of pages

getPreviousPage

public WizardPage getPreviousPage(WizardPage page)
Returns the predecessor of the given page.

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

getStartingPage

public WizardPage getStartingPage()
Returns the first page to be shown in this wizard.

Specified by:
getStartingPage in interface Wizard
Returns:
the first wizard page

needsPreviousAndNextButtons

public boolean needsPreviousAndNextButtons()
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 Wizard
Returns:
true if Previous and Next buttons are required, and false if none are needed

addWizardListener

public void addWizardListener(WizardListener wizardListener)
Add a listener to this wizard

Specified by:
addWizardListener in interface Wizard
Parameters:
wizardListener - The listener to be added.

removeWizardListener

public void removeWizardListener(WizardListener wizardListener)
Removes the given listener from this wizard.

Specified by:
removeWizardListener in interface Wizard
Parameters:
wizardListener - The listener to be removed.

fireFinishedPerformed

protected void fireFinishedPerformed(boolean result)
Fires an onPerformFinish event to all listeners.


fireCancelPerformed

protected void fireCancelPerformed(boolean result)
Fires an onPerformCancel event to all listeners.


performFinish

public boolean performFinish()
Performs any required processing when the wizard receives a finish request, and then fires an appropriate event to any wizard listeners listening to this wizard.

Specified by:
performFinish in interface Wizard
Returns:
true to indicate that the finish request was accepted, false to indicate that it was refused.

performCancel

public boolean performCancel()
Performs any required processing when the wizard is cancelled, and then fires an appropriate event to any wizard listeners listening to this wizard.

Specified by:
performCancel in interface Wizard
Returns:
true to indicate that the cancel request was accepted, false to indicate that it was refused.

onFinish

protected abstract boolean onFinish()
Subclasses must implement this method to perform any processing when the wizard receives a finish request.

Returns:
true to indicate that the finish request was accepted, false to indicate that it was refused.

onCancel

protected boolean onCancel()
Subclasses can override this method to perform processing when the wizard receives a cancel request. This default implementation always returns true.



Copyright © 2004-2008 The Spring Framework. All Rights Reserved.