|
Side of Software Wizard Library 1.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--sos.wizard.AbstractModel
|
+--sos.wizard.AbstractWizardModel
|
+--sos.wizard.DefaultWizardModel
A general-purpose wizard model that can handle both static (unconditional) and dynamic (conditional) pages.
The model maintains a list of pages, their corresponding transitions,
and a current position.
When stepNext is called, the model applies the transition
corresponding to the current page and then increments its position.
When stepBack is called, the model decrements its position
and then applies the transition corresponding to the revisited page.
When it reaches the page that is denoted as "last", the finish
operation becomes enabled. When the finish operation is executed,
the model runs the finish task and optionally sets the current
page to a "progress page." If the task completes successfully,
the model optionally sets the current page to a summary page.
To establish the sequence of pages that this wizard model should
step the user through, use addLast, push,
and removeLast.
To denote a page as the "last" page, use setLastPage. To
set the summary page, use setSummaryPage.
// create the pages Page page1 = ... Page page2 = ... Page page3 = ... // store the pages in an array Page[] pages = new Page[3]; pages[0] = page1; pages[1] = page2; pages[2] = page3; // create the wizard's task Task task = ... // create the optional summary page Page summaryPage = ... // create the static model WizardModel model = new DefaultWizardModel( pages, task, summaryPage );
// create an empty model
final DefaultWizardModel model = new DefaultWizardModel();
// create the first page, which will determine
// subsequent pages
final CustomPage page1 = ...
// create a transition that will update the model
// depending on the user's choice in page 1
DefaultWizardModelTransition transition
= new DefaultWizardModel.TransitionAdapter() {
public void stepNext()
{
if( page1.isOption1Selected() )
{
Page page2 = ...
Page page3 = ...
model.push( page2 ); // page2 becomes the next page
model.addLast( page3 ); // page3 comes after page2
model.setLastPage( page3 );
Task task = ...
model.setFinishTask( task );
}
else
{
Page page2 = ...
Page page3 = ...
Page page4 = ...
model.push( page2 ); // page2 becomes the next page
model.addLast( page3 ); // page3 comes after page2
model.addLast( page4 ); // page4 comes after page3
model.setLastPage( page4 );
Task task = ...
model.setFinishTask( task );
}
}
};
// add the first page with a custom transition
model.addLast( page1, transition );
DefaultWizardModel provides some methods to customize its
behavior:
setSupportsLast - Call this with
true if you want your model
to have the ability to bypass intermediate pages and jump
to the page currently denoted as "last".
setProgressPageIsUsed - Call this with
true if you want your model to use a progress page while
the finish task is executing. This only applies if the
finish task is not null.
setProgressPageName - Use this to set the name of
the progress page. This only applies if the progress page
is used.
| Nested Class Summary | |
static interface |
DefaultWizardModel.Transition
An action to carry out when the wizard leaves or returns to a page. |
static class |
DefaultWizardModel.TransitionAdapter
A convenience class that implements the Transition interface
with empty methods. |
| 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 | |
DefaultWizardModel()
Creates a DefaultWizardModel with no pages. |
|
DefaultWizardModel(Page[] pages,
Task finishTask,
Page summaryPage)
Creates a DefaultWizardModel with the specified pages
and finish task. |
|
DefaultWizardModel(Page initialPage,
DefaultWizardModel.Transition initialTransition)
Creates a DefaultWizardModel with the specified
initial page and initial transition. |
|
| Method Summary | |
void |
addLast(Page page)
Adds the specified page to the end of the current list of pages. |
void |
addLast(Page page,
DefaultWizardModel.Transition transition)
Adds the specified page to the end of the current list of pages and assigns it the specified transition. |
boolean |
canCancel()
Returns true if this wizard can be canceled. |
void |
cancel()
Cancels this wizard. |
boolean |
canFinish()
Returns true if this wizard allows the user to finish,
given the current state. |
boolean |
canStepBack()
Returns true if this wizard has a previous page. |
boolean |
canStepLast()
Returns true if this wizard can accept
the current values and advance to the last page. |
boolean |
canStepNext()
Returns true if this wizard has a subsequent page. |
protected ProgressPage |
createProgressPage(java.lang.String name,
Task finishTask)
Creates and returns a progress page with the specified name and task. |
void |
finish()
Ends this wizard. |
Page |
getCurrentPage()
Retrieves the page currently being processed. |
java.lang.Object |
getElementAt(int index)
Returns the step at the specified index. |
Task |
getFinishTask()
Returns the task to execute when the client "finishes" this model. |
Page |
getLastPage()
Returns the page currently denoted as "last". |
boolean |
getProgressPageIsUsed()
Returns true if this model uses a "progress page" while the
finish task is executing. |
java.lang.String |
getProgressPageName()
Returns the name to use for the progress page. |
java.lang.Object |
getSelectedItem()
Returns the current step. |
int |
getSize()
Returns the length of the list of steps. |
int |
getState()
Returns the state of this wizard. |
void |
push(Page page)
Removes any subsequent pages and appends the specified page to the end of the list. |
void |
push(Page page,
DefaultWizardModel.Transition transition)
Removes any subsequent pages and appends the specified page to the end of the list and assigns it the specified transition. |
void |
removeLast()
Removes this model's last page and transition. |
void |
setFinishTask(Task finishTask)
Sets the action to carry out when this model is finished. |
void |
setLastPage(Page lastPage)
Informs this wizards that the specified page serves as the last page. |
void |
setProgressPageIsUsed(boolean use)
Sets whether or not this model uses a "progress page" while the finish task is executing. |
void |
setProgressPageName(java.lang.String progressPageName)
Sets the name to use for the progress page. |
void |
setSelectedItem(java.lang.Object anItem)
Set the selected item. |
void |
setSummaryPage(Page summaryPage)
Sets the page to display after the finish task has completed successfully. |
void |
setSupportsLast(boolean supportsLast)
Sets whether or not this model should have the ability to bypass all intermediate pages and just to the last page. |
void |
stepBack()
Advances this wizard to the previous page. |
void |
stepLast()
Advances this wizard to the last step. |
void |
stepNext()
Advances this wizard to the next step. |
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.AbstractWizardModel |
addListDataListener, firePageChanged, fireStepsAdded, fireStepsChanged, fireStepsRemoved, removeListDataListener |
| 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.Model |
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener |
| Constructor Detail |
public DefaultWizardModel()
DefaultWizardModel with no pages.
public DefaultWizardModel(Page initialPage,
DefaultWizardModel.Transition initialTransition)
DefaultWizardModel with the specified
initial page and initial transition.
initialPage - first step in this wizard modelinitialTransition - action to carry out to transition from
the initial page
java.lang.NullPointerException - if initialPage or
initialTransition is nullDefaultWizardModel( Page[], Task, Page )
public DefaultWizardModel(Page[] pages,
Task finishTask,
Page summaryPage)
DefaultWizardModel with the specified pages
and finish task.
The wizard's last page is set to the last page in the array.
Use this constructor when all of the wizard's steps are unconditional.
finishTask may be null,
but a non-null task must
be supplied to setFinishTask before the wizard is finished.
A null summaryPage indicates
that there is no summary page
to display. This can be changed later with setSummaryPage.
pages - all of the unconditional steps of this wizard modelfinishTask - task to carry out when the last page is completedsummaryPage - page to display after finishedTask has completed
java.lang.NullPointerException - if pages is null or any
element of pages is nullDefaultWizardModel( Page, DefaultWizardModel.Transition )| Method Detail |
public void addLast(Page page)
page - step to add to this wizard
java.lang.NullPointerException - if page is nulladdLast( Page, DefaultWizardModel.Transition ),
push( Page )
public void addLast(Page page,
DefaultWizardModel.Transition transition)
page - step to add to this wizardtransition - action to carry out when page is finished
java.lang.NullPointerException - if page or transition is
nulladdLast( Page ),
push( Page, DefaultWizardModel.Transition )public boolean canCancel()
WizardModeltrue if this wizard can be canceled.
canCancel in interface WizardModelcanCancel in class AbstractWizardModeltrue if this wizard can be canceled.WizardModel.cancel()public boolean canFinish()
WizardModeltrue if this wizard allows the user to finish,
given the current state.
If this wizard is not in progress,
false is returned.
canFinish in interface WizardModelWizardModel.finish()public boolean canStepBack()
WizardModeltrue if this wizard has a previous page.
If this wizard is not in progress,
false is returned.
canStepBack in interface WizardModeltrue if this wizard has a previous pageWizardModel.canStepNext()public boolean canStepLast()
WizardModeltrue 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.
canStepLast in interface WizardModelcanStepLast in class AbstractWizardModeltrue if this wizard can advance to the last pageWizardModel.stepLast(),
WizardModel.supportsLast()public boolean canStepNext()
WizardModeltrue if this wizard has a subsequent page.
If this wizard is not in progress,
false is returned.
canStepNext in interface WizardModeltrue if this wizard has a subsequent pageWizardModel.canStepBack()
public void cancel()
throws java.lang.IllegalStateException
WizardModel
cancel in interface WizardModeljava.lang.IllegalStateException - if this wizard is not in progress
or canCancel returns falseWizardModel.canCancel()
protected ProgressPage createProgressPage(java.lang.String name,
Task finishTask)
name - name of the progress pagefinishTask - task for whose progress will be monitored
public void finish()
throws java.lang.IllegalStateException
WizardModel
finish in interface WizardModeljava.lang.IllegalStateException - if this wizard is not in progress
or canFinish returns falseWizardModel.canFinish()public Page getCurrentPage()
WizardModel
getCurrentPage in interface WizardModelpublic java.lang.Object getElementAt(int index)
WizardModel
getElementAt in interface WizardModelindex - the requested index
indexpublic Task getFinishTask()
setFinishTask(sos.wizard.Task)public boolean getProgressPageIsUsed()
true if this model uses a "progress page" while the
finish task is executing.
true if a progress page is usedsetProgressPageIsUsed(boolean)public java.lang.String getProgressPageName()
setProgressPageName(java.lang.String),
getProgressPageIsUsed()public java.lang.Object getSelectedItem()
WizardModel
getSelectedItem in interface WizardModelnull if there is nonepublic int getSize()
WizardModel
getSize in interface WizardModelpublic int getState()
WizardModel
getState in interface WizardModelWIZARD_IN_PROGRESS,
WIZARD_FINISHED, WIZARD_FINISHING,
and WIZARD_CANCELEDpublic Page getLastPage()
setLastPage(sos.wizard.Page)public void push(Page page)
page - step to add to this wizard
java.lang.NullPointerException - if page is nullpush( Page, DefaultWizardModel.Transition ),
addLast( Page )
public void push(Page page,
DefaultWizardModel.Transition transition)
page - step to add to this wizardtransition - action to carry out when page is finished
java.lang.NullPointerException - if page or transition is
nullpush( Page ),
addLast( Page, DefaultWizardModel.Transition )public void removeLast()
java.util.NoSuchElementException - if there are no pages in this modelpublic void setFinishTask(Task finishTask)
finishTask - the finish taskgetFinishTask()public void setLastPage(Page lastPage)
null lastPage
indicates that no last page has yet been specified.
lastPage - last step in this wizard (may be null)getLastPage()public void setProgressPageIsUsed(boolean use)
use - true if this model should use a progress pagegetProgressPageIsUsed()public void setProgressPageName(java.lang.String progressPageName)
progressPageName - the name to use for the progress pagegetProgressPageName(),
getProgressPageIsUsed()public void setSelectedItem(java.lang.Object anItem)
WizardModelUnsupportedOperationException.
setSelectedItem in interface WizardModelsetSelectedItem in class AbstractWizardModelanItem - the list object to select or null
to clear the selectionpublic void setSupportsLast(boolean supportsLast)
supportsLast - true if this wizard can jump to the last pagesupportsLast()public void setSummaryPage(Page summaryPage)
summaryPage - this model's summary page (may be null)public void stepBack()
WizardModel
stepBack in interface WizardModelWizardModel.canStepBack(),
WizardModel.stepNext()public void stepLast()
WizardModel
stepLast in interface WizardModelWizardModel.canStepLast(),
WizardModel.supportsLast()public void stepNext()
WizardModel
stepNext in interface WizardModelWizardModel.canStepNext(),
WizardModel.stepBack()public boolean supportsLast()
WizardModeltrue 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.
supportsLast in interface WizardModelsupportsLast in class AbstractWizardModeltrue if this wizard has the ability to
skip intermediate pages and advance to the last pageWizardModel.canStepLast()
|
Side of Software Wizard Library 1.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||