1 package com.vaadin.tests.components.datefield;
3 import java.time.LocalDate;
5 import com.vaadin.server.VaadinRequest;
6 import com.vaadin.shared.ui.datefield.DateResolution;
7 import com.vaadin.tests.components.AbstractTestUI;
8 import com.vaadin.ui.Button;
9 import com.vaadin.ui.DateField;
11 public class DateFieldMonthResolutionStatusChange extends AbstractTestUI {
14 protected void setup(VaadinRequest request) {
15 DateField dateField = new DateField();
16 dateField.setResolution(DateResolution.MONTH);
17 dateField.setValue(LocalDate.of(2019, 1, 1));
18 dateField.setReadOnly(true);
20 Button dateReadOnlySwitch = new Button("Toggle read-only");
21 dateReadOnlySwitch.setId("readOnly");
22 dateReadOnlySwitch.addClickListener(event -> {
23 dateField.setReadOnly(!dateField.isReadOnly());
26 Button addRangeButton = new Button("Add range");
27 addRangeButton.setId("addRange");
28 addRangeButton.addClickListener(event -> {
29 dateField.setRangeStart(LocalDate.of(2018, 1, 1));
30 dateField.setRangeEnd(LocalDate.of(2020, 1, 1));
33 addComponent(dateField);
34 addComponent(dateReadOnlySwitch);
35 addComponent(addRangeButton);
39 protected String getTestDescription() {
40 return "Changing any field status (e.g. read-only or range) before "
41 + "the DateField popup has been opened should not change "
42 + "the date to current.";
46 protected Integer getTicketNumber() {