info.magnolia.ui.form.field.factory
Class AbstractFieldFactory<D extends FieldDefinition,T>

java.lang.Object
  extended by info.magnolia.ui.form.AbstractFormItem
      extended by info.magnolia.ui.form.field.factory.AbstractFieldFactory<D,T>
Type Parameters:
D - definition type
T - field value type
All Implemented Interfaces:
FieldFactory, FormItem
Direct Known Subclasses:
AbstractAccessFieldFactory, BasicTextCodeFieldFactory, BasicUploadFieldFactory, CheckBoxFieldFactory, CompositeFieldFactory, DateFieldFactory, HiddenFieldFactory, LinkFieldFactory, LinkFieldSelectionFactory, MultiValueFieldFactory, PasswordFieldFactory, RichTextFieldFactory, SelectFieldFactory, StaticFieldFactory, SwitchableFieldFactory, TextFieldFactory, WorkbenchFieldFactory

public abstract class AbstractFieldFactory<D extends FieldDefinition,T>
extends AbstractFormItem
implements FieldFactory

Abstract FieldFactory implementations. This class handle all common attributes defined in FieldDefinition and binds Vaadin Field instances created by subclasses to the Property they will be reading and writing to.


Field Summary
protected  D definition
           
protected  com.vaadin.ui.Field<T> field
           
protected  com.vaadin.data.Item item
           
 
Constructor Summary
AbstractFieldFactory(D definition, com.vaadin.data.Item relatedFieldItem)
           
 
Method Summary
protected  Object createDefaultValue(com.vaadin.data.Property<?> property)
          Create a typed default value.
 com.vaadin.ui.Field<T> createField()
          Creates and initializes a Vaadin Field component.
protected abstract  com.vaadin.ui.Field<T> createFieldComponent()
          Implemented by subclasses to create and initialize the Vaadin Field instance to use.
protected  Class<?> getDefaultFieldType()
          Exposed method used by field's factory in order to define a default Field Type (decoupled from the definition).
protected  Class<?> getDefinitionType()
           
 D getFieldDefinition()
           
protected  Class<?> getFieldType()
          Define the field property value type Class.
Return the value defined by the configuration ('type' property).
If this value is not defined, return the value of the overriding method getDefaultFieldType().
If this method is not override, return UndefinedPropertyType.
In this case, the Transformer will have the responsibility to define the property type.
protected  String getI18nBasename()
           
 View getView()
           
protected  Transformer<?> initializeTransformer(Class<? extends Transformer<?>> transformerClass)
          Exposed method used by field's factory to initialize the property Transformer.
This allows to add additional constructor parameter if needed.
 void setComponentProvider(info.magnolia.objectfactory.ComponentProvider componentProvider)
           
 void setFieldValidatorFactoryFactory(FieldValidatorFactoryFactory fieldValidatorFactoryFactory)
           
 void setI18nContentSupport(info.magnolia.cms.i18n.I18nContentSupport i18nContentSupport)
           
 void setPropertyDataSourceAndDefaultValue(com.vaadin.data.Property<?> property)
          Set the DataSource of the current field.
Set the default value if :
- the item is an instance of ItemAdapter and this is a new Item (Not yet stored in the related datasource) - the item is not an instance of ItemAdapter.
In this case, the Item is a custom implementation of Item and we have no possibility to define if it is or not a new Item.
protected  void setPropertyDataSourceDefaultValue(com.vaadin.data.Property property)
          Set the Field default value is required.
 
Methods inherited from class info.magnolia.ui.form.AbstractFormItem
getMessage, getMessages, getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.magnolia.ui.form.FormItem
getMessages, getParent, setParent
 

Field Detail

item

protected com.vaadin.data.Item item

field

protected com.vaadin.ui.Field<T> field

definition

protected D extends FieldDefinition definition
Constructor Detail

AbstractFieldFactory

public AbstractFieldFactory(D definition,
                            com.vaadin.data.Item relatedFieldItem)
Method Detail

setFieldValidatorFactoryFactory

public void setFieldValidatorFactoryFactory(FieldValidatorFactoryFactory fieldValidatorFactoryFactory)
Specified by:
setFieldValidatorFactoryFactory in interface FieldFactory

setI18nContentSupport

public void setI18nContentSupport(info.magnolia.cms.i18n.I18nContentSupport i18nContentSupport)
Specified by:
setI18nContentSupport in interface FieldFactory

createField

public com.vaadin.ui.Field<T> createField()
Description copied from interface: FieldFactory
Creates and initializes a Vaadin Field component.

Specified by:
createField in interface FieldFactory

setPropertyDataSourceAndDefaultValue

public void setPropertyDataSourceAndDefaultValue(com.vaadin.data.Property<?> property)
Set the DataSource of the current field.
Set the default value if :
- the item is an instance of ItemAdapter and this is a new Item (Not yet stored in the related datasource) - the item is not an instance of ItemAdapter.
In this case, the Item is a custom implementation of Item and we have no possibility to define if it is or not a new Item.


setPropertyDataSourceDefaultValue

protected void setPropertyDataSourceDefaultValue(com.vaadin.data.Property property)
Set the Field default value is required.


createDefaultValue

protected Object createDefaultValue(com.vaadin.data.Property<?> property)
Create a typed default value.


getFieldDefinition

public D getFieldDefinition()
Specified by:
getFieldDefinition in interface FieldFactory

createFieldComponent

protected abstract com.vaadin.ui.Field<T> createFieldComponent()
Implemented by subclasses to create and initialize the Vaadin Field instance to use.


getView

public View getView()
Specified by:
getView in interface FieldFactory

initializeTransformer

protected Transformer<?> initializeTransformer(Class<? extends Transformer<?>> transformerClass)
Exposed method used by field's factory to initialize the property Transformer.
This allows to add additional constructor parameter if needed.


getFieldType

protected Class<?> getFieldType()
Define the field property value type Class.
Return the value defined by the configuration ('type' property).
If this value is not defined, return the value of the overriding method getDefaultFieldType().
If this method is not override, return UndefinedPropertyType.
In this case, the Transformer will have the responsibility to define the property type.


getDefinitionType

protected Class<?> getDefinitionType()
Returns:
Class Type defined into the field definition or null if not defined.

getDefaultFieldType

protected Class<?> getDefaultFieldType()
Exposed method used by field's factory in order to define a default Field Type (decoupled from the definition).


getI18nBasename

protected String getI18nBasename()
Specified by:
getI18nBasename in class AbstractFormItem

setComponentProvider

public void setComponentProvider(info.magnolia.objectfactory.ComponentProvider componentProvider)
Specified by:
setComponentProvider in interface FieldFactory


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.