|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pietschy.wizard.AbstractWizardStep
public abstract class AbstractWizardStep
This is the base class for all non panel related wizard steps. Subclasses must implement the
abstract methods init(org.pietschy.wizard.WizardModel), WizardStep.prepare(), WizardStep.applyState() and
WizardStep.getPreferredSize(). In addition an appropriate UI must be installed by
calling setView(java.awt.Component).
The Wizard listens to property change events from the step and will update
accordingly when ever setView(java.awt.Component), setComplete(boolean) or setBusy(boolean) is called.
An example is shown below.
public class MyWizardStep
extends WizardStep
{
private MyModel model;
private JPanel mainView;
private JCheckBox agreeCheckbox;
private JTextArea license;
public MyWizardStep()
{
super("My First Step", "A summary of the first step");
// build and layout the components..
mainView = new JPanel();
agreeCheckbox = new JCheckBox("Agree");
license = new JTextArea();
mainView.setLayout(...);
mainView.add(agreeCheckbox);
...
// listen to changes in the state..
agreeCheckbox.addItemListener(new ItemListener()
{
public void itemSelected(ItemEvent e)
{
// only continue if they agree
MyWizardStep.this.setComplete(agreeCheckbox.isSelected());
}
});
}
public void init(WizardModel model)
{
this.model = (MyModel) model;
}
public void prepare()
{
// load our view...
setView(mainView);
}
public void applyState()
throws InvalidStateException
{
// display a progress bar of some kind..
setView(myProgressView);
setBusy(true);
try
{
// do some work on another thread.. see Foxtrot
...
}
finally
{
setBusy(false);
}
// if error then throw an exception
if (!ok)
{
// restore our original view..
setView(mainView)
throw new InvalidStateException("That didn't work!");
}
// this isn't really meaningful as we refuse to continue
// while the checkbox is un-checked.
model.setAcceptsLicense(agreeCheckbox.isSelected());
}
public void getPreferredSize()
{
// use the size of our main view...
return mainView.getPreferredSize();
}
}
| Field Summary |
|---|
| Fields inherited from interface org.pietschy.wizard.WizardStep |
|---|
_ID_ |
| Constructor Summary | |
|---|---|
AbstractWizardStep(java.lang.String name,
java.lang.String summary)
Creates a new step with the specified name and summary. |
|
AbstractWizardStep(java.lang.String name,
java.lang.String summary,
javax.swing.Icon icon)
Creates a new step with the specified name and summary. |
|
| Method Summary | |
|---|---|
void |
abortBusy()
Called by the wizard if the user presses cancel while the step is in a busy
state. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
|
javax.swing.Icon |
getIcon()
Gets the Icon that represents this step. |
java.lang.String |
getName()
Gets the name of this step. |
java.lang.String |
getSummary()
Gets the summary of this step. |
java.awt.Component |
getView()
Returns the current view this step is displaying. |
abstract void |
init(WizardModel model)
Called to initialize the step. |
boolean |
isBusy()
Checks if the current task is busy. |
boolean |
isComplete()
Checks if this step is compete. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
|
void |
setBusy(boolean busy)
Sets the busy state of this wizard step. |
void |
setComplete(boolean complete)
Marks this step as compete. |
void |
setIcon(javax.swing.Icon icon)
Sets the Icon that represents this step. |
void |
setName(java.lang.String name)
Sets the name of this step. |
void |
setSummary(java.lang.String summary)
Sets the summary of this step. |
protected void |
setView(java.awt.Component component)
Sets the current view this step is displaying. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.pietschy.wizard.WizardStep |
|---|
applyState, getPreferredSize, prepare |
| Constructor Detail |
|---|
public AbstractWizardStep(java.lang.String name,
java.lang.String summary)
name - the name of this step.summary - a brief summary of this step or some usage guidelines.
public AbstractWizardStep(java.lang.String name,
java.lang.String summary,
javax.swing.Icon icon)
name - the name of this step.summary - a brief summary of this step or some usage guidelines.| Method Detail |
|---|
public java.lang.String getName()
getName in interface WizardSteppublic void setName(java.lang.String name)
name - the name of this step.public java.lang.String getSummary()
getSummary in interface WizardSteppublic void setSummary(java.lang.String summary)
summary - the summary of this step.public javax.swing.Icon getIcon()
Icon that represents this step.
getIcon in interface WizardStepIcon that represents this step, or null if the step
doesn't have an icon.public void setIcon(javax.swing.Icon icon)
Icon that represents this step.
icon - the Icon that represents this step, or null if the step
doesn't have an icon.public java.awt.Component getView()
setView(java.awt.Component) and the wizard will update accordingly.
getView in interface WizardStepsetView(java.awt.Component)protected void setView(java.awt.Component component)
component - the current view of the step.public boolean isComplete()
setComplete(boolean) .
isComplete in interface WizardStepsetComplete(boolean)public void setComplete(boolean complete)
complete - true to allow the wizard to proceed, false otherwise.isComplete()public boolean isBusy()
isBusy in interface WizardStepWizardStep.abortBusy()public void setBusy(boolean busy)
Wizard steps that go into a busy state must also implement abortBusy() to cancel any
inprogress operation.
busy - true to mark the step as busy and disable further user action, false
to return the wizard to its normal state.public abstract void init(WizardModel model)
init in interface WizardStepmodel - the model to which the step belongs.public void abortBusy()
busy
state. Steps that are never busy need not override this method.
abortBusy in interface WizardSteppublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface WizardSteppublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface WizardStep
public void addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface WizardStep
public void removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface WizardStep
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||