diff options
author | Artur Signell <artur@vaadin.com> | 2013-02-12 09:15:21 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-02-12 09:15:40 +0200 |
commit | 6624c7fedf44b1097eb09f78d016ba471aa3dc12 (patch) | |
tree | b982d5acc71f8f1bb80aabf988bca6aaefdf44de /server/src/com/vaadin/data | |
parent | 12996f599cf5284b4c2994764e26e700011e1a64 (diff) | |
download | vaadin-framework-6624c7fedf44b1097eb09f78d016ba471aa3dc12.tar.gz vaadin-framework-6624c7fedf44b1097eb09f78d016ba471aa3dc12.zip |
Added support for Dates to DefaultFieldGroupFieldFactory (#8539)
Change-Id: I61b45b4bb988878d86a913d383764ce7c17c3bf9
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r-- | server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java b/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java index 9ced6588f5..ff6b1d3aee 100644 --- a/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java +++ b/server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java @@ -15,18 +15,23 @@ */ package com.vaadin.data.fieldgroup; +import java.util.Date; import java.util.EnumSet; import com.vaadin.data.Item; import com.vaadin.data.fieldgroup.FieldGroup.BindException; +import com.vaadin.ui.AbstractField; import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.CheckBox; import com.vaadin.ui.ComboBox; +import com.vaadin.ui.DateField; import com.vaadin.ui.Field; +import com.vaadin.ui.InlineDateField; import com.vaadin.ui.ListSelect; import com.vaadin.ui.NativeSelect; import com.vaadin.ui.OptionGroup; +import com.vaadin.ui.PopupDateField; import com.vaadin.ui.RichTextArea; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; @@ -39,6 +44,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { public <T extends Field> T createField(Class<?> type, Class<T> fieldType) { if (Enum.class.isAssignableFrom(type)) { return createEnumField(type, fieldType); + } else if (Date.class.isAssignableFrom(type)) { + return createDateField(type, fieldType); } else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) { return createBooleanField(fieldType); @@ -70,6 +77,24 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { return null; } + private <T extends Field> T createDateField(Class<?> type, + Class<T> fieldType) { + AbstractField field; + + if (InlineDateField.class.isAssignableFrom(fieldType)) { + field = new InlineDateField(); + } else if (DateField.class.isAssignableFrom(fieldType)) { + field = new PopupDateField(); + } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { + field = createAbstractTextField((Class<? extends AbstractTextField>) fieldType); + } else { + return null; + } + + field.setImmediate(true); + return (T) field; + } + protected AbstractSelect createCompatibleSelect( Class<? extends AbstractSelect> fieldType) { AbstractSelect select; |