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.

DateFieldPopupClosingOnDetach.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.vaadin.tests.components.datefield;
  2. import java.util.Timer;
  3. import java.util.TimerTask;
  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. public class DateFieldPopupClosingOnDetach extends AbstractReindeerTestUI {
  9. @Override
  10. protected void setup(VaadinRequest request) {
  11. // Use polling to notice the removal of DateField.
  12. getUI().setPollInterval(500);
  13. final AbstractLocalDateField df = new TestDateField();
  14. getLayout().addLayoutClickListener(event -> {
  15. // Use a background Thread to remove the DateField 1 second
  16. // after being clicked.
  17. TimerTask removeTask = new TimerTask() {
  18. @Override
  19. public void run() {
  20. getUI().access(() -> removeComponent(df));
  21. }
  22. };
  23. new Timer(true).schedule(removeTask, 1000);
  24. });
  25. addComponent(df);
  26. }
  27. @Override
  28. protected String getTestDescription() {
  29. return "DateField popup should be removed if it's open while the DateField is removed. "
  30. + "Click the popup open and a background Thread will remove the DateField after 1 second.";
  31. }
  32. @Override
  33. protected Integer getTicketNumber() {
  34. return 18985;
  35. }
  36. }