net.sf.doolin.gui.validation
Class IconFeedbackPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLayeredPane
net.sf.doolin.gui.validation.IconFeedbackPanel
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible
public final class IconFeedbackPanel
- extends JLayeredPane
Can display validation feedback icons "over" a content panel. It observes a
ValidationResultModel and creates icon labels in a feedback layer of a
JLayeredPane on top of the content layer. To position the feedback
labels, the content pane is traversed and searched for text components that
match a validation message key in this panel's observed
ValidationResultModel.
Note: This panel doesn't reserve space for the portion used
to display the overlaid feedback components. It has been designed to not
change the layout of the wrapped content. Therefore you must reserve this
space, or in other words, you must ensure that the wrapped content provides
enough space to display the overlaid components. Since the current
implementation positions the overlay components in the lower left, just make
sure that there are about 6 pixel to the left and bottom of the input
components that can be marked.
This panel handles two event types:
- the ValidationResultModel changes; in this case the set of visible
feedback components shall mark the input components that match the new
validation result. This is done by this class' internal
ValidationResultChangeHandler which in turn invokes
#updateFeedbackComponents.
- the content layout changes; the feedback components must then be
repositioned to reflect the position of the overlaid input components. This
is done by overriding
#validateTree and invoking
#repositionFeedBackComponents after the child tree has been laid
out. The current simple but expensive implementation updates all components.
TO DO: Check how the wrapping mechanism shall work with JSplitPanes,
JTabbedPanes and CardPanels. At least provide guidelines, how to wrap these
panel types, or how to handle these cases.
TO DO: Turn this class into an abstract superclass. Subclasses shall
implement the feedback component creation and specify where to locate the
feedback component relative to the underlying content component.
TO DO: Consider adding a mechanism, so that components can be added and
removed later.
- Author:
- Karsten Lentzsch, Damien Coraboeuf
- See Also:
- Serialized Form
| Methods inherited from class javax.swing.JLayeredPane |
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition |
| 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateUI |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
| 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 |
IconFeedbackPanel
public IconFeedbackPanel(ValidationSupport<?> validationSupport,
JComponent content)
- Creates an IconFeedbackPanel on the given ValidationResultModel using the
specified content panel.
Note: Typically you should wrap component trees with
getWrappedComponentTree, not this constructor.
Note: You must not add or remove components from the
content once this constructor has been invoked.
- Parameters:
validationSupport - the validation supportcontent - the panel that contains the content components
- Throws:
NullPointerException - if model or content is null.
getWrappedComponentTree
public static JComponent getWrappedComponentTree(ValidationSupport<?> model,
JComponent root)
- Wraps the components in the given component tree with instances of
IconFeedbackPanel where necessary. Such a wrapper is required for all
JScrollPanes that contain multiple children and for the root - unless
it's a JScrollPane with multiple children.
- Parameters:
model - Model for the validation resultsroot - the root of the component tree to wrap
- Returns:
- the wrapped component tree
getResultIcon
protected Icon getResultIcon(GUIValidation result)
- Gets the icon for a validation result
- Parameters:
result - Validation result
- Returns:
- Icon to use
validateTree
protected void validateTree()
- Recursively descends the container tree and recomputes the layout for any
subtrees marked as needing it (those marked as invalid). In addition to
the superclass behavior, we reposition the feedback components after the
child components have been validated.
We reposition the feedback components only, if this panel is visible; if
it becomes visible, #validateTree will be invoked.
- Overrides:
validateTree in class Container
- See Also:
Container.validateTree(),
Container.validate(),
Container.invalidate(),
Container.doLayout(),
Component.setVisible(boolean),
LayoutManager
Copyright © 2011. All Rights Reserved.