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:
BasicTextCodeFieldFactory, BasicUploadFieldFactory, CheckBoxFieldFactory, DateFieldFactory, HiddenFieldFactory, LinkFieldFactory, MultiFieldFactory, MultiLinkFieldFactory, PasswordFieldFactory, RichTextFieldFactory, SelectFieldFactory, StaticFieldFactory, SwitchableFieldFactory, TextFieldFactory

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
 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(FieldDefinition fieldDefinition)
           
 D getFieldDefinition()
           
protected  Class<?> getFieldType(FieldDefinition fieldDefinition)
          Return the Class field Type if define in the configuration.
protected  String getI18nBasename()
           
protected  com.vaadin.data.Property<?> getOrCreateProperty()
          Get a property from the current Item.
 String getPropertyName()
           
protected  javax.jcr.Node getRelatedNode(com.vaadin.data.Item fieldRelatedItem)
          Returns the field related node.
 info.magnolia.ui.api.view.View getView()
           
 void setComponentProvider(info.magnolia.objectfactory.ComponentProvider componentProvider)
           
 void setFieldValidatorFactoryFactory(FieldValidatorFactoryFactory fieldValidatorFactoryFactory)
           
 void setI18nContentSupport(info.magnolia.cms.i18n.I18nContentSupport i18nContentSupport)
           
 void setPropertyDataSource(com.vaadin.data.Property<?> property)
          Set the DataSource of the current field.
 
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

getFieldDefinition

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

setPropertyDataSource

public void setPropertyDataSource(com.vaadin.data.Property<?> property)
Set the DataSource of the current field.


createFieldComponent

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


getView

public info.magnolia.ui.api.view.View getView()
Specified by:
getView in interface FieldFactory

getOrCreateProperty

protected com.vaadin.data.Property<?> getOrCreateProperty()
Get a property from the current Item.

if the field is i18n-aware - create a special property that would delegate the values to the proper localized properties. Otherwise - follow the default pattern.

If the property already exists, return this property. If the property does not exist, create a new property based on the defined type, default value, and saveInfo.


getFieldType

protected Class<?> getFieldType(FieldDefinition fieldDefinition)
Return the Class field Type if define in the configuration. If the Type is not defined in the configuration or not of a supported type, throws a IllegalArgumentException:


getDefaultFieldType

protected Class<?> getDefaultFieldType(FieldDefinition fieldDefinition)

getRelatedNode

protected javax.jcr.Node getRelatedNode(com.vaadin.data.Item fieldRelatedItem)
                                 throws javax.jcr.RepositoryException
Returns the field related node. If field is of type JcrNewNodeAdapter then return the parent node. Else get the node associated with the Vaadin item.

Throws:
javax.jcr.RepositoryException

getPropertyName

public String getPropertyName()

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.