diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-08-10 12:34:56 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-08-12 09:08:05 +0000 |
commit | bb9564db426d9d9471b6b07410d301fe1059ec19 (patch) | |
tree | 54a85089346397079431d94dac8aed6195d4b375 /server | |
parent | 2863eada413a37874027713f82acbddb577033c2 (diff) | |
download | vaadin-framework-bb9564db426d9d9471b6b07410d301fe1059ec19.tar.gz vaadin-framework-bb9564db426d9d9471b6b07410d301fe1059ec19.zip |
Move old DateField components to legacy package (pre-#57).
Change-Id: I9e766be232d90aab92b5daa77351f4b0a3933f1d
Diffstat (limited to 'server')
14 files changed, 153 insertions, 124 deletions
diff --git a/server/src/main/java/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java b/server/src/main/java/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java index a82da7ef51..0ad53fe3d7 100644 --- a/server/src/main/java/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java +++ b/server/src/main/java/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java @@ -22,16 +22,16 @@ import com.vaadin.data.Item; import com.vaadin.data.fieldgroup.FieldGroup.BindException; import com.vaadin.legacy.ui.LegacyAbstractField; import com.vaadin.legacy.ui.LegacyCheckBox; +import com.vaadin.legacy.ui.LegacyDateField; import com.vaadin.legacy.ui.LegacyField; +import com.vaadin.legacy.ui.LegacyInlineDateField; +import com.vaadin.legacy.ui.LegacyPopupDateField; import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.DateField; -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; @@ -64,7 +64,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { } @Override - public <T extends LegacyField> T createField(Class<?> type, Class<T> fieldType) { + public <T extends LegacyField> T createField(Class<?> type, + Class<T> fieldType) { if (Enum.class.isAssignableFrom(type)) { return createEnumField(type, fieldType); } else if (Date.class.isAssignableFrom(type)) { @@ -74,8 +75,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { return createBooleanField(fieldType); } if (AbstractTextField.class.isAssignableFrom(fieldType)) { - return fieldType.cast(createAbstractTextField(fieldType - .asSubclass(AbstractTextField.class))); + return fieldType.cast(createAbstractTextField( + fieldType.asSubclass(AbstractTextField.class))); } else if (fieldType == RichTextArea.class) { return fieldType.cast(createRichTextArea()); } @@ -104,7 +105,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { populateWithEnumData(s, (Class<? extends Enum>) type); return (T) s; } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { - return (T) createAbstractTextField((Class<? extends AbstractTextField>) fieldType); + return (T) createAbstractTextField( + (Class<? extends AbstractTextField>) fieldType); } return null; @@ -114,13 +116,14 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { Class<T> fieldType) { LegacyAbstractField field; - if (InlineDateField.class.isAssignableFrom(fieldType)) { - field = new InlineDateField(); + if (LegacyInlineDateField.class.isAssignableFrom(fieldType)) { + field = new LegacyInlineDateField(); } else if (anyField(fieldType) - || DateField.class.isAssignableFrom(fieldType)) { - field = new PopupDateField(); + || LegacyDateField.class.isAssignableFrom(fieldType)) { + field = new LegacyPopupDateField(); } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { - field = createAbstractTextField((Class<? extends AbstractTextField>) fieldType); + field = createAbstractTextField( + (Class<? extends AbstractTextField>) fieldType); } else { return null; } @@ -160,7 +163,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { * @return true if any LegacyAbstractField can be assigned to the field */ protected boolean anyField(Class<?> fieldType) { - return fieldType == LegacyField.class || fieldType == LegacyAbstractField.class; + return fieldType == LegacyField.class + || fieldType == LegacyAbstractField.class; } /** @@ -179,7 +183,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { cb.setImmediate(true); return (T) cb; } else if (AbstractTextField.class.isAssignableFrom(fieldType)) { - return (T) createAbstractTextField((Class<? extends AbstractTextField>) fieldType); + return (T) createAbstractTextField( + (Class<? extends AbstractTextField>) fieldType); } return null; @@ -195,8 +200,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory { field.setImmediate(true); return field; } catch (Exception e) { - throw new BindException("Could not create a field of type " - + fieldType, e); + throw new BindException( + "Could not create a field of type " + fieldType, e); } } diff --git a/server/src/main/java/com/vaadin/ui/DateField.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java index 1630053ee1..86cbcf9eec 100644 --- a/server/src/main/java/com/vaadin/ui/DateField.java +++ b/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.ui; +package com.vaadin.legacy.ui; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -36,15 +36,16 @@ import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.legacy.data.Validator; import com.vaadin.legacy.data.Validator.InvalidValueException; -import com.vaadin.legacy.data.validator.LegacyDateRangeValidator; import com.vaadin.legacy.data.util.converter.LegacyConverter; -import com.vaadin.legacy.ui.LegacyAbstractField; -import com.vaadin.legacy.ui.LegacyField; +import com.vaadin.legacy.data.validator.LegacyDateRangeValidator; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.shared.ui.datefield.DateFieldConstants; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.shared.ui.datefield.TextualDateFieldState; +import com.vaadin.ui.Component; +import com.vaadin.ui.Form; +import com.vaadin.ui.LegacyComponent; import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; @@ -67,7 +68,7 @@ import com.vaadin.ui.declarative.DesignContext; * @since 3.0 */ @SuppressWarnings("serial") -public class DateField extends LegacyAbstractField<Date> implements +public class LegacyDateField extends LegacyAbstractField<Date> implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier, LegacyComponent { /** @@ -181,7 +182,7 @@ public class DateField extends LegacyAbstractField<Date> implements /** * Constructs an empty <code>DateField</code> with no caption. */ - public DateField() { + public LegacyDateField() { } /** @@ -190,7 +191,7 @@ public class DateField extends LegacyAbstractField<Date> implements * @param caption * the caption of the datefield. */ - public DateField(String caption) { + public LegacyDateField(String caption) { setCaption(caption); } @@ -203,7 +204,7 @@ public class DateField extends LegacyAbstractField<Date> implements * @param dataSource * the Property to be edited with this editor. */ - public DateField(String caption, Property dataSource) { + public LegacyDateField(String caption, Property dataSource) { this(dataSource); setCaption(caption); } @@ -215,11 +216,12 @@ public class DateField extends LegacyAbstractField<Date> implements * @param dataSource * the Property to be edited with this editor. */ - public DateField(Property dataSource) throws IllegalArgumentException { + public LegacyDateField(Property dataSource) + throws IllegalArgumentException { if (!Date.class.isAssignableFrom(dataSource.getType())) { - throw new IllegalArgumentException("Can't use " - + dataSource.getType().getName() - + " typed property as datasource"); + throw new IllegalArgumentException( + "Can't use " + dataSource.getType().getName() + + " typed property as datasource"); } setPropertyDataSource(dataSource); @@ -237,7 +239,7 @@ public class DateField extends LegacyAbstractField<Date> implements * @param value * the Date value. */ - public DateField(String caption, Date value) { + public LegacyDateField(String caption, Date value) { setValue(value); setCaption(caption); } @@ -326,8 +328,8 @@ public class DateField extends LegacyAbstractField<Date> implements // Create a defensive copy against issues when using java.sql.Date (and // also against mutable Date). - getState().rangeStart = startDate != null ? new Date( - startDate.getTime()) : null; + getState().rangeStart = startDate != null + ? new Date(startDate.getTime()) : null; updateRangeValidator(); } @@ -479,15 +481,12 @@ public class DateField extends LegacyAbstractField<Date> implements @Override public void changeVariables(Object source, Map<String, Object> variables) { - if (!isReadOnly() - && (variables.containsKey("year") - || variables.containsKey("month") - || variables.containsKey("day") - || variables.containsKey("hour") - || variables.containsKey("min") - || variables.containsKey("sec") - || variables.containsKey("msec") || variables - .containsKey("dateString"))) { + if (!isReadOnly() && (variables.containsKey("year") + || variables.containsKey("month") + || variables.containsKey("day") || variables.containsKey("hour") + || variables.containsKey("min") || variables.containsKey("sec") + || variables.containsKey("msec") + || variables.containsKey("dateString"))) { // Old and new dates final Date oldDate = getValue(); @@ -545,8 +544,8 @@ public class DateField extends LegacyAbstractField<Date> implements newDate = cal.getTime(); } - if (newDate == null && dateString != null && !"".equals( - dateString)) { + if (newDate == null && dateString != null + && !"".equals(dateString)) { try { Date parsedDate = handleUnparsableDateString(dateString); setValue(parsedDate, true); @@ -659,7 +658,7 @@ public class DateField extends LegacyAbstractField<Date> implements * * @param dateString * @return parsed Date - * @throws LegacyConverter.ConversionException + * @throws Converter.ConversionException * to keep the old value and indicate an error */ protected Date handleUnparsableDateString(String dateString) @@ -816,8 +815,8 @@ public class DateField extends LegacyAbstractField<Date> implements // Start by a zeroed calendar to avoid having values for lower // resolution variables e.g. time when resolution is day int min, field; - for (Resolution r : Resolution.getResolutionsLowerThan( - resolution)) { + for (Resolution r : Resolution + .getResolutionsLowerThan(resolution)) { field = r.getCalendarField(); min = calendar.getActualMinimum(field); calendar.set(field, min); @@ -1062,8 +1061,8 @@ public class DateField extends LegacyAbstractField<Date> implements return timeZone; } - public static class UnparsableDateString extends - Validator.InvalidValueException { + public static class UnparsableDateString + extends Validator.InvalidValueException { public UnparsableDateString(String message) { super(message); @@ -1075,11 +1074,11 @@ public class DateField extends LegacyAbstractField<Date> implements public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); if (design.hasAttr("value") && !design.attr("value").isEmpty()) { - Date date = DesignAttributeHandler.getFormatter().parse( - design.attr("value"), Date.class); + Date date = DesignAttributeHandler.getFormatter() + .parse(design.attr("value"), Date.class); // formatting will return null if it cannot parse the string if (date == null) { - Logger.getLogger(DateField.class.getName()).info( + Logger.getLogger(LegacyDateField.class.getName()).info( "cannot parse " + design.attr("value") + " as date"); } this.setValue(date, false, true); diff --git a/server/src/main/java/com/vaadin/ui/InlineDateField.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyInlineDateField.java index e6f0f5d7a0..d7f5fc520f 100644 --- a/server/src/main/java/com/vaadin/ui/InlineDateField.java +++ b/server/src/main/java/com/vaadin/legacy/ui/LegacyInlineDateField.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.ui; +package com.vaadin.legacy.ui; import java.util.Date; @@ -26,30 +26,30 @@ import com.vaadin.data.Property; * * </p> * - * @see DateField - * @see PopupDateField + * @see LegacyDateField + * @see LegacyPopupDateField * @author Vaadin Ltd. * @since 5.0 */ -public class InlineDateField extends DateField { +public class LegacyInlineDateField extends LegacyDateField { - public InlineDateField() { + public LegacyInlineDateField() { super(); } - public InlineDateField(Property dataSource) throws IllegalArgumentException { + public LegacyInlineDateField(Property dataSource) throws IllegalArgumentException { super(dataSource); } - public InlineDateField(String caption, Date value) { + public LegacyInlineDateField(String caption, Date value) { super(caption, value); } - public InlineDateField(String caption, Property dataSource) { + public LegacyInlineDateField(String caption, Property dataSource) { super(caption, dataSource); } - public InlineDateField(String caption) { + public LegacyInlineDateField(String caption) { super(caption); } diff --git a/server/src/main/java/com/vaadin/ui/PopupDateField.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyPopupDateField.java index f07ac84160..05091b8663 100644 --- a/server/src/main/java/com/vaadin/ui/PopupDateField.java +++ b/server/src/main/java/com/vaadin/legacy/ui/LegacyPopupDateField.java @@ -14,7 +14,7 @@ * the License. */ -package com.vaadin.ui; +package com.vaadin.legacy.ui; import java.util.Date; @@ -29,32 +29,32 @@ import com.vaadin.shared.ui.datefield.PopupDateFieldState; * * </p> * - * @see DateField - * @see InlineDateField + * @see LegacyDateField + * @see LegacyInlineDateField * @author Vaadin Ltd. * @since 5.0 */ -public class PopupDateField extends DateField { +public class LegacyPopupDateField extends LegacyDateField { private String inputPrompt = null; - public PopupDateField() { + public LegacyPopupDateField() { super(); } - public PopupDateField(Property dataSource) throws IllegalArgumentException { + public LegacyPopupDateField(Property dataSource) throws IllegalArgumentException { super(dataSource); } - public PopupDateField(String caption, Date value) { + public LegacyPopupDateField(String caption, Date value) { super(caption, value); } - public PopupDateField(String caption, Property dataSource) { + public LegacyPopupDateField(String caption, Property dataSource) { super(caption, dataSource); } - public PopupDateField(String caption) { + public LegacyPopupDateField(String caption) { super(caption); } diff --git a/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java b/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java index 3e44a901fc..925f50244c 100644 --- a/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java +++ b/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java @@ -21,6 +21,7 @@ import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.data.Property; import com.vaadin.legacy.ui.LegacyCheckBox; +import com.vaadin.legacy.ui.LegacyDateField; import com.vaadin.legacy.ui.LegacyField; import com.vaadin.shared.util.SharedUtil; @@ -34,7 +35,8 @@ import com.vaadin.shared.util.SharedUtil; * factories. * */ -public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory { +public class DefaultFieldFactory + implements FormFieldFactory, TableFieldFactory { private static final DefaultFieldFactory instance = new DefaultFieldFactory(); @@ -88,7 +90,7 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory * by this method: * <p> * <b>Boolean</b>: {@link CheckBox}.<br/> - * <b>Date</b>: {@link DateField}(resolution: day).<br/> + * <b>Date</b>: {@link LegacyDateField}(resolution: day).<br/> * <b>Item</b>: {@link Form}. <br/> * <b>default field type</b>: {@link TextField}. * <p> @@ -110,8 +112,8 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory // Date field if (Date.class.isAssignableFrom(type)) { - final DateField df = new DateField(); - df.setResolution(DateField.RESOLUTION_DAY); + final LegacyDateField df = new LegacyDateField(); + df.setResolution(LegacyDateField.RESOLUTION_DAY); return df; } diff --git a/server/src/test/java/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java b/server/src/test/java/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java index 1b019586e2..62ea95148c 100644 --- a/server/src/test/java/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java +++ b/server/src/test/java/com/vaadin/data/DefaultFieldGroupFieldFactoryTest.java @@ -23,13 +23,13 @@ import org.junit.Before; import org.junit.Test; import com.vaadin.data.fieldgroup.DefaultFieldGroupFieldFactory; +import com.vaadin.legacy.ui.LegacyDateField; +import com.vaadin.legacy.ui.LegacyInlineDateField; import com.vaadin.legacy.ui.LegacyField; +import com.vaadin.legacy.ui.LegacyPopupDateField; import com.vaadin.ui.AbstractSelect; import com.vaadin.ui.ComboBox; -import com.vaadin.ui.DateField; -import com.vaadin.ui.InlineDateField; import com.vaadin.ui.ListSelect; -import com.vaadin.ui.PopupDateField; import com.vaadin.ui.TextField; public class DefaultFieldGroupFieldFactoryTest { @@ -66,16 +66,16 @@ public class DefaultFieldGroupFieldFactoryTest { @Test public void testDateGenerationForPopupDateField() { - LegacyField f = fieldFactory.createField(Date.class, DateField.class); + LegacyField f = fieldFactory.createField(Date.class, LegacyDateField.class); Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + Assert.assertEquals(LegacyPopupDateField.class, f.getClass()); } @Test public void testDateGenerationForInlineDateField() { - LegacyField f = fieldFactory.createField(Date.class, InlineDateField.class); + LegacyField f = fieldFactory.createField(Date.class, LegacyInlineDateField.class); Assert.assertNotNull(f); - Assert.assertEquals(InlineDateField.class, f.getClass()); + Assert.assertEquals(LegacyInlineDateField.class, f.getClass()); } @Test @@ -89,7 +89,7 @@ public class DefaultFieldGroupFieldFactoryTest { public void testDateGenerationForField() { LegacyField f = fieldFactory.createField(Date.class, LegacyField.class); Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + Assert.assertEquals(LegacyPopupDateField.class, f.getClass()); } public enum SomeEnum { diff --git a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupDateTest.java b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupDateTest.java index 919f4d3974..1226939e31 100644 --- a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupDateTest.java +++ b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupDateTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import com.vaadin.data.util.BeanItem; import com.vaadin.legacy.ui.LegacyField; -import com.vaadin.ui.PopupDateField; +import com.vaadin.legacy.ui.LegacyPopupDateField; public class FieldGroupDateTest { @@ -68,20 +68,20 @@ public class FieldGroupDateTest { public void testBuildAndBindDate() { LegacyField f = fieldGroup.buildAndBind("javaDate"); Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + Assert.assertEquals(LegacyPopupDateField.class, f.getClass()); } @Test public void testBuildAndBindSqlDate() { LegacyField f = fieldGroup.buildAndBind("sqlDate"); Assert.assertNotNull(f); - Assert.assertEquals(PopupDateField.class, f.getClass()); + Assert.assertEquals(LegacyPopupDateField.class, f.getClass()); } @Test public void clearFields() { - PopupDateField sqlDate = new PopupDateField(); - PopupDateField javaDate = new PopupDateField(); + LegacyPopupDateField sqlDate = new LegacyPopupDateField(); + LegacyPopupDateField javaDate = new LegacyPopupDateField(); fieldGroup.bind(sqlDate, "sqlDate"); fieldGroup.bind(javaDate, "javaDate"); diff --git a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupExceptionTest.java b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupExceptionTest.java index 636162de54..617301b155 100644 --- a/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupExceptionTest.java +++ b/server/src/test/java/com/vaadin/data/fieldgroup/FieldGroupExceptionTest.java @@ -18,14 +18,14 @@ package com.vaadin.data.fieldgroup; import org.junit.Test; import com.vaadin.data.fieldgroup.FieldGroup.CommitException; -import com.vaadin.ui.PopupDateField; +import com.vaadin.legacy.ui.LegacyPopupDateField; public class FieldGroupExceptionTest { @Test(expected = CommitException.class) public void testUnboundCommitException() throws CommitException { FieldGroup fieldGroup = new FieldGroup(); - PopupDateField dateField = new PopupDateField(); + LegacyPopupDateField dateField = new LegacyPopupDateField(); fieldGroup.bind(dateField, "date"); fieldGroup.commit(); } diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java index b1abb7e5b5..eb3da47957 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldConverterTest.java @@ -25,18 +25,18 @@ import org.junit.Test; import com.vaadin.data.Property; import com.vaadin.data.util.ObjectProperty; import com.vaadin.legacy.data.util.converter.LegacyConverter; +import com.vaadin.legacy.ui.LegacyDateField; import com.vaadin.shared.ui.datefield.Resolution; -import com.vaadin.ui.DateField; public class DateFieldConverterTest { private Property<Long> date; - private DateField datefield; + private LegacyDateField datefield; @Before public void setUp() { date = new ObjectProperty<Long>(0L); - datefield = new DateField(); + datefield = new LegacyDateField(); datefield.setBuffered(false); datefield.setConverter(new LegacyConverter<Date, Long>() { diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java index dc6db3bfe6..4950ef5bef 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldDeclarativeTest.java @@ -21,24 +21,25 @@ import java.util.TimeZone; import org.junit.Test; +import com.vaadin.legacy.ui.LegacyDateField; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.DateField; /** - * Tests the declarative support for implementations of {@link DateField}. + * Tests the declarative support for implementations of {@link LegacyDateField}. * * @author Vaadin Ltd * @since 7.4 */ -public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { +public class DateFieldDeclarativeTest + extends DeclarativeTestBase<LegacyDateField> { private String getYearResolutionDesign() { - return "<vaadin-date-field resolution='year' value='2020'/>"; + return "<com_vaadin_legacy_ui-legacy-date-field resolution='year' value='2020'/>"; } - private DateField getYearResolutionExpected() { - DateField df = new DateField(); + private LegacyDateField getYearResolutionExpected() { + LegacyDateField df = new LegacyDateField(); df.setResolution(Resolution.YEAR); df.setValue(new Date(2020 - 1900, 1 - 1, 1)); return df; @@ -46,11 +47,13 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { private String getTimezoneDesign() { String timeZone = new SimpleDateFormat("Z").format(new Date()); - return String.format("<vaadin-date-field range-start=\"2014-05-05 00:00:00%1$s\" range-end=\"2014-06-05 00:00:00%1$s\" date-out-of-range-message=\"Please select a sensible date\" date-format=\"yyyy-MM-dd\" lenient show-iso-week-numbers parse-error-message=\"You are doing it wrong\" time-zone=\"GMT+05:00\" value=\"2014-05-15 00:00:00%1$s\"/>" ,timeZone); + return String.format( + "<com_vaadin_legacy_ui-legacy-date-field range-start=\"2014-05-05 00:00:00%1$s\" range-end=\"2014-06-05 00:00:00%1$s\" date-out-of-range-message=\"Please select a sensible date\" date-format=\"yyyy-MM-dd\" lenient show-iso-week-numbers parse-error-message=\"You are doing it wrong\" time-zone=\"GMT+05:00\" value=\"2014-05-15 00:00:00%1$s\"/>", + timeZone); } - private DateField getTimezoneExpected() { - DateField df = new DateField(); + private LegacyDateField getTimezoneExpected() { + LegacyDateField df = new LegacyDateField(); df.setRangeStart(new Date(2014 - 1900, 5 - 1, 5)); df.setRangeEnd(new Date(2014 - 1900, 6 - 1, 5)); @@ -84,19 +87,21 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { @Test public void writeYearResolution() { // Writing is always done in full resolution.. - String timeZone = new SimpleDateFormat("Z").format(new Date(2020 - 1900, 1 - 1, 1)); + String timeZone = new SimpleDateFormat("Z") + .format(new Date(2020 - 1900, 1 - 1, 1)); testWrite( - getYearResolutionDesign().replace("2020", - "2020-01-01 00:00:00" + timeZone), - getYearResolutionExpected()); + getYearResolutionDesign().replace("2020", + "2020-01-01 00:00:00" + timeZone), + getYearResolutionExpected()); } @Test public void testReadOnlyValue() { Date date = new Date(2020 - 1900, 1 - 1, 1); String timeZone = new SimpleDateFormat("Z").format(date); - String design = "<vaadin-date-field readonly resolution='year' value='2020-01-01 00:00:00" + timeZone + "'/>"; - DateField df = new DateField(); + String design = "<com_vaadin_legacy_ui-legacy-date-field readonly resolution='year' value='2020-01-01 00:00:00" + + timeZone + "'/>"; + LegacyDateField df = new LegacyDateField(); df.setResolution(Resolution.YEAR); df.setValue(date); df.setReadOnly(true); @@ -104,4 +109,12 @@ public class DateFieldDeclarativeTest extends DeclarativeTestBase<DateField> { testRead(design, df); testWrite(design, df); } + + @Override + public LegacyDateField testRead(String design, LegacyDateField expected) { + return super.testRead( + "<html><head><meta charset='UTF-8' name='package-mapping' content='com_vaadin_legacy_ui:com.vaadin.legacy.ui'></head> " + + design + "</html>", + expected); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java index 8885573bd8..bd0af5361e 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/DateFieldListenersTest.java @@ -6,20 +6,20 @@ import com.vaadin.event.FieldEvents.BlurEvent; import com.vaadin.event.FieldEvents.BlurListener; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; +import com.vaadin.legacy.ui.LegacyDateField; import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase; -import com.vaadin.ui.DateField; public class DateFieldListenersTest extends AbstractListenerMethodsTestBase { @Test public void testFocusListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(DateField.class, FocusEvent.class, + testListenerAddGetRemove(LegacyDateField.class, FocusEvent.class, FocusListener.class); } @Test public void testBlurListenerAddGetRemove() throws Exception { - testListenerAddGetRemove(DateField.class, BlurEvent.class, + testListenerAddGetRemove(LegacyDateField.class, BlurEvent.class, BlurListener.class); } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java index 04468c658a..77c5a23c73 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/InlineDateFieldDeclarativeTest.java @@ -21,24 +21,24 @@ import java.text.SimpleDateFormat; import org.junit.Test; +import com.vaadin.legacy.ui.LegacyDateField; +import com.vaadin.legacy.ui.LegacyInlineDateField; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.DateField; -import com.vaadin.ui.InlineDateField; import com.vaadin.ui.declarative.Design; /** - * Tests the declarative support for implementations of {@link DateField}. + * Tests the declarative support for implementations of {@link LegacyDateField}. * * @since 7.4 * @author Vaadin Ltd */ public class InlineDateFieldDeclarativeTest extends - DeclarativeTestBase<InlineDateField> { + DeclarativeTestBase<LegacyInlineDateField> { @Test public void testInlineDateFieldToFromDesign() throws Exception { - InlineDateField field = new InlineDateField("Day is", + LegacyInlineDateField field = new LegacyInlineDateField("Day is", new SimpleDateFormat("yyyy-MM-dd").parse("2003-02-27")); field.setResolution(Resolution.DAY); field.setShowISOWeekNumbers(true); @@ -50,7 +50,7 @@ public class InlineDateFieldDeclarativeTest extends ByteArrayOutputStream bos = new ByteArrayOutputStream(); Design.write(field, bos); - InlineDateField result = (InlineDateField) Design + LegacyInlineDateField result = (LegacyInlineDateField) Design .read(new ByteArrayInputStream(bos.toByteArray())); assertEquals(field.getResolution(), result.getResolution()); assertEquals(field.getCaption(), result.getCaption()); diff --git a/server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java index b637d10c9e..f22583e1ae 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/datefield/PopupDateFieldDeclarativeTest.java @@ -19,26 +19,26 @@ import java.util.Date; import org.junit.Test; +import com.vaadin.legacy.ui.LegacyDateField; +import com.vaadin.legacy.ui.LegacyPopupDateField; import com.vaadin.shared.ui.datefield.Resolution; import com.vaadin.tests.design.DeclarativeTestBase; -import com.vaadin.ui.DateField; -import com.vaadin.ui.PopupDateField; /** - * Tests the declarative support for implementations of {@link DateField}. + * Tests the declarative support for implementations of {@link LegacyDateField}. * * @since 7.4 * @author Vaadin Ltd */ -public class PopupDateFieldDeclarativeTest extends - DeclarativeTestBase<PopupDateField> { +public class PopupDateFieldDeclarativeTest + extends DeclarativeTestBase<LegacyPopupDateField> { private String getBasicDesign() { - return "<vaadin-popup-date-field assistive-text='at' text-field-enabled='false' show-iso-week-numbers resolution=\"MINUTE\" range-end=\"2019-01-15\" input-prompt=\"Pick a day\" value=\"2003-02-27 07:15\"></vaadin-popup-date-field>"; + return "<com_vaadin_legacy_ui-legacy-popup-date-field assistive-text='at' text-field-enabled='false' show-iso-week-numbers resolution=\"MINUTE\" range-end=\"2019-01-15\" input-prompt=\"Pick a day\" value=\"2003-02-27 07:15\"></vaadin-popup-date-field>"; } - private PopupDateField getBasicExpected() { - PopupDateField pdf = new PopupDateField(); + private LegacyPopupDateField getBasicExpected() { + LegacyPopupDateField pdf = new LegacyPopupDateField(); pdf.setShowISOWeekNumbers(true); pdf.setResolution(Resolution.MINUTE); pdf.setRangeEnd(new Date(2019 - 1900, 1 - 1, 15)); @@ -59,4 +59,12 @@ public class PopupDateFieldDeclarativeTest extends testRead(getBasicDesign(), getBasicExpected()); } + @Override + public LegacyPopupDateField testRead(String design, + LegacyPopupDateField expected) { + return super.testRead( + "<html><head><meta charset='UTF-8' name='package-mapping' content='com_vaadin_legacy_ui:com.vaadin.legacy.ui'></head> " + + design + "</html>", + expected); + } } diff --git a/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java index 5fee13f2cb..d8c75fb795 100644 --- a/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java +++ b/server/src/test/java/com/vaadin/ui/DateFieldTestCase.java @@ -3,6 +3,8 @@ package com.vaadin.ui; import org.junit.Before; import org.junit.Test; +import com.vaadin.legacy.ui.LegacyDateField; + import java.util.Date; import static org.hamcrest.CoreMatchers.is; @@ -11,12 +13,12 @@ import static org.hamcrest.core.IsNull.nullValue; public class DateFieldTestCase { - private DateField dateField; + private LegacyDateField dateField; private Date date; @Before public void setup() { - dateField = new DateField(); + dateField = new LegacyDateField(); date = new Date(); } |