|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.netbeans.spi.wizard.WizardPage
public class WizardPage extends javax.swing.JPanel implements WizardPanel
A convenience JPanel subclass that makes it easy to create wizard panels. This class provides a number of conveniences:
Automatic listening to child componentsname
property of the component has been set, then
the value from the component (i.e. Boolean for checkboxes, selected item(s)
for lists/combo boxes/trees, etc.) will automatically be added to the
wizard settings map, with the component name as the key.name
property is set,
validateContents()
will be called. You can override that method
to enable/disable the finish button, call setProblem()
to
disable navigation and display a string to the user, etc.
false
to the
appropriate constructor. In that case, validateContents
will
never be called automatically.
If you have custom components that WizardPage will not know how to listen
to automatically, attach an appropriate listener to them and optionally
call userInputReceived()
with the component and the event if
you want to run your automatic validation code.
For convenience, this class implements the relevant methods for accessing
the WizardController
and the settings map for the wizard that
the panel is a part of.
Instances of WizardPage can be returned from a WizardPanelProvider; this
class also offers two methods for conveniently assembling a wizard:
createWizard()
. Note that for large wizards, it is preferable
to construct the panels on demand rather than at construction time.public static String getDescription()
autoListen
constructor argument is true, a WizardPage
will automatically listen to components which have a name, if they are
standard Swing components it knows how to listen to. If you are using
custom components, implement WizardPage.CustomComponentListener and return
it from createCustomComponentListener()
to add supplementary
listening code for custom components.
Note: Swing components do not fire property changes when setName() is called.
If your component's values are not being propagated into the settings map,
make sure you are calling setName() before adding the component
to the hierarchy.
Also note that cell editors in tables and lists and so forth are always
ignored by the automatic listening code.
Modifier and Type | Class and Description |
---|---|
static class |
WizardPage.CustomComponentListener
Implement this class if you are using custom Swing or AWT components, and return an instance of it from WizardPage.createCustomComponentListener() . |
static class |
WizardPage.CustomComponentNotifier
Object which is passed to CustomComponentListener.startListeningTo() ,
which can be called when an event has occurred on a custom component the
CustomComponentListener has claimed (by returning true
from its accept() method). |
static interface |
WizardPage.WizardResultProducer
Interface that is passed to WizardPage.createWizard(). |
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Modifier and Type | Field and Description |
---|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Modifier | Constructor and Description |
---|---|
protected |
WizardPage()
Default constructor. |
protected |
WizardPage(boolean autoListen)
Use this constructor or the default constructor if you intend to pass an array of Class objects to lazily create WizardPanels. |
|
WizardPage(java.lang.String stepDescription)
Create an auto-listening WizardPage with the passed description |
|
WizardPage(java.lang.String stepDescription,
boolean autoListen)
Create a WizardPage with the passed description and auto-listening behavior. |
|
WizardPage(java.lang.String stepId,
java.lang.String stepDescription)
Create an auto-listening WizardPage with the passed description |
|
WizardPage(java.lang.String stepId,
java.lang.String stepDescription,
boolean autoListen)
Construct a new WizardPage with the passed step id and description. |
Modifier and Type | Method and Description |
---|---|
void |
addNotify()
|
WizardPanelNavResult |
allowBack(java.lang.String stepName,
java.util.Map settings,
Wizard wizard)
This method is invoked when the "back" button has been pushed, to discard any data from the setings that will not been needed and for which the normal "just hide that data" is not the desired behavior. |
WizardPanelNavResult |
allowFinish(java.lang.String stepName,
java.util.Map settings,
Wizard wizard)
This method is invoked when the "finish" button has been pushed, to allow veto of the finish action BEFORE the wizard finish method is invoked. |
WizardPanelNavResult |
allowNext(java.lang.String stepName,
java.util.Map settings,
Wizard wizard)
This method is invoked when the "next" button has been pushed, to do a final validation of input (such as doing a database login). |
protected WizardPage.CustomComponentListener |
createCustomComponentListener()
If you are using custom Swing or AWT components which the WizardPage will not know how to automatically listen to, you may want to override this method, implement CustomComponentListener and return an instance of it. |
static Wizard |
createWizard(java.lang.Class[] wizardPageClasses)
Create a simple Wizard from an array of classes, each of which is a unique subclass of WizardPage, with a no-op WizardResultProducer. |
static Wizard |
createWizard(java.lang.Class[] wizardPageClasses,
WizardPage.WizardResultProducer finisher)
Create simple Wizard from an array of classes, each of which is a unique subclass of WizardPage. |
static Wizard |
createWizard(java.lang.String title,
java.lang.Class[] wizardPageClasses)
Create simple Wizard from an array of classes, each of which is a unique subclass of WizardPage. |
static Wizard |
createWizard(java.lang.String title,
java.lang.Class[] wizardPageClasses,
WizardPage.WizardResultProducer finisher)
Create simple Wizard from an array of classes, each of which is a unique subclass of WizardPage. |
static Wizard |
createWizard(java.lang.String title,
WizardPage[] contents)
|
static Wizard |
createWizard(java.lang.String title,
WizardPage[] contents,
WizardPage.WizardResultProducer finisher)
|
static Wizard |
createWizard(WizardPage[] contents)
Create a simple Wizard from an array of WizardPages, with a no-op WizardResultProducer. |
static Wizard |
createWizard(WizardPage[] contents,
WizardPage.WizardResultProducer finisher)
Create a simple Wizard from an array of WizardPage s |
java.lang.String |
getLongDescription()
Get the long description of this page, which should be used in the title area of the wizard's UI if non-null. |
protected java.lang.Object |
getMapKeyFor(java.awt.Component c)
Get the map key that should be used to automatically put the value represented by this component into the wizard data map. |
protected java.lang.Object |
getWizardData(java.lang.Object key)
Retrieve a value stored in the wizard map, which may have been putWizardData there by this panel or any previous panel in the wizard which contains this panel. |
protected java.lang.Object[] |
getWizardDataKeys()
Returns all of the keys in the wizard data map. |
protected java.util.Map |
getWizardDataMap()
Get the settings map into which the wizard gathers settings. |
protected void |
putWizardData(java.lang.Object key,
java.lang.Object value)
Store a value in response to user interaction with a GUI component. |
protected void |
recycle()
Called if the user is navigating into this panel when it has already been displayed at least once - the user has navigated back to this panel, or back past this panel and is now navigating forward again. |
protected void |
renderingPage()
Called whenever the page is rendered. |
protected void |
setBusy(boolean busy)
Disable all navigation. |
protected void |
setForwardNavigationMode(int value)
Set whether the finish, next or both buttons should be enabled, assuming no problem string is set. |
protected void |
setLongDescription(java.lang.String desc)
Set the long description of this page. |
protected void |
setProblem(java.lang.String value)
Set the problem string. |
protected void |
userInputReceived(java.awt.Component source,
java.lang.Object event)
Called when an event is received from one of the components in the panel that indicates user input. |
protected java.lang.String |
validateContents(java.awt.Component component,
java.lang.Object event)
Called when user interaction has occurred on a component contained by this panel or one of its children. |
protected java.lang.Object |
valueFrom(java.awt.Component comp)
Given an ad-hoc swing component, fetch the likely value based on its state. |
protected void |
valueTo(java.util.Map settings,
java.awt.Component comp)
Given an ad-hoc swing component, set the value as the property from the settings. |
protected boolean |
wizardDataContainsKey(java.lang.Object key)
Determine if the wizard map contains the requested key. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WizardPage(java.lang.String stepDescription, boolean autoListen)
stepDescription
- the localized description of this stepautoListen
- if true, components added will automatically be
listened to for user inputpublic WizardPage(java.lang.String stepId, java.lang.String stepDescription, boolean autoListen)
createWizard
.
stepId
- the unique ID for the step represented. If null,
the class name or a variant of it will be usedstepDescription
- the localized description of this stepautoListen
- if true, components added will automatically be
listened to for user inputvalidateContents(java.awt.Component, java.lang.Object)
public WizardPage(java.lang.String stepDescription)
stepDescription
- the localized description of this steppublic WizardPage(java.lang.String stepId, java.lang.String stepDescription)
stepId
- The unique id for the step. If null, an id will be
generatedstepDescription
- the localized description of this stepprotected WizardPage(boolean autoListen)
protected WizardPage()
Method Detail |
---|
protected WizardPage.CustomComponentListener createCustomComponentListener()
public void addNotify()
addNotify
in class javax.swing.JComponent
public WizardPanelNavResult allowBack(java.lang.String stepName, java.util.Map settings, Wizard wizard)
WizardPanel
allowBack
in interface WizardPanel
public WizardPanelNavResult allowFinish(java.lang.String stepName, java.util.Map settings, Wizard wizard)
WizardPanel
allowFinish
in interface WizardPanel
public WizardPanelNavResult allowNext(java.lang.String stepName, java.util.Map settings, Wizard wizard)
WizardPanel
allowNext
in interface WizardPanel
protected void renderingPage()
public static Wizard createWizard(WizardPage[] contents, WizardPage.WizardResultProducer finisher)
WizardPage
s
public static Wizard createWizard(java.lang.String title, WizardPage[] contents, WizardPage.WizardResultProducer finisher)
public static Wizard createWizard(java.lang.String title, WizardPage[] contents)
public static Wizard createWizard(WizardPage[] contents)
public static Wizard createWizard(java.lang.Class[] wizardPageClasses, WizardPage.WizardResultProducer finisher)
public static Wizard createWizard(java.lang.String title, java.lang.Class[] wizardPageClasses, WizardPage.WizardResultProducer finisher)
public static Wizard createWizard(java.lang.String title, java.lang.Class[] wizardPageClasses)
public static Wizard createWizard(java.lang.Class[] wizardPageClasses)
protected final void setProblem(java.lang.String value)
protected final void setForwardNavigationMode(int value)
value
- WizardController.MODE_CAN_CONTINUE,
WizardController.MODE_CAN_FINISH or
WizardController.MODE_CAN_CONTINUE_OR_FINISH;protected final void setBusy(boolean busy)
protected final void putWizardData(java.lang.Object key, java.lang.Object value)
protected final java.lang.Object[] getWizardDataKeys()
protected final java.lang.Object getWizardData(java.lang.Object key)
protected final boolean wizardDataContainsKey(java.lang.Object key)
protected final void userInputReceived(java.awt.Component source, java.lang.Object event)
source
- The component that the user interacted with (if it can
be determined from the event) or nullevent
- Usually an instance of EventObject, except in the case of
DocumentEvent.protected java.lang.Object valueFrom(java.awt.Component comp)
protected void valueTo(java.util.Map settings, java.awt.Component comp)
protected java.lang.Object getMapKeyFor(java.awt.Component c)
c.getName()
,
which is almost always sufficient and convenient - just set the
component names in a GUI builder and everything will be handled.
protected java.lang.String validateContents(java.awt.Component component, java.lang.Object event)
setForwardNavigationMode()
if warranted.
This method also may be called with a null argument an effect of
calling putWizardData()
from someplace other than within
this method.
Note that this method may be called very frequently, so it is important
that validation code be fast. For cases such as DocumentEvent
s,
it may be desirable to delay validation with a timer, if the implementation
of this method is too expensive to call on each keystroke.
Either the component, or the event, or both may be null on some calls
to this method (such as when it is called because the settings map
has been written to).
The default implementation returns null.
component
- The component the user interacted with, if it can be
determined. The infrastructure does track the owners of list models
and such, and can find the associated component, so this will usually
(but not necessarily) be non-null.event
- The event object (if any) that triggered this call to
validateContents. For most cases this will be an instance of
EventObject, and can be used to directly detect what component
the user interacted with. Since javax.swing.text.DocumentEvent is
not a subclass of EventObject, the type of the argument is Object,
so these events may be passed.protected void recycle()
getWizardData()
.
The default implementation simply calls
validateContents (null, null)
.
protected java.util.Map getWizardDataMap()
protected void setLongDescription(java.lang.String desc)
desc
- The long description for this steppublic final java.lang.String getLongDescription()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |