F - allows enforcing a type of FieldRetrieverpublic class ReflectionFormBuilder<F extends de.richtercloud.validation.tools.FieldRetriever> extends Object
ReflectionFormPanel by recursing over all fields of all
subclasses of an class and arranging form components for each item. The
components to choose are configurable.
The handling of fields is conrolled with different mappings which are
fieldAnnotationMapping, classAnnotationMapping,
classMapping and primitiveMapping which all
associate a characteristic of a class field to an instance of
JComponent which is put into the panel (some components are generated
using the Reflection API, others use more complex factories, like
FieldAnnotationHandler and ClassAnnotationHandler.
The precedence of the mappings is static and reads as listed above. It can be
overwritten by subclassing field and class annotation handlers to ignore
certain type or fields (or what ever criteria you can imagine) and omitting
entires in class mapping.| Constructor and Description |
|---|
ReflectionFormBuilder(String fieldDescriptionDialogTitle,
de.richtercloud.message.handler.IssueHandler issueHandler,
F fieldRetriever)
Creates a new reflection form builder.
|
| Modifier and Type | Method and Description |
|---|---|
protected JComponent |
getClassComponent(Field field,
Class<?> entityClass,
Object instance,
FieldHandler fieldHandler)
Retrieves the associated
JComponent to be displayed in the form. |
protected F |
getFieldRetriever() |
de.richtercloud.message.handler.IssueHandler |
getIssueHandler() |
protected void |
onFieldUpdate(FieldUpdateEvent event,
Field field,
Object instance) |
protected Object |
prepareInstance(Class<?> entityClass,
Object entityToUpdate) |
protected void |
transformClass(Class<?> clazz,
Object instance,
Map<Field,JComponent> fieldMapping,
ReflectionFormPanel reflectionFormPanel,
FieldHandler fieldHandler)
Code used by entity and embeddable transformation.
|
ReflectionFormPanel |
transformEntityClass(Class<?> entityClass,
Object entityToUpdate,
FieldHandler fieldHandler) |
static void |
validateMapping(Map<?,?> mapping,
String argumentName) |
public ReflectionFormBuilder(String fieldDescriptionDialogTitle, de.richtercloud.message.handler.IssueHandler issueHandler, F fieldRetriever)
fieldRetriever - the field retriever to usefieldDescriptionDialogTitle - the field description dialog titleissueHandler - the issue handler to usepublic de.richtercloud.message.handler.IssueHandler getIssueHandler()
protected F getFieldRetriever()
protected JComponent getClassComponent(Field field, Class<?> entityClass, Object instance, FieldHandler fieldHandler) throws FieldHandlingException, ResetException
JComponent to be displayed in the form.field - the field to get the class component forentityClass - the entity class declaring the fieldinstance - the instance to create forfieldHandler - the field handler to usenullFieldHandlingException - wraps all exceptions occuring during read
or write access to fieldsResetException - if an exception during resetting the field occursprotected void onFieldUpdate(FieldUpdateEvent event, Field field, Object instance) throws FieldUpdateException
FieldUpdateExceptionprotected void transformClass(Class<?> clazz, Object instance, Map<Field,JComponent> fieldMapping, ReflectionFormPanel reflectionFormPanel, FieldHandler fieldHandler) throws TransformationException, ResetException
clazz - the class to transforminstance - the instance to transformfieldMapping - the field mapping to usereflectionFormPanel - the resulting reflection form panel to add tofieldHandler - the field handler to useTransformationException - wraps any exception which occurs during
field accessResetException - if an exception during resetting the field occurspublic ReflectionFormPanel transformEntityClass(Class<?> entityClass, Object entityToUpdate, FieldHandler fieldHandler) throws TransformationException, ResetException
entityClass - the entity classentityToUpdate - an entity to update (instead of creating a new
instance of entityClass). null indicates to create a
new instance and write changes of the ReflectionFormPanel
into it.fieldHandler - the field handler to sueTransformationException - wraps all exception occuring during field
accessResetException - if an exception during resetting the field occursprotected Object prepareInstance(Class<?> entityClass, Object entityToUpdate) throws TransformationException
TransformationExceptionCopyright © 2018. All rights reserved.