|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.spi.wizard.WizardPanelProvider
public abstract class WizardPanelProvider extends java.lang.Object
(Note: WizardPage
offers somewhat simpler functionality for
creating a wizard than does WizardPanelProvider; the only advantage of
WizardPanelProvider
is that it does not require one to
subclass a panel component).
A simple interface for providing a fixed set of panels for a wizard.
To use, simply implement createPanel()
to create the
appropriate UI component for a given step (a unique String ID - one of the ones passed
in the constructor in the steps
array), and implement
finish()
to do whatever should be done when the wizard is
finished.
To control whether the Next/Finish buttons are enabled, components
created in createPanel()
should call methods on the
WizardController
passed. The created panels should listen on the
UI components they create, updating the settings Map when the user changes
their input.
Super-simple one-pane wizard example - if the checkbox is checked, the user can continue:
public class MyProvider extends WizardPanelProvider { public MyProvider() { //here we pass a localized title for the wizard, //the ID of the one step it will have, and a localized description //the wizard can show for that one step super ("Click the box", "click", "Click the checkbox"); } protected JComponent createPanel (final WizardController controller, String id, final Map settings) { //A quick sanity check assert "click".equals (id); //Remember this method will only be called once for any panel final JCheckBox result = new JCheckBox(); result.addActionListener (new ActionListener() { public void actionPerformed (ActionEvent ae) { //Typically you want to write the result of some user //action into the settings map as soon as they do it settings.put ("boxSelected", result.isSelected() ? Boolean.TRUE : Boolean.FALSE); if (result.isSelected()) { controller.setProblem(null); } else { controller.setProblem("The box is not checked"); } controller.setCanFinish(true); //won't matter if we called setProblem() with non-null } }); return result; } protected Object finish (Map settings) throws WizardException { //if we had some interesting information (Strings a user put in a //text field or something, we'd generate some interesting object or //create some files or something here return null; } }
Modifier | Constructor and Description |
---|---|
protected |
WizardPanelProvider(java.lang.String[] steps,
java.lang.String[] descriptions)
Create a WizardPanelProvider. |
protected |
WizardPanelProvider(java.lang.String title,
java.lang.String[] steps,
java.lang.String[] descriptions)
Create a WizardPanelProvider with the provided title, steps and descriptions. |
protected |
WizardPanelProvider(java.lang.String title,
java.lang.String singleStep,
java.lang.String singleDescription)
Convenience constructor to create a WizardPanelProvider which has only one step to it. |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(java.util.Map settings)
Called if the user invokes cancel. |
protected abstract javax.swing.JComponent |
createPanel(WizardController controller,
java.lang.String id,
java.util.Map settings)
Create a panel that represents a named step in the wizard. |
Wizard |
createWizard()
Create a Wizard for this PanelProvider. |
protected java.lang.Object |
finish(java.util.Map settings)
Instantiate whatever object (if any) the wizard creates from its gathered data. |
java.lang.String |
getLongDescription(java.lang.String stepId)
This method can optionally be overridden to provide a longer description of a step to be shown in the top of its panel. |
protected int |
indexOfStep(java.lang.String id)
Convenience method to get the index into the array of steps passed to the constructor of a specific step id. |
protected void |
recycleExistingPanel(java.lang.String id,
WizardController controller,
java.util.Map wizardData,
javax.swing.JComponent panel)
The method provides a chance to call setProblem() or setCanFinish() when the user re-navigates to a panel they've already seen - in the case that the user pressed the Previous button and then the Next button. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected WizardPanelProvider(java.lang.String[] steps, java.lang.String[] descriptions)
WizardBranchController
, where the first pane
will determine the title, and the titles of the sub-wizards will never be
shown.
steps
- A set of unique IDs identifying each step of this wizard. Each
ID must occur only once in the array of steps.descriptions
- A set of human-readable descriptions corresponding
1:1 with the unique IDs passed as the steps
parameterprotected WizardPanelProvider(java.lang.String title, java.lang.String[] steps, java.lang.String[] descriptions)
steps
parameter are unique IDs of
panels, which will be passed to createPanel
to create
panels for various steps in the wizard, as the user navigates it.
The descriptions
parameter is a set of localized descriptions
that can appear in the Wizard to describe each step.
title
- A human readable title for the wizard dialogsteps
- An array of unique IDs for the various panels of this
wizarddescriptions
- An array of descriptions corresponding 1:1 with the
unique IDs. These must be human readable, localized strings.protected WizardPanelProvider(java.lang.String title, java.lang.String singleStep, java.lang.String singleDescription)
WizardBranchController
.
title
- A human readable title for the wizard dialogsingleStep
- The unique ID of the only step this wizard hassingleDescription
- The human-readable description of what the user
should do in the one step of this one-step wizard or sub-wizardMethod Detail |
---|
protected abstract javax.swing.JComponent createPanel(WizardController controller, java.lang.String id, java.util.Map settings)
setProblem()
and setCanFinish()
as
appropriate in response to user input.
controller
- - the object which controls whether the
Next/Finish buttons in the wizard are enabled, and what instructions
are displayed to the user if they are notid
- The name of the step, one of the array of steps passed in
the constructorsettings
- A Map containing settings from earlier steps in
the wizard. It is safe to retain a reference to this map and put
values in it as the user manipulates the UI; the reference should
be refreshed whenever this method is called again.protected java.lang.Object finish(java.util.Map settings) throws WizardException
If an instance of Summary
is returned from this method, the
UI shall display it on a final page and disable all navigation buttons
except the Close/Cancel button.
If an instance of DeferredWizardResult
is returned from this
method, the UI shall display some sort of progress bar while the result
is computed in the background. If that DeferredWizardResult
produces a Summary
object, that summary shall be displayed
as described above.
The default implementation returns the settings map it is passed.
settings
- The settings map, now fully populated with all settings needed
to complete the wizard (this method will only be called if
setProblem(null)
and setCanFinish(true)
have
been called on the WizardController
passed to
createPanel()
.DeferredWizardResult
or Summary
is returned from this method.WizardException
protected void recycleExistingPanel(java.lang.String id, WizardController controller, java.util.Map wizardData, javax.swing.JComponent panel)
The default implementation does nothing, which is sufficient for most cases. If whether this panel is valid or not could have changed because of changed data from a previous panel, or it displays data entered on previous panes which may have changed, you may want to override this method to ensure validity and canFinish are set correctly, and that the components have the correct text.
This method will not be called when a panel is first instantiated -
createPanel()
is expected to set validity and canFinish
appropriately.
The settings Map passed to this method will always be the same
Settings map instance that was passed to createPanel()
when the panel was created.
If you are implementing WizardPanelProvider and some of the pages are
WizardPage
s, you should call the super implementation if
you override this method.
public final Wizard createWizard()
public java.lang.String getLongDescription(java.lang.String stepId)
stepId
- a unique id for one step of the wizardprotected final int indexOfStep(java.lang.String id)
public boolean cancel(java.util.Map settings)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |