public class JGoodiesValidatorProcessor extends Object implements AdvancedWidgetProcessor<JComponent,SwingMetawidget>
Out of the box, JGoodies does not provide any Validator implementations, so by default this class
only calls JGoodies' setMandatory
and updateComponentTreeMandatory
methods. Clients are expected to extend this class and override getValidator
to
integrate their own validators.
Constructor and Description |
---|
JGoodiesValidatorProcessor() |
Modifier and Type | Method and Description |
---|---|
protected void |
attachValidator(JComponent component,
com.jgoodies.validation.Validator<?> validator,
String path,
SwingMetawidget metawidget)
Attach the given Validator to the given JComponent.
|
protected com.jgoodies.validation.Validator<?> |
getValidator(JComponent component,
Map<String,String> attributes,
String path,
SwingMetawidget metawidget)
Return the appropriate validator for the given JComponent with the given attributes.
|
void |
onEndBuild(SwingMetawidget metawidget)
Event called at the end of widget building, after all widgets have been built and added to
the
Layout . |
void |
onStartBuild(SwingMetawidget metawidget)
Event called at the start of the widget building process, before the
WidgetBuilder is called. |
JComponent |
processWidget(JComponent component,
String elementName,
Map<String,String> attributes,
SwingMetawidget metawidget)
Process the given widget.
|
protected void |
updateComponent(JComponent component,
com.jgoodies.validation.ValidationResult validationResult,
SwingMetawidget metawidget)
Update the given component with the given validation result.
|
protected void |
validateChange(JComponent component,
com.jgoodies.validation.Validator<?> validator,
String path,
SwingMetawidget metawidget)
Execute the given Validator against the given JComponent.
|
public void onStartBuild(SwingMetawidget metawidget)
AdvancedWidgetProcessor
WidgetBuilder
is called. WidgetProcessor
s may wish to act on this
event to initialize themselves ready for processing. This event is only called once per
inspection, not once per widget built.onStartBuild
in interface AdvancedWidgetProcessor<JComponent,SwingMetawidget>
metawidget
- the parent Metawidget. Never nullpublic JComponent processWidget(JComponent component, String elementName, Map<String,String> attributes, SwingMetawidget metawidget)
WidgetProcessor
WidgetBuilder
, and before it is added to the Layout
.processWidget
in interface WidgetProcessor<JComponent,SwingMetawidget>
component
- the widget to process. Never nullelementName
- XML node name of the business field. Typically 'entity', 'property' or 'action'.
Never nullattributes
- attributes of the widget to process. Never null. This Map is modifiable - changes
will be passed to subsequent WidgetProcessors and Layoutsmetawidget
- the parent Metawidget. Never nullpublic void onEndBuild(SwingMetawidget metawidget)
AdvancedWidgetProcessor
Layout
. WidgetProcessor
s may wish to act on this event to clean
themselves up after processing. This event is only called once per inspection, not once per
widget built.onEndBuild
in interface AdvancedWidgetProcessor<JComponent,SwingMetawidget>
metawidget
- the parent Metawidget. Never nullprotected com.jgoodies.validation.Validator<?> getValidator(JComponent component, Map<String,String> attributes, String path, SwingMetawidget metawidget)
component
- component validator will be attached to (by attachValidator
)attributes
- attributes of the widget to layout. Never nullpath
- path to the domain object property (of the form com.myapp.Foo/bar/baz)metawidget
- the owning Metawidget. May be useful if you wish to look up other WidgetProcessors
(such asprotected void attachValidator(JComponent component, com.jgoodies.validation.Validator<?> validator, String path, SwingMetawidget metawidget)
This method attaches the Validator, but largely delegates to validateChange for the actual validation work. Clients can override this method to attach Validators to other events, whilst still calling validateChange to perform the validation.
protected void validateChange(JComponent component, com.jgoodies.validation.Validator<?> validator, String path, SwingMetawidget metawidget)
protected void updateComponent(JComponent component, com.jgoodies.validation.ValidationResult validationResult, SwingMetawidget metawidget)
Clients may override this method to integrate their own Visitors. For example
ValidationComponentUtils.visitComponentTree( getMetawidget(), validationResult.keyMap(), new MyCustomVisitor() );
component
- the component that was validatedvalidationResult
- contains the latest ValidationResult plus any previous ValidationResults for other
components (so can be used correctly with updateComponentTreeXXX)Copyright © 2015. All Rights Reserved.