| |
|
| java.lang.Object org.pietschy.wizard.AbstractWizardStep
All known Subclasses: org.pietschy.wizard.pane.WizardPaneStep,
AbstractWizardStep | abstract public class AbstractWizardStep implements WizardStep(Code) | | This is the base class for all non panel related wizard steps. Subclasses must implement the
abstract methods
AbstractWizardStep.init ,
AbstractWizardStep.prepare ,
AbstractWizardStep.applyState and
AbstractWizardStep.getPreferredSize . In addition an appropriate UI must be installed by
calling
AbstractWizardStep.setView .
The
Wizard listens to property change events from the step and will update
accordingly when ever
AbstractWizardStep.setView ,
AbstractWizardStep.setComplete or
AbstractWizardStep.setBusy 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();
}
}
|
AbstractWizardStep | public AbstractWizardStep(String name, String summary)(Code) | | Creates a new step with the specified name and summary. The name and summary are displayed in
the wizard title block while this step is active.
Parameters: name - the name of this step. Parameters: summary - a brief summary of this step or some usage guidelines. |
AbstractWizardStep | public AbstractWizardStep(String name, String summary, Icon icon)(Code) | | Creates a new step with the specified name and summary. The name and summary are displayed in
the wizard title block while this step is active.
Parameters: name - the name of this step. Parameters: summary - a brief summary of this step or some usage guidelines. |
abortBusy | public void abortBusy()(Code) | | Called by the wizard if the user presses cancel while the step is in a
AbstractWizardStep.isBusy busy state. Steps that are never busy need not override this method.
|
getName | public String getName()(Code) | | Gets the name of this step. This will be displayed in the title of the wizard while this
step is active.
the name of this step. |
getSummary | public String getSummary()(Code) | | Gets the summary of this step. This will be displayed in the title of the wizard while this
step is active. The summary is typically an overview of the step or some usage guidelines
for the user.
the summary of this step. |
getView | public Component getView()(Code) | | Returns the current view this step is displaying. This component will be displayed in the main
section of the wizard with this step is active. This may changed at any time by calling
AbstractWizardStep.setView and the wizard will update accordingly.
the current view of the step. See Also: AbstractWizardStep.setView |
init | abstract public void init(WizardModel model)(Code) | | Called to initialize the step. This method will be called when the wizard is
first initialising.
Parameters: model - the model to which the step belongs. |
isBusy | public boolean isBusy()(Code) | | Checks if the current task is busy. This usually indicates that the step is performing
a time consuming task on a background thread.
true if step is busy performing a background operation, falseotherwise. |
setBusy | public void setBusy(boolean busy)(Code) | | Sets the busy state of this wizard step. This should usually be set when a time consuming
task is being performed on a background thread. The Wizard responds by disabling the various
buttons appropriately.
Wizard steps that go into a busy state must also implement
AbstractWizardStep.abortBusy to cancel any
inprogress operation.
Parameters: busy - true to mark the step as busy and disable further user action, falseto return the wizard to its normal state. |
setComplete | public void setComplete(boolean complete)(Code) | | Marks this step as compete. The wizard will not be able to proceed from this step until
this property is configured to true.
Parameters: complete - true to allow the wizard to proceed, false otherwise. See Also: AbstractWizardStep.isComplete |
setName | public void setName(String name)(Code) | | Sets the name of this step. This will be displayed in the title of the wizard while this
step is active.
Parameters: name - the name of this step. |
setSummary | public void setSummary(String summary)(Code) | | Sets the summary of this step. This will be displayed in the title of the wizard while this
step is active. The summary is typically an overview of the step or some usage guidelines
for the user.
Parameters: summary - the summary of this step. |
setView | protected void setView(Component component)(Code) | | Sets the current view this step is displaying. This component will be displayed in the main
section of the wizard with this step is active. This method may changed at any time and the
wizard will update accordingly.
Parameters: component - the current view of the step. |
|
|
|