|
|||||||||
| Home >> All >> com >> jgoodies >> validation >> tutorial >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.jgoodies.validation.tutorial.util
Class IconFeedbackPanel

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLayeredPane
com.jgoodies.validation.tutorial.util.IconFeedbackPanel
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
- public final class IconFeedbackPanel
- extends javax.swing.JLayeredPane
Can display validation feedback icons "over" a content panel. It observes a ValidationResultModel and creates icon labels in a feedback layer of a javax.swing.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.
This panel handles two event types:
- the ValidationResultModel changes,
- the content layout changes.
TODO: 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.
TODO: 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.
TODO: Consider adding a mechanism, so that components can be added and removed later.
- Version:
- $Revision: 1.4 $
| Nested Class Summary | |
private class |
IconFeedbackPanel.SimpleLayout
|
private class |
IconFeedbackPanel.ValidationResultChangeHandler
|
| Nested classes inherited from class javax.swing.JLayeredPane |
javax.swing.JLayeredPane.AccessibleJLayeredPane |
| 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 | |
private javax.swing.JComponent |
content
Refers to the content panel that holds the content components. |
private static int |
CONTENT_LAYER
|
private static int |
FEEDBACK_LAYER
|
private ValidationResultModel |
model
Holds the ValidationResult and reports changes in that result. |
| Fields inherited from class javax.swing.JLayeredPane |
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER |
| 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.Container |
|
| 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 | |
IconFeedbackPanel(ValidationResultModel model,
javax.swing.JComponent content)
Creates an IconFeedbackPanel on the given ValidationResultModel using the specified content panel. |
|
| Method Summary | |
private void |
addFeedbackComponent(java.awt.Component contentComponent,
javax.swing.JComponent messageComponent,
java.util.Map keyMap,
int xOffset,
int yOffset)
|
private javax.swing.JComponent |
createFeedbackComponent(ValidationResult result,
java.awt.Component contentComponent)
Creates and returns a validation feedback component that shall overlay the specified content component. |
private static ValidationResult |
getAssociatedResult(javax.swing.JComponent comp,
java.util.Map keyMap)
Returns the ValidationResult associated with the given component using the specified validation result key map. |
private java.awt.Point |
getFeedbackComponentOrigin(javax.swing.JComponent feedbackComponent,
java.awt.Component contentComponent)
Computes and returns the origin of the given feedback component using the content component's origin. |
static javax.swing.JComponent |
getWrappedComponentTree(ValidationResultModel model,
javax.swing.JComponent root)
Wraps the components in the given component tree with instances of IconFeedbackPanel where necessary. |
private void |
initEventHandling()
Registers a listener with the validation result model that updates the feedback components. |
void |
invalidate()
TODO: Check how to handle layout changes properly. |
private static boolean |
isMarkable(java.awt.Component component)
Checks and answers if the given component can be marked or not. |
private static boolean |
isScrollPaneView(java.awt.Component c)
|
private static boolean |
isScrollPaneWithUnmarkableView(java.awt.Component c)
|
private void |
removeAllFeedbackComponents()
|
private void |
repositionFeedbackComponents()
TODO: Improve this implementation to set only positions. |
private void |
updateFeedbackComponents()
|
private void |
visitComponentTree(java.awt.Container container,
java.util.Map keyMap,
int xOffset,
int yOffset)
Traverses the component tree starting at the given container and creates a feedback component for each JTextComponent that is associated with a message in the specified keyMap. |
private static void |
wrapComponentTree(ValidationResultModel model,
java.awt.Container container)
|
| 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, putLayer, remove, removeAll, setLayer, setLayer, setPosition |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
CONTENT_LAYER
private static final int CONTENT_LAYER
- See Also:
- Constant Field Values
FEEDBACK_LAYER
private static final int FEEDBACK_LAYER
- See Also:
- Constant Field Values
model
private final ValidationResultModel model
- Holds the ValidationResult and reports changes in that result.
Used to update the state of the feedback components.
content
private final javax.swing.JComponent content
- Refers to the content panel that holds the content components.
| Constructor Detail |
IconFeedbackPanel
public IconFeedbackPanel(ValidationResultModel model,
javax.swing.JComponent content)
- Creates an IconFeedbackPanel on the given ValidationResultModel
using the specified content panel.
Note: Typically you should wrap component trees with
getWrappedComponentTree(ValidationResultModel, JComponent)55 , not this constructor.Note: You must not add or remove components from the content once this constructor has been invoked.
| Method Detail |
getWrappedComponentTree
public static javax.swing.JComponent getWrappedComponentTree(ValidationResultModel model, javax.swing.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.
wrapComponentTree
private static void wrapComponentTree(ValidationResultModel model,
java.awt.Container container)
isScrollPaneWithUnmarkableView
private static boolean isScrollPaneWithUnmarkableView(java.awt.Component c)
initEventHandling
private void initEventHandling()
- Registers a listener with the validation result model that updates
the feedback components.
createFeedbackComponent
private javax.swing.JComponent createFeedbackComponent(ValidationResult result, java.awt.Component contentComponent)
- Creates and returns a validation feedback component
that shall overlay the specified content component.
This implementation returns a JLabel. The validation result's severity is used to lookup the label's icon; the result's message text is set as the label's tooltip text.
TODO: Turn this method into an abstract method if this class becomes an abstract superclass of general feedback overlay panels.
getFeedbackComponentOrigin
private java.awt.Point getFeedbackComponentOrigin(javax.swing.JComponent feedbackComponent, java.awt.Component contentComponent)
- Computes and returns the origin of the given feedback component
using the content component's origin.
This implementation returns a JLabel. The validation result's severity is used to lookup the label's icon; the result's message text is set as the label's tooltip text.
TODO: Turn this method into an abstract method if this class becomes an abstract superclass of general feedback overlay panels.
removeAllFeedbackComponents
private void removeAllFeedbackComponents()
visitComponentTree
private void visitComponentTree(java.awt.Container container, java.util.Map keyMap, int xOffset, int yOffset)
- Traverses the component tree starting at the given container
and creates a feedback component for each JTextComponent that
is associated with a message in the specified
keyMap.The arguments passed to the feedback component creation method are the visited component and its associated validation subresult. This subresult is requested from the specified
keyMapusing the visited component's message key.
isScrollPaneView
private static boolean isScrollPaneView(java.awt.Component c)
isMarkable
private static boolean isMarkable(java.awt.Component component)
- Checks and answers if the given component can be marked or not.
TODO: Check the combobox editable state.
TODO: Add the JSpinner to the list of markable components.
addFeedbackComponent
private void addFeedbackComponent(java.awt.Component contentComponent, javax.swing.JComponent messageComponent, java.util.Map keyMap, int xOffset, int yOffset)
getAssociatedResult
private static ValidationResult getAssociatedResult(javax.swing.JComponent comp, java.util.Map keyMap)
- Returns the ValidationResult associated with the given component
using the specified validation result key map.
updateFeedbackComponents
private void updateFeedbackComponents()
repositionFeedbackComponents
private void repositionFeedbackComponents()
- TODO: Improve this implementation to set only positions.
The current implementation removes all components and re-adds
them later.
invalidate
public void invalidate()
- TODO: Check how to handle layout changes properly.
|
|||||||||
| Home >> All >> com >> jgoodies >> validation >> tutorial >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC