]> source.dussan.org Git - vaadin-framework.git/blob
55b2823a1d168f1802ab3b9c00425b7f154619e8
[vaadin-framework.git] /
1 package com.vaadin.tests.components.datefield;
2
3 import java.time.LocalDate;
4
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;
10
11 public class DateFieldMonthResolutionStatusChange extends AbstractTestUI {
12
13     @Override
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);
19
20         Button dateReadOnlySwitch = new Button("Toggle read-only");
21         dateReadOnlySwitch.setId("readOnly");
22         dateReadOnlySwitch.addClickListener(event -> {
23             dateField.setReadOnly(!dateField.isReadOnly());
24         });
25
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));
31         });
32
33         addComponent(dateField);
34         addComponent(dateReadOnlySwitch);
35         addComponent(addRangeButton);
36     }
37
38     @Override
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.";
43     }
44
45     @Override
46     protected Integer getTicketNumber() {
47         return 11864;
48     }
49 }