sk.uniba.euromath.editor.wizards
Class MultiWizard

java.lang.Object
  extended by sk.uniba.euromath.editor.wizards.MultiWizard
All Implemented Interfaces:
IWizard

public class MultiWizard
extends Object
implements IWizard

Multi-wizard switcher. Each wizard it encapsulates must comply to these rules:

This wizard guarantees that

This wizard does not support any dialog settings - setting them has no effect.

Author:
Martin Vysny

Nested Class Summary
protected  class MultiWizard.PageLocator
          Locates page.
 
Field Summary
protected  IdentityHashMap<IWizard,List<BaseWizardPage>> pages
          Contains pages created by the wizards.
protected  IMultiWizardProvider provider
          Provides switcher with wizard instances.
protected  List<IWizard> wizards
          Contains list of wizards.
 
Constructor Summary
MultiWizard(IMultiWizardProvider provider)
          Creates instance of wizard switcher.
 
Method Summary
 boolean canFinish()
          Returns whether this wizard could be finished without further user interaction.
 BaseWizardPage current()
          Fetches the current page.
protected  void deletePagesAfter(MultiWizard.PageLocator locator, boolean including)
          Deletes all pages after given page.
 void dispose()
          Disposes of this wizard.
protected  MultiWizard.PageLocator getActivePage()
          Returns active (last) page.
protected  IWizard getActiveWizard()
          Returns active wizard - the last item of wizards array.
 String getName()
          Returns name of this wizard.
protected  MultiWizard.PageLocator getPage(BaseWizardPage page)
          Finds given page and returns its location in the wizards and pages properties.
 IMultiWizardProvider getProvider()
          Returns the provider instance.
protected  BaseWizardPage getStartingPage()
          Retrieves the first page of the first wizard.
 RGB getTitleBarColor()
          Returns the title bar color for this wizard.
 boolean hasNext()
          Checks if there is next page.
 boolean hasPrevious()
          Checks if there is previous page.
 BaseWizardPage next()
          Fetches the next page.
 boolean performCancel()
          Performs any actions appropriate in response to the user having pressed the Cancel button, or refuse if canceling now is not permitted.
 boolean performFinish()
          Performs any actions appropriate in response to the user having pressed the Finish button, or refuse if finishing now is not permitted.
 BaseWizardPage previous()
          Fetches the previous page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

provider

protected final IMultiWizardProvider provider
Provides switcher with wizard instances.


wizards

protected final List<IWizard> wizards
Contains list of wizards. Last wizard is always the active wizard.


pages

protected final IdentityHashMap<IWizard,List<BaseWizardPage>> pages
Contains pages created by the wizards.

Constructor Detail

MultiWizard

public MultiWizard(IMultiWizardProvider provider)
Creates instance of wizard switcher.

Parameters:
provider - provides switcher with wizard instances.
Method Detail

getActiveWizard

protected final IWizard getActiveWizard()
Returns active wizard - the last item of wizards array.

Returns:
active wizard.

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.

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

dispose

public void dispose()
Description copied from interface: IWizard
Disposes of this wizard. All SWT resources are freed automatically when this method finishes.

Specified by:
dispose in interface IWizard

getPage

protected MultiWizard.PageLocator getPage(BaseWizardPage page)
Finds given page and returns its location in the wizards and pages properties.

Parameters:
page - page to find
Returns:
the page location, never null.

getActivePage

protected MultiWizard.PageLocator getActivePage()
Returns active (last) page.

Returns:
locator of active page.

deletePagesAfter

protected void deletePagesAfter(MultiWizard.PageLocator locator,
                                boolean including)
Deletes all pages after given page. Disposes all unused wizards automatically.

Parameters:
locator - the locator of the page.
including - if true then page itself will be deleted. In this case the locator must not denote starting page.

hasNext

public boolean hasNext()
Description copied from interface: IWizard
Checks if there is next page. This method must return false if current page contains errors.

Specified by:
hasNext in interface IWizard
Returns:
true if there is next wizard or false if next() will fail.

current

public BaseWizardPage current()
Description copied from interface: IWizard
Fetches the current page.

Specified by:
current in interface IWizard
Returns:
current page. May return null only if the provider provides no pages.

getName

public String getName()
Description copied from interface: IWizard
Returns name of this wizard. Describes this wizard. Shown in the dialog.

Specified by:
getName in interface IWizard
Returns:
displayable wizard name, like 'New element contents'.

next

public BaseWizardPage next()
                    throws ProviderException
Description copied from interface: IWizard
Fetches the next page. Function may fail even when hasNext() returned true - it may throw ProviderException.

Specified by:
next in interface IWizard
Returns:
next page. The page does not have to be initialized - MultiWizard initializes it for you. Never null.
Throws:
ProviderException - if next page instance cannot be constructed because of to some unexpected error. In such case, wizard stays at current page, exception is logged and an error dialog is shown.

hasPrevious

public boolean hasPrevious()
Description copied from interface: IWizard
Checks if there is previous page.

Specified by:
hasPrevious in interface IWizard
Returns:
true if there is previous wizard or false if previous() will fail.

previous

public BaseWizardPage previous()
Description copied from interface: IWizard
Fetches the previous page. Current page is automatically disposed.

Specified by:
previous in interface IWizard
Returns:
previous page.

getStartingPage

protected final BaseWizardPage getStartingPage()
Retrieves the first page of the first wizard.

Returns:
first page instance.

getTitleBarColor

public RGB getTitleBarColor()
Description copied from interface: IWizard
Returns the title bar color for this wizard.

Specified by:
getTitleBarColor in interface IWizard
Returns:
the title bar color, or null if default should be used.

performCancel

public boolean performCancel()
Description copied from interface: IWizard
Performs any actions appropriate in response to the user having pressed the Cancel button, or refuse if canceling now is not permitted.

Specified by:
performCancel in interface IWizard
Returns:
true to indicate the cancel request was accepted, and false to indicate that the cancel request was refused

performFinish

public boolean performFinish()
Description copied from interface: IWizard
Performs any actions appropriate in response to the user having pressed the Finish button, or refuse if finishing now is not permitted. Normally this method is only called on the container's current wizard. However if the current wizard is a nested wizard this method will also be called on all wizards in its parent chain. Such parents may use this notification to save state etc. However, the value the parents return from this method is ignored.

Specified by:
performFinish in interface IWizard
Returns:
true to indicate the finish request was accepted, and false to indicate that the finish request was refused

getProvider

public final IMultiWizardProvider getProvider()
Returns the provider instance. The provider's next() and previous() methods must not be called.

Returns:
the provider instance.


Copyright © 2003-2006 null. All Rights Reserved.