diff options
author | Denis <denis@vaadin.com> | 2017-01-10 12:22:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-10 12:22:34 +0200 |
commit | 3ef30789d6ac773eed7346dcaa670426fa6f662c (patch) | |
tree | 2e5aee20b96e3a66088aa6cde13796256ec2bcf1 /shared | |
parent | b4af93bebf1b7e51d33330c42e3c89d5e3e4fd45 (diff) | |
download | vaadin-framework-3ef30789d6ac773eed7346dcaa670426fa6f662c.tar.gz vaadin-framework-3ef30789d6ac773eed7346dcaa670426fa6f662c.zip |
Refactor AbstractDateField. (#8146)
First round for #8132.
Diffstat (limited to 'shared')
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractDateFieldState.java (renamed from shared/src/main/java/com/vaadin/shared/ui/datefield/DateFieldState.java) | 28 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractTextualDateFieldState.java | 26 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/DateResolution.java (renamed from shared/src/main/java/com/vaadin/shared/ui/datefield/Resolution.java) | 17 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/DateTimeResolution.java | 27 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/InlineDateFieldState.java | 2 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateFieldState.java | 26 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateTimeFieldState.java | 26 | ||||
-rw-r--r-- | shared/src/main/java/com/vaadin/shared/ui/datefield/TextualDateFieldState.java | 23 |
8 files changed, 144 insertions, 31 deletions
diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/DateFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractDateFieldState.java index 4566096e9a..12a0ebd367 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/datefield/DateFieldState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractDateFieldState.java @@ -15,20 +15,34 @@ */ package com.vaadin.shared.ui.datefield; -import com.vaadin.shared.annotations.DelegateToWidget; +import java.util.Date; + +import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.annotations.NoLayout; -public class DateFieldState extends TextualDateFieldState { - public static final String DESCRIPTION_FOR_ASSISTIVE_DEVICES = "Arrow down key opens calendar element for choosing the date"; +/** + * Shared state for the AbstractDateField component. + * + * @author Vaadin Ltd + * + */ +public class AbstractDateFieldState extends AbstractFieldState { { primaryStyleName = "v-datefield"; } - public boolean textFieldEnabled = true; + /* + * Start range that has been cleared, depending on the resolution of the + * date field + */ @NoLayout - public String descriptionForAssistiveDevices = DESCRIPTION_FOR_ASSISTIVE_DEVICES; + public Date rangeStart = null; + + /* + * End range that has been cleared, depending on the resolution of the date + * field + */ @NoLayout - @DelegateToWidget - public String placeholder = null; + public Date rangeEnd = null; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractTextualDateFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractTextualDateFieldState.java new file mode 100644 index 0000000000..843c453f39 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/AbstractTextualDateFieldState.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.datefield; + +/** + * Shared state for the AbstractLocalDateField component. + * + * @author Vaadin Ltd + * + */ +public class AbstractTextualDateFieldState extends AbstractDateFieldState { + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/Resolution.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/DateResolution.java index 0fc5da4803..ce2871e0a7 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/datefield/Resolution.java +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/DateResolution.java @@ -24,7 +24,7 @@ import java.util.List; * @author Vaadin Ltd. * @since 7.0 */ -public enum Resolution { +public enum DateResolution { DAY, MONTH, YEAR; /** @@ -36,10 +36,10 @@ public enum Resolution { * The resolution to start from * @return An iterable for the resolutions higher or equal to r */ - public static Iterable<Resolution> getResolutionsHigherOrEqualTo( - Resolution r) { - List<Resolution> resolutions = new ArrayList<>(); - Resolution[] values = Resolution.values(); + public static Iterable<DateResolution> getResolutionsHigherOrEqualTo( + DateResolution r) { + List<DateResolution> resolutions = new ArrayList<>(); + DateResolution[] values = DateResolution.values(); for (int i = r.ordinal(); i < values.length; i++) { resolutions.add(values[i]); } @@ -55,9 +55,10 @@ public enum Resolution { * The resolution to start from * @return An iterable for the resolutions lower than r */ - public static List<Resolution> getResolutionsLowerThan(Resolution r) { - List<Resolution> resolutions = new ArrayList<>(); - Resolution[] values = Resolution.values(); + public static List<DateResolution> getResolutionsLowerThan( + DateResolution r) { + List<DateResolution> resolutions = new ArrayList<>(); + DateResolution[] values = DateResolution.values(); for (int i = r.ordinal() - 1; i >= 0; i--) { resolutions.add(values[i]); } diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/DateTimeResolution.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/DateTimeResolution.java new file mode 100644 index 0000000000..7876fb51f4 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/DateTimeResolution.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.datefield; + +/** + * Resolutions for DateTimeFields + * + * @author Vaadin Ltd. + * @since 8.0 + */ +public enum DateTimeResolution { + SECOND, MINUTE, HOUR, DAY, MONTH, YEAR; + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/InlineDateFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/InlineDateFieldState.java index da0fe14a29..42c21b9376 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/datefield/InlineDateFieldState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/InlineDateFieldState.java @@ -15,7 +15,7 @@ */ package com.vaadin.shared.ui.datefield; -public class InlineDateFieldState extends TextualDateFieldState { +public class InlineDateFieldState extends AbstractTextualDateFieldState { { primaryStyleName = "v-inline-datefield"; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateFieldState.java new file mode 100644 index 0000000000..fdfea3eab6 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateFieldState.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.datefield; + +/** + * Shared state for the DateField component. + * + * @author Vaadin Ltd + * + */ +public class LocalDateFieldState extends TextualDateFieldState { + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateTimeFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateTimeFieldState.java new file mode 100644 index 0000000000..cb439dd1a8 --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/LocalDateTimeFieldState.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui.datefield; + +/** + * Shared state for the DateTimeField component. + * + * @author Vaadin Ltd + * + */ +public class LocalDateTimeFieldState extends AbstractTextualDateFieldState { + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/datefield/TextualDateFieldState.java b/shared/src/main/java/com/vaadin/shared/ui/datefield/TextualDateFieldState.java index ae0ec560e0..fa5c0ac8be 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/datefield/TextualDateFieldState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/datefield/TextualDateFieldState.java @@ -15,27 +15,20 @@ */ package com.vaadin.shared.ui.datefield; -import java.util.Date; - -import com.vaadin.shared.AbstractFieldState; +import com.vaadin.shared.annotations.DelegateToWidget; import com.vaadin.shared.annotations.NoLayout; -public class TextualDateFieldState extends AbstractFieldState { +public class TextualDateFieldState extends AbstractTextualDateFieldState { + public static final String DESCRIPTION_FOR_ASSISTIVE_DEVICES = "Arrow down key opens calendar element for choosing the date"; + { primaryStyleName = "v-datefield"; } - /* - * Start range that has been cleared, depending on the resolution of the - * date field - */ + public boolean textFieldEnabled = true; @NoLayout - public Date rangeStart = null; - - /* - * End range that has been cleared, depending on the resolution of the date - * field - */ + public String descriptionForAssistiveDevices = DESCRIPTION_FOR_ASSISTIVE_DEVICES; @NoLayout - public Date rangeEnd = null; + @DelegateToWidget + public String placeholder = null; } |