You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DateFieldReadOnly.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.vaadin.tests.components.datefield;
  2. import java.time.LocalDate;
  3. import java.util.Locale;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractReindeerTestUI;
  6. import com.vaadin.tests.components.TestDateField;
  7. import com.vaadin.ui.AbstractLocalDateField;
  8. import com.vaadin.ui.Button;
  9. public class DateFieldReadOnly extends AbstractReindeerTestUI {
  10. @Override
  11. protected String getTestDescription() {
  12. return "A read-only DateField should not show the popup button and not be editable.";
  13. }
  14. @Override
  15. protected Integer getTicketNumber() {
  16. return 3163;
  17. }
  18. @Override
  19. protected void setup(VaadinRequest request) {
  20. final AbstractLocalDateField timeField = new TestDateField(
  21. "A read-only datefield");
  22. timeField.setCaption(null);
  23. timeField.setIcon(null);
  24. timeField.setWidth("8em");
  25. timeField.addStyleName("timeField");
  26. timeField.setLocale(new Locale("fi"));
  27. // Set date so that testing always has same time
  28. timeField.setValue(LocalDate.of(2009, 6, 12));
  29. timeField.setReadOnly(true);
  30. addComponent(timeField);
  31. Button b = new Button("Switch read-only");
  32. b.addClickListener(
  33. event -> timeField.setReadOnly(!timeField.isReadOnly()));
  34. addComponent(b);
  35. }
  36. }