summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2013-02-14 13:36:00 +0000
committerVaadin Code Review <review@vaadin.com>2013-02-14 13:36:00 +0000
commit2f69a0a0466a064c6303bc3b1d83ced42193a269 (patch)
tree02c709a1d8a18e5f4e7ad00b2c387528512a0e30 /server
parent7d23e22733d1b41963ae6751b3dabbb12b4da8bc (diff)
parent6624c7fedf44b1097eb09f78d016ba471aa3dc12 (diff)
downloadvaadin-framework-2f69a0a0466a064c6303bc3b1d83ced42193a269.tar.gz
vaadin-framework-2f69a0a0466a064c6303bc3b1d83ced42193a269.zip
Merge "Added support for Dates to DefaultFieldGroupFieldFactory (#8539)"
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java25
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;