Side of Software
Wizard Library 1.6

sos.wizard
Class AbstractWizardModel

java.lang.Object
  |
  +--sos.wizard.AbstractModel
        |
        +--sos.wizard.AbstractWizardModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, Model, java.io.Serializable, WizardModel
Direct Known Subclasses:
DefaultWizardModel

public abstract class AbstractWizardModel
extends AbstractModel
implements java.io.Serializable, WizardModel

A partial implementation of the WizardModel interface. It handles the registration and notification of listeners and provides default responses to supportsLast, canStepLast, and canCancel.

A concrete subclass must implement the following methods:

  boolean canFinish()
  boolean canStepBack()
  boolean canStepNext()
  void cancel() throws IllegalStateException
  void finish() throws IllegalStateException
  Page getCurrentPage()
  Object getElementAt(int index)
  Object getSelectedItem()
  int getSize()
  int getState()
  void stepBack() throws IllegalStateException
  void stepLast() throws IllegalStateException
  void stepNext() throws IllegalStateException
Subclasses should invoke firePageChanged when the current page changes. This class listens to the current page. If the page's state changes, this class automatically checks if any of the canXxx methods have changed.

Subclasses should invoke fireStepsAdded, fireStepsChanged, or fireStepsRemoved when their steps change.

By default, this class always returns true for canCancel and false for supportsLast and canStepLast. Sublasses may override these for different behavior.

Since:
1.0

Field Summary
 
Fields inherited from interface sos.wizard.WizardModel
BACK_PROPERTY, CANCEL_PROPERTY, CURRENT_PAGE_PROPERTY, FINISH_PROPERTY, LAST_PROPERTY, NEXT_PROPERTY, STATE_PROPERTY, SUPPORTS_LAST_PROPERTY, WIZARD_CANCELED, WIZARD_FINISHED, WIZARD_FINISHING, WIZARD_IN_PROGRESS
 
Constructor Summary
AbstractWizardModel()
           
 
Method Summary
 void addListDataListener(javax.swing.event.ListDataListener listener)
          Adds a listener to the list that is notified each time a change to the data model occurs.
 boolean canCancel()
          Returns true if this wizard can be canceled.
 boolean canStepLast()
          Returns true if this wizard can accept the current values and advance to the last page.
protected  void firePageChanged(Page oldPage, Page newPage)
          Notifies property change listeners that the current pages has changed from oldPage to newPage.
protected  void fireStepsAdded(int index0, int index1)
          Notifies all listeners that steps have been added to the sequence.
protected  void fireStepsChanged(int index0, int index1)
          Notifies all listeners that the steps have changed or that the current step has changed.
protected  void fireStepsRemoved(int index0, int index1)
          Notifies all listeners that steps have been removed from the sequence.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Removes a listener from the list that is notified each time a change to the data model occurs.
 void setSelectedItem(java.lang.Object anItem)
          Set the selected item.
 boolean supportsLast()
          Returns true if this wizard has the ability to skip intermediate pages and advance to the last page.
 
Methods inherited from class sos.wizard.AbstractModel
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sos.wizard.WizardModel
cancel, canFinish, canStepBack, canStepNext, finish, getCurrentPage, getElementAt, getSelectedItem, getSize, getState, stepBack, stepLast, stepNext
 
Methods inherited from interface sos.wizard.Model
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

AbstractWizardModel

public AbstractWizardModel()
Method Detail

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener listener)
Description copied from interface: WizardModel
Adds a listener to the list that is notified each time a change to the data model occurs.

Specified by:
addListDataListener in interface WizardModel
Parameters:
listener - the ListDataListener to be added

canCancel

public boolean canCancel()
Description copied from interface: WizardModel
Returns true if this wizard can be canceled.

Specified by:
canCancel in interface WizardModel
Returns:
true if this wizard can be canceled.
See Also:
WizardModel.cancel()

canStepLast

public boolean canStepLast()
Description copied from interface: WizardModel
Returns true if this wizard can accept the current values and advance to the last page. If this wizard is not in progress or if this wizard does not support last, false is returned.

Specified by:
canStepLast in interface WizardModel
Returns:
true if this wizard can advance to the last page
See Also:
WizardModel.stepLast(), WizardModel.supportsLast()

firePageChanged

protected void firePageChanged(Page oldPage,
                               Page newPage)
Notifies property change listeners that the current pages has changed from oldPage to newPage.

Parameters:
oldPage - previous current page
newPage - new current page

fireStepsAdded

protected void fireStepsAdded(int index0,
                              int index1)
Notifies all listeners that steps have been added to the sequence.

Parameters:
index0 - start index of the change
index1 - end index (inclusive) of the change
See Also:
fireStepsChanged(int, int)

fireStepsChanged

protected void fireStepsChanged(int index0,
                                int index1)
Notifies all listeners that the steps have changed or that the current step has changed. To indicate the latter, pass in -1 for both index0 and index1.

Parameters:
index0 - start index of the change
index1 - end index (inclusive) of the change
See Also:
fireStepsAdded(int, int)

fireStepsRemoved

protected void fireStepsRemoved(int index0,
                                int index1)
Notifies all listeners that steps have been removed from the sequence.

Parameters:
index0 - start index of the change
index1 - end index (inclusive) of the change
See Also:
fireStepsChanged(int, int)

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Description copied from interface: WizardModel
Removes a listener from the list that is notified each time a change to the data model occurs.

Specified by:
removeListDataListener in interface WizardModel
Parameters:
l - the ListDataListener to be removed
See Also:
WizardModel.addListDataListener(javax.swing.event.ListDataListener)

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Description copied from interface: WizardModel
Set the selected item. This method is here only because it is a part of ComboBoxModel. Clients should assume this method throws an UnsupportedOperationException.

Specified by:
setSelectedItem in interface WizardModel
Parameters:
anItem - the list object to select or null to clear the selection

supportsLast

public boolean supportsLast()
Description copied from interface: WizardModel
Returns true if this wizard has the ability to skip intermediate pages and advance to the last page. Note that this method ignores the current state of this wizard. To check if this wizard can jump to the last page given the current state, use canStepLast. JWizard uses this property to determine if it should show the Last button.

Specified by:
supportsLast in interface WizardModel
Returns:
true if this wizard has the ability to skip intermediate pages and advance to the last page
See Also:
WizardModel.canStepLast()

Side of Software
Wizard Library 1.6

Copyright 2004-07 Side of Software (SOS). All rights reserved.