wicket.extensions.wizard
Class WizardModel

java.lang.Object
  extended bywicket.extensions.wizard.WizardModel
All Implemented Interfaces:
IWizardModel, java.io.Serializable

public class WizardModel
extends java.lang.Object
implements IWizardModel

Default implementation of IWizardModel.

Steps can be added to this model directly using either the normal add method or the conditional add method.

Swing Wizard Framework served as a valuable source of inspiration.

Author:
Eelco Hillenius
See Also:
Serialized Form

Nested Class Summary
static interface WizardModel.ICondition
          Interface for conditional displaying of wizard steps.
 
Field Summary
static WizardModel.ICondition TRUE
          Condition that always evaluates true.
 
Constructor Summary
WizardModel()
          Construct.
 
Method Summary
 void add(IWizardStep step)
          Adds the next step to the wizard.
 void add(IWizardStep step, WizardModel.ICondition condition)
          Adds an optional step to the model.
 void addListener(IWizardModelListener listener)
          Adds a wizard model listener.
protected  boolean allStepsComplete()
          Returns true if all the steps in the wizard return true from IWizardStep.isComplete().
 void cancel()
          This implementation just fires a cancel event.
protected  IWizardStep findLastStep()
          Finds the last step in this model.
protected  IWizardStep findNextVisibleStep()
          Finds the next visible step based on the active step.
 void finish()
          This implementation just fires a finish event.
protected  void fireActiveStepChanged(IWizardStep step)
          Notify listeners that the active step has changed.
protected  void fireWizardCancelled()
          Notify listeners that the wizard is finished.
protected  void fireWizardFinished()
          Notify listeners that the wizard is finished.
 IWizardStep getActiveStep()
          Gets the current active step the wizard should display.
 boolean isCancelVisible()
          Gets whether cancel functionality is available.
 boolean isLastAvailable()
          Checks if the last button should be enabled.
 boolean isLastStep(IWizardStep step)
          Gets whether the specified step is the last step in the wizard.
 boolean isLastVisible()
          Checks if the last button should be displayed.
 boolean isNextAvailable()
          Checks if the next button should be enabled.
 boolean isPreviousAvailable()
          Checks if the previous button should be enabled.
 void lastStep()
          Takes the model to the last step in the wizard.
 void next()
          Increments the model the the next step.
 void previous()
          Takes the model to the previous step.This method must only be called if isPreviousAvailable() returns true.
 void removeListener(IWizardModelListener listener)
          Removes a wizard model listener.
 void reset()
          Resets the model, setting it to the first step.
 void setActiveStep(IWizardStep step)
          Sets the active step.
 void setCancelVisible(boolean cancelVisible)
          Sets whether cancel functionality is available.
 void setLastVisible(boolean lastVisible)
          Configures if the last button should be displayed.
 java.util.Iterator stepIterator()
          Returns an iterator over all the steps in the model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final WizardModel.ICondition TRUE
Condition that always evaluates true.

Constructor Detail

WizardModel

public WizardModel()
Construct.

Method Detail

add

public void add(IWizardStep step)
Adds the next step to the wizard. If the WizardStep implements WizardModel.ICondition, then this method is equivalent to calling add(step, (ICondition)step).

Parameters:
step - the step to added.

add

public void add(IWizardStep step,
                WizardModel.ICondition condition)
Adds an optional step to the model. The step will only be displayed if the specified condition is met.

Parameters:
step - The step to add
condition - the WizardModel.ICondition under which it should be included in the wizard.

addListener

public final void addListener(IWizardModelListener listener)
Adds a wizard model listener.

Specified by:
addListener in interface IWizardModel
Parameters:
listener - The listener to add

cancel

public void cancel()
This implementation just fires a cancel event. Though this isn't a very strong contract, it gives all the power to the user of this model.

Specified by:
cancel in interface IWizardModel
See Also:
IWizardModel.cancel()

finish

public void finish()
This implementation just fires a finish event. Though this isn't a very strong contract, it gives all the power to the user of this model.

Specified by:
finish in interface IWizardModel
See Also:
IWizardModel.finish()

getActiveStep

public final IWizardStep getActiveStep()
Gets the current active step the wizard should display.

Specified by:
getActiveStep in interface IWizardModel
Returns:
the active step.

isCancelVisible

public boolean isCancelVisible()
Gets whether cancel functionality is available.

Specified by:
isCancelVisible in interface IWizardModel
Returns:
Whether cancel functionality is available

isLastAvailable

public final boolean isLastAvailable()
Checks if the last button should be enabled.

Specified by:
isLastAvailable in interface IWizardModel
Returns:
true if the last button should be enabled, false otherwise.
See Also:
isLastVisible()

isLastStep

public boolean isLastStep(IWizardStep step)
Description copied from interface: IWizardModel
Gets whether the specified step is the last step in the wizard.

Specified by:
isLastStep in interface IWizardModel
Parameters:
step - the step to check
Returns:
True if its the final step in the wizard, false< otherwise.
See Also:
IWizardModel.isLastStep(wicket.extensions.wizard.IWizardStep)

isLastVisible

public boolean isLastVisible()
Checks if the last button should be displayed. This method should only return true if the isLastAvailable() will return true at any point. Returning false will prevent the last button from appearing on the wizard at all.

Specified by:
isLastVisible in interface IWizardModel
Returns:
true if the previou last should be displayed, false otherwise.

isNextAvailable

public final boolean isNextAvailable()
Checks if the next button should be enabled.

Specified by:
isNextAvailable in interface IWizardModel
Returns:
true if the next button should be enabled, false otherwise.

isPreviousAvailable

public final boolean isPreviousAvailable()
Checks if the previous button should be enabled.

Specified by:
isPreviousAvailable in interface IWizardModel
Returns:
true if the previous button should be enabled, false otherwise.

lastStep

public void lastStep()
Description copied from interface: IWizardModel
Takes the model to the last step in the wizard. This method must only be called if IWizardModel.isLastAvailable() returns true.

Specified by:
lastStep in interface IWizardModel
See Also:
IWizardModel.lastStep()

next

public void next()
Description copied from interface: IWizardModel
Increments the model the the next step. This method must only be called if IWizardModel.isNextAvailable() returns true.

Specified by:
next in interface IWizardModel
See Also:
IWizardModel.next()

previous

public void previous()
Description copied from interface: IWizardModel
Takes the model to the previous step.This method must only be called if IWizardModel.isPreviousAvailable() returns true.

Specified by:
previous in interface IWizardModel
See Also:
IWizardModel.previous()

removeListener

public final void removeListener(IWizardModelListener listener)
Removes a wizard model listener.

Specified by:
removeListener in interface IWizardModel
Parameters:
listener - The listener to remove

reset

public void reset()
Description copied from interface: IWizardModel
Resets the model, setting it to the first step.

Specified by:
reset in interface IWizardModel
See Also:
IWizardModel.reset()

setActiveStep

public void setActiveStep(IWizardStep step)
Sets the active step.

Parameters:
step - the new active step step.

setCancelVisible

public void setCancelVisible(boolean cancelVisible)
Sets whether cancel functionality is available.

Parameters:
cancelVisible - Whether cancel functionality is available

setLastVisible

public void setLastVisible(boolean lastVisible)
Configures if the last button should be displayed.

Parameters:
lastVisible - true to display the last button, false otherwise.
See Also:
isLastVisible()

stepIterator

public final java.util.Iterator stepIterator()
Description copied from interface: IWizardModel
Returns an iterator over all the steps in the model. The iteration order is not guarenteed to the be the order of traversal.

Specified by:
stepIterator in interface IWizardModel
Returns:
an iterator over all the steps of the model
See Also:
IWizardModel.stepIterator()

allStepsComplete

protected final boolean allStepsComplete()
Returns true if all the steps in the wizard return true from IWizardStep.isComplete(). This is primarily used to determine if the last button can be enabled.

Returns:
true if all the steps in the wizard are complete, false otherwise.

findLastStep

protected final IWizardStep findLastStep()
Finds the last step in this model.

Returns:
The last step

findNextVisibleStep

protected final IWizardStep findNextVisibleStep()
Finds the next visible step based on the active step.

Returns:
The next visible step based on the active step

fireActiveStepChanged

protected final void fireActiveStepChanged(IWizardStep step)
Notify listeners that the active step has changed.

Parameters:
step - The new step

fireWizardCancelled

protected final void fireWizardCancelled()
Notify listeners that the wizard is finished.


fireWizardFinished

protected final void fireWizardFinished()
Notify listeners that the wizard is finished.



Copyright © 2004-2008 Wicket developers. All Rights Reserved.