|
||||||||||
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.pietschy.wizard.PanelWizardStep
This is a base class for JPanel based wizard steps. Subclasses override the methods
init(org.pietschy.wizard.WizardModel)
, prepare()
, applyState()
.
The Wizard
listens to property change events from the step and will update
accordingly when ever setComplete(boolean)
or setBusy(boolean)
is called.
An example is shown below.
public class MyWizardStep extends PanelWizardStep { private MyModel model; private JCheckBox agreeCheckbox; private JTextArea license; public MyWizardStep() { super("My First Step", "A summary of the first step"); // build and layout the components.. agreeCheckbox = new JCheckBox("Agree"); license = new JTextArea(); setLayout(...); 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() { // read the model and configure the panel } public void applyState() throws InvalidStateException { // load a progress bar of some kind.. ... 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.. ...... 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(); } }
Nested Class Summary |
Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
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 org.pietschy.wizard.WizardStep |
_ID_ |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
PanelWizardStep()
A default constructor make this class JavaBean compatible. |
|
PanelWizardStep(java.lang.String name,
java.lang.String summary)
Creates a new step with the specified name and summary. |
|
PanelWizardStep(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 |
applyState()
This method is called whenever the user presses next while this step is active. |
javax.swing.Icon |
getIcon()
Gets the Icon that represents this step. |
java.lang.String |
getSummary()
Gets the summary of this step. |
java.awt.Component |
getView()
Returns 'this'. |
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 |
prepare()
Called to prepare this step to display. |
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 |
setSummary(java.lang.String summary)
Sets this steps summary. |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.pietschy.wizard.WizardStep |
addPropertyChangeListener, addPropertyChangeListener, getName, getPreferredSize, removePropertyChangeListener, removePropertyChangeListener |
Constructor Detail |
public PanelWizardStep()
public PanelWizardStep(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 PanelWizardStep(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 getSummary()
getSummary
in interface WizardStep
public 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 WizardStep
Icon
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()
getView
in interface WizardStep
public boolean isComplete()
setComplete(boolean)
.
isComplete
in interface WizardStep
setComplete(boolean)
public void setComplete(boolean complete)
complete
- true to allow the wizard to proceed, false otherwise.isComplete()
public boolean isBusy()
isBusy
in interface WizardStep
WizardStep.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 void init(WizardModel model)
init
in interface WizardStep
model
- the model to which the step belongs.public void prepare()
This method will be called whenever the step is to be displayed, regardless of whether the user pressed next or previous.
prepare
in interface WizardStep
public void applyState() throws InvalidStateException
If this method will take a long time to complete, subclasses should consider executing the work and a separate thread and displaying some kind of progress indicator.
This method will only be called if WizardModel.isNextAvailable()
and isComplete()
return true.
applyState
in interface WizardStep
InvalidStateException
- if an error occurs and the wizard can't progress to the next
step. By default the message of this exception will be displayed to the user. If you wish to
prevent this behaviour please ensure InvalidStateException.setShowUser(boolean)
is called with
a value of false.public void abortBusy()
busy
state. Steps that are never busy need not override this method.
abortBusy
in interface WizardStep
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |