org.openbp.swing.components.wizard
Class WizardImpl

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.openbp.swing.components.wizard.WizardImpl
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener, Wizard

public class WizardImpl
extends javax.swing.JPanel
implements Wizard, javax.swing.event.ChangeListener

Wizard component.

Author:
Heiko Erhardt
See Also:
Serialized Form

Nested Class Summary
 
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
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
WizardImpl()
          Constructor.
WizardImpl(ResourceCollection wizardResourceCollection)
          Constructor.
WizardImpl(ResourceCollection wizardResourceCollection, javax.swing.ImageIcon defaultWizardImage)
          Constructor.
WizardImpl(ResourceCollection wizardResourceCollection, javax.swing.ImageIcon defaultWizardImage, javax.swing.ImageIcon defaultBackgroundImage)
          Constructor.
 
Method Summary
 void addAndLinkPage(java.lang.String name, java.awt.Component page)
          Adds a page to the wizard and links it into the sequence manager's list.
 void addPage(java.lang.String name, java.awt.Component page)
          Adds a page to the wizard, but does not link it into the sequence manager's list.
 void addWizardListener(WizardListener listener)
          Adds a wizard event listener.
 boolean canCancel()
          Determines if we can cancel the wizard dialog at this point.
 void cancel()
          Cancels the wizard.
 boolean canFinish()
          Determines if we can finish the wizard dialog at this point.
 boolean canMoveBackward()
          Determines if we can return to the previous page.
 boolean canMoveForward()
          Determines if we can advance to the next page.
 void clearPages()
          Clears the wizard pages.
 void close()
          Closes the wizard.
 void displayBack()
          Displays the previous page.
 void displayFirst()
          Displays the first page in the sequence.
 void displayNext()
          Displays the next page.
 void displayPage(java.lang.String name)
          Shows a particular page and updates the navigator.
 void finish()
          Finishes the wizard.
 boolean fireWizardEvent(int eventType)
          Fires a wizard event using the given event code.
protected  boolean fireWizardEvent(WizardEvent event)
          Fires a wizard event.
 WizardDataModel getDataModel()
          Gets the data collection model holding the data of the pages.
 javax.swing.ImageIcon getDefaultBackgroundImage()
          Gets the default background image.
 javax.swing.ImageIcon getDefaultWizardImage()
          Gets the default wizard image.
 SequenceManager getManager()
          Gets the page sequence manager.
 java.awt.Component getPage(java.lang.String name)
          Gets a page by its name.
 java.util.Iterator getPageNames()
          Gets the list of page names.
 java.lang.String getPageResourcePrefix()
          Gets the optional resource prefix for wizard page resources.
 java.lang.String getPageResourceString(java.lang.String pageName, java.lang.String suffix)
          Gets a text resource for the specified page from the wizard resource.
 java.util.Iterator getPages()
          Gets the list of pages.
 ResourceCollection getResource()
          Gets the wizard resource.
 java.lang.String getResultPageName()
          Gets the wizard result page name.
 boolean hasBackward()
          Determines if there is a previous page.
 boolean hasForward()
          Determines if there is a next page.
 void hideWizard()
          Hides the window the wizard is contained in.
 void removePage(java.lang.String name)
          Removes a page from the wizard and the sequence manager.
 void removeWizardListener(WizardListener listener)
          Removes a wizard event listener.
 void setDataModel(WizardDataModel dataModel)
          Sets the data collection model holding the data of the pages.
 void setDefaultBackgroundImage(javax.swing.ImageIcon defaultBackgroundImage)
          Sets the default background image.
 void setDefaultWizardImage(javax.swing.ImageIcon defaultWizardImage)
          Sets the default wizard image.
 void setManager(SequenceManager manager)
          Sets the page sequence manager.
 void setPageResourcePrefix(java.lang.String pageResourcePrefix)
          Sets the optional resource prefix for wizard page resources.
 void setResultPage(java.lang.String resultPageName, java.awt.Component page)
          Adds a result page to the wizard.
 void setResultPageName(java.lang.String resultPageName)
          Sets the wizard result page name.
 void setShowHelp(boolean showHelp)
          Sets the show help.
 void setWizardResource(ResourceCollection wizardResourceCollection)
          Sets the wizard resource.
 void stateChanged(javax.swing.event.ChangeEvent event)
          Called if the state of the model changed.
 void updateNavigator()
          Updates the navigation bar.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, 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, 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, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WizardImpl

public WizardImpl()
Constructor.


WizardImpl

public WizardImpl(ResourceCollection wizardResourceCollection)
Constructor.

Parameters:
wizardResourceCollection - The resource that contains texts and images for the wizard's navigator

WizardImpl

public WizardImpl(ResourceCollection wizardResourceCollection,
                  javax.swing.ImageIcon defaultWizardImage)
Constructor.

Parameters:
wizardResourceCollection - The resource that contains texts and images for the wizard's navigator
defaultWizardImage - Default wizard image

WizardImpl

public WizardImpl(ResourceCollection wizardResourceCollection,
                  javax.swing.ImageIcon defaultWizardImage,
                  javax.swing.ImageIcon defaultBackgroundImage)
Constructor.

Parameters:
wizardResourceCollection - The resource that contains texts and images for the wizard's navigator
defaultWizardImage - Default wizard image
defaultBackgroundImage - Default background image
Method Detail

addAndLinkPage

public void addAndLinkPage(java.lang.String name,
                           java.awt.Component page)
Adds a page to the wizard and links it into the sequence manager's list. The pages will be displayed in the sequence they have been added to the wizard using this method.

Specified by:
addAndLinkPage in interface Wizard
Parameters:
name - Name of the page. Use this name for any sequence manager operations (see getManager()).
page - page to add. The page should be a subclass of WizardPage

addPage

public void addPage(java.lang.String name,
                    java.awt.Component page)
Adds a page to the wizard, but does not link it into the sequence manager's list. You have to use the methods of the sequence manager (see getManager()) to define the order the pages will appear.

Specified by:
addPage in interface Wizard
Parameters:
name - Name of the page. Use this name for any sequence manager operations (see getManager()).
page - page to add. The page should be a subclass of WizardPage

removePage

public void removePage(java.lang.String name)
Removes a page from the wizard and the sequence manager.

Specified by:
removePage in interface Wizard
Parameters:
name - Name of the page

getPage

public java.awt.Component getPage(java.lang.String name)
Gets a page by its name.

Specified by:
getPage in interface Wizard
Parameters:
name - Name of the page or null for the current page
Returns:
The page component (usually an instance of WizardPage)

getPageNames

public java.util.Iterator getPageNames()
Gets the list of page names.

Specified by:
getPageNames in interface Wizard
Returns:
An iterator of wizard page names (strings)

getPages

public java.util.Iterator getPages()
Gets the list of pages.

Specified by:
getPages in interface Wizard
Returns:
An iterator of wizard pages (Component objects)

getResultPageName

public java.lang.String getResultPageName()
Gets the wizard result page name. The result page will be displayed after the user has pressed the 'Finish' button. It will not be considered by the sequence manager. Note that the result page component must have been added using the addPage(java.lang.String, java.awt.Component) method.

Specified by:
getResultPageName in interface Wizard
Returns:
The name of the result page or null if no result page is set

setResultPageName

public void setResultPageName(java.lang.String resultPageName)
Sets the wizard result page name. The result page will be displayed after the user has pressed the 'Finish' button. It will not be considered by the sequence manager. Note that the result page component must have been added using the addPage(java.lang.String, java.awt.Component) method.

Specified by:
setResultPageName in interface Wizard
Parameters:
resultPageName - The name of the result page or null for no result page

setResultPage

public void setResultPage(java.lang.String resultPageName,
                          java.awt.Component page)
Adds a result page to the wizard. The result page will be displayed after the user has pressed the 'Finish' button. It will not be considered by the sequence manager.
This method is a convenience method for addPage(java.lang.String, java.awt.Component) + setResultPageName(java.lang.String)

Specified by:
setResultPage in interface Wizard
Parameters:
resultPageName - The name of the result page or null for no result page
page - Page component to add (usually a WizardPage)

clearPages

public void clearPages()
Clears the wizard pages. Clears all pages and the sequence manager information

Specified by:
clearPages in interface Wizard

displayFirst

public void displayFirst()
Displays the first page in the sequence.

Specified by:
displayFirst in interface Wizard

displayBack

public void displayBack()
Displays the previous page. Also called if the user presses the 'Back' button.

Specified by:
displayBack in interface Wizard

displayNext

public void displayNext()
Displays the next page. Also called if the user presses the 'Next' button.

Specified by:
displayNext in interface Wizard

finish

public void finish()
Finishes the wizard. Also called if the user presses the 'Finish' button.

Specified by:
finish in interface Wizard

cancel

public void cancel()
Cancels the wizard. Also called if the user presses the 'Cancel' button.

Specified by:
cancel in interface Wizard

close

public void close()
Closes the wizard. Also called if the user presses the 'Close' button.

Specified by:
close in interface Wizard

canMoveBackward

public boolean canMoveBackward()
Determines if we can return to the previous page. Default: true.

Specified by:
canMoveBackward in interface Wizard

hasBackward

public boolean hasBackward()
Determines if there is a previous page.

Specified by:
hasBackward in interface Wizard

canMoveForward

public boolean canMoveForward()
Determines if we can advance to the next page. Default: false.

Specified by:
canMoveForward in interface Wizard

hasForward

public boolean hasForward()
Determines if there is a next page.

Specified by:
hasForward in interface Wizard

canFinish

public boolean canFinish()
Determines if we can finish the wizard dialog at this point. Default: false.

Specified by:
canFinish in interface Wizard

canCancel

public boolean canCancel()
Determines if we can cancel the wizard dialog at this point. Default: true.

Specified by:
canCancel in interface Wizard

displayPage

public void displayPage(java.lang.String name)
Shows a particular page and updates the navigator.

Specified by:
displayPage in interface Wizard
Parameters:
name - Name of the page to show or null for the current one

updateNavigator

public void updateNavigator()
Updates the navigation bar. This method should be called if a page that does not make use of the wizard data model (see setDataModel(WizardDataModel)) has changed its status and wants to update the state of the navigation bar buttons accordingly.

Specified by:
updateNavigator in interface Wizard

hideWizard

public void hideWizard()
Hides the window the wizard is contained in.


addWizardListener

public void addWizardListener(WizardListener listener)
Adds a wizard event listener. The listener will be notified each time a property value changes.

Specified by:
addWizardListener in interface Wizard
Parameters:
listener - Listener

removeWizardListener

public void removeWizardListener(WizardListener listener)
Removes a wizard event listener.

Specified by:
removeWizardListener in interface Wizard
Parameters:
listener - Listener

fireWizardEvent

public boolean fireWizardEvent(int eventType)
Fires a wizard event using the given event code.

Parameters:
eventType - Event code to fire
Returns:
true Processing can be continued.
false The cancel flag of the event has been set by an event listener.

fireWizardEvent

protected boolean fireWizardEvent(WizardEvent event)
Fires a wizard event.

Parameters:
event - Event to fire
Returns:
true Processing can be continued.
false The cancel flag of the event has been set by an event listener.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent event)
Called if the state of the model changed. The navigator is updated to reflect any changes in the model that might lead to enable/disable the 'Next' or 'Finish' buttons.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
event - Event

getDataModel

public WizardDataModel getDataModel()
Gets the data collection model holding the data of the pages.

Specified by:
getDataModel in interface Wizard

setDataModel

public void setDataModel(WizardDataModel dataModel)
Sets the data collection model holding the data of the pages.

Specified by:
setDataModel in interface Wizard

getManager

public SequenceManager getManager()
Gets the page sequence manager.

Specified by:
getManager in interface Wizard

setManager

public void setManager(SequenceManager manager)
Sets the page sequence manager.

Specified by:
setManager in interface Wizard

getResource

public ResourceCollection getResource()
Gets the wizard resource.

Specified by:
getResource in interface Wizard

setWizardResource

public void setWizardResource(ResourceCollection wizardResourceCollection)
Sets the wizard resource.

Specified by:
setWizardResource in interface Wizard

getPageResourcePrefix

public java.lang.String getPageResourcePrefix()
Gets the optional resource prefix for wizard page resources.

Specified by:
getPageResourcePrefix in interface Wizard

setPageResourcePrefix

public void setPageResourcePrefix(java.lang.String pageResourcePrefix)
Sets the optional resource prefix for wizard page resources.

Specified by:
setPageResourcePrefix in interface Wizard

setShowHelp

public void setShowHelp(boolean showHelp)
Sets the show help.

Specified by:
setShowHelp in interface Wizard

getDefaultWizardImage

public javax.swing.ImageIcon getDefaultWizardImage()
Gets the default wizard image.

Specified by:
getDefaultWizardImage in interface Wizard

setDefaultWizardImage

public void setDefaultWizardImage(javax.swing.ImageIcon defaultWizardImage)
Sets the default wizard image.

Specified by:
setDefaultWizardImage in interface Wizard

getDefaultBackgroundImage

public javax.swing.ImageIcon getDefaultBackgroundImage()
Gets the default background image.

Specified by:
getDefaultBackgroundImage in interface Wizard

setDefaultBackgroundImage

public void setDefaultBackgroundImage(javax.swing.ImageIcon defaultBackgroundImage)
Sets the default background image.

Specified by:
setDefaultBackgroundImage in interface Wizard

getPageResourceString

public java.lang.String getPageResourceString(java.lang.String pageName,
                                              java.lang.String suffix)
Gets a text resource for the specified page from the wizard resource. The method will search the wizard resource for a string named "wizard.\i@lp pageResourcePrefix\i.\ipageName\i.\isuffix\i" if a page resource prefix has been set. If no such string can be found, the method will try "wizard.\ipageName\i.\isuffix\i" and "wizard.\isuffix\i".

Specified by:
getPageResourceString in interface Wizard
Parameters:
pageName - Name of the wizard page
suffix - Suffix to use for the the resource item name generation
Returns:
The value of the resource item or null if no such resource item exists


Copyright © 2011. All Rights Reserved.