kiwi.ui
Class WizardPanelSequence

java.lang.Object
  |
  +--kiwi.ui.WizardPanelSequence

public class WizardPanelSequence
extends Object
implements ChangeListener

This class serves as a factory of WizardPanels for a WizardView. A WizardPanelSequence maintains a set of WizardPanels and a Config object. When a WizardPanel is added to the sequence, a reference to the Config object is passed to the panel. The panel may use this Config object to store results from user input or to look up the current or default values for its input fields.

Whenever the value of a property is changed or a property is added to or removed from the Config object, the Config object notifies the WizardPanelSequence via a ChangeEvent. Subclassers may override the stateChanged() method to handle these events.

The goal of the Wizard family of classes was to provide a framework for creating wizards that was as flexible as possible, without creating a large amount of classes and interfaces to achieve that goal. Therefore the APIs for these classes may at first appear counterintuitive or inelegant. If they are found to be too cumbersome, they will be changed in a future release of Kiwi.

Version:
1.1 (11/98)
Author:
Mark Lindner, PING Software Group
See Also:
WizardView, WizardPanel, Config, ChangeEvent

Field Summary
protected  Config config
          The configuration object for this sequence.
protected  int currentIndex
          The index of the currently-selected WizardPanel.
protected  Vector panels
          The list of WizardPanels.
 
Constructor Summary
WizardPanelSequence()
          Construct a new WizardPanelSequence.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Add a ChangeListener to this object's list of listeners.
 void addPanel(WizardPanel panel)
          Add a WizardPanel to this sequence.
 void addPanels(WizardPanel[] panels)
          Add an array of WizardPanels to this sequence.
 boolean canMoveBackward()
          Determine if the user is allowed to move to the previous panel.
 boolean canMoveForward()
          Determine if the user is allowed to move to the next panel.
protected  void fireChangeEvent()
          Fire a change event.
 Config getConfig()
          Get a reference to this WizardPanelSequence's Config object.
 WizardPanel getNextPanel()
          Get the next panel from this sequence.
 WizardPanel getPreviousPanel()
          Get the previous panel from this sequence.
 boolean isLastPanel()
          Determine if the current panel is the last panel in the sequence.
 void removeChangeListener(ChangeListener listener)
          Remove a ChangeListener from this object's list of listeners.
 void reset()
          Reset the sequence.
 void stateChanged(ChangeEvent evt)
          Handle ChangeEvents fired by the WizardPanels that belong to this sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panels

protected Vector panels
The list of WizardPanels.

currentIndex

protected int currentIndex
The index of the currently-selected WizardPanel.

config

protected Config config
The configuration object for this sequence.
Constructor Detail

WizardPanelSequence

public WizardPanelSequence()
Construct a new WizardPanelSequence.
Method Detail

addPanel

public final void addPanel(WizardPanel panel)
Add a WizardPanel to this sequence. All panels should be added before the sequence is used to construct a WizardView.
Parameters:
panel - The panel to add.
See Also:
addPanels(kiwi.ui.WizardPanel[])

addPanels

public final void addPanels(WizardPanel[] panels)
Add an array of WizardPanels to this sequence. All panels should be added before the sequence is used to construct a WizardView.
Parameters:
panels - The panels to add.
See Also:
addPanel(kiwi.ui.WizardPanel)

reset

public void reset()
Reset the sequence. Resets the sequence so that the first panel in the sequence becomes the current panel; thus the next call to getNextPanel() will return the first panel in the sequence.
See Also:
getNextPanel()

getConfig

public final Config getConfig()
Get a reference to this WizardPanelSequence's Config object.
Returns:
The Config object.

getNextPanel

public WizardPanel getNextPanel()
Get the next panel from this sequence. The default implementation returns the next panel from the panels vector and increments the currentIndex variable only if the end of the sequence has not been reached and the next panel is reachable (e.g., if canMoveForward() returns true).
Returns:
The next panel to be displayed in the WizardView.

getPreviousPanel

public WizardPanel getPreviousPanel()
Get the previous panel from this sequence. The default implementation returns the previous panel from the panels vector and decrements the currentIndex variable only if the beginning of the sequence has not been reached and the previous panel is reachable (e.g., if canMoveBackward() returns true).
Returns:
The previous panel to be displayed in the WizardView.

isLastPanel

public boolean isLastPanel()
Determine if the current panel is the last panel in the sequence. Once the last panel in a sequence has been reached, th WizardView changes its Next button to a Finish button.
Returns:
true if the current panel is the last panel, and false otherwise.

canMoveForward

public boolean canMoveForward()
Determine if the user is allowed to move to the next panel. The default implementation returns true if the current panel is not the last panel in the sequence. Subclassers may wish to override this method to allow movement backward only if certain conditions are met.
Returns:
true if the previous panel is reachable, and false otherwise.

canMoveBackward

public boolean canMoveBackward()
Determine if the user is allowed to move to the previous panel. The default implementation returns

stateChanged

public void stateChanged(ChangeEvent evt)
Handle ChangeEvents fired by the WizardPanels that belong to this sequence. The default implementation does nothing; subclassers may wish to add logic to determine (based on the current values of properties in the Config object) whether movement to the next or previous panel is allowed, or to determine which panel will be displayed next, for example.
Specified by:
stateChanged in interface ChangeListener
Parameters:
evt - The event. The source of the event is the WizardPanel that fired it.
See Also:
EventObject.getSource()

addChangeListener

public void addChangeListener(ChangeListener listener)
Add a ChangeListener to this object's list of listeners.
Parameters:
listener - The listener to add.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Remove a ChangeListener from this object's list of listeners.
Parameters:
listener - The listener to remove.

fireChangeEvent

protected void fireChangeEvent()
Fire a change event. Notify listeners (typically only the WizardView that owns this sequence) that the state of this WizardPanelSequence has changed. Subclassers may wish to call this method from the body of the stateChanged() method if a change in the Config object has changed the state of this WizardPanelSequence in a way that will affect the appearance of the WizardView.