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.

ModalWindowFocus.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.vaadin.tests.components.window;
  2. import com.vaadin.annotations.Widgetset;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.tests.components.AbstractReindeerTestUI;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.TextField;
  8. import com.vaadin.ui.VerticalLayout;
  9. import com.vaadin.ui.Window;
  10. @Widgetset("com.vaadin.DefaultWidgetSet")
  11. public class ModalWindowFocus extends AbstractReindeerTestUI {
  12. @Override
  13. protected void setup(VaadinRequest req) {
  14. Button button = new Button("Open windows");
  15. button.setTabIndex(2);
  16. button.setId("firstButton");
  17. addComponent(button);
  18. button.addClickListener(event -> {
  19. Window w = new Window("This is first window");
  20. w.setModal(true);
  21. addWindow(w);
  22. Window w2 = new Window("This is second window");
  23. w2.setModal(true);
  24. addWindow(w2);
  25. HorizontalLayout lay = new HorizontalLayout();
  26. Button buttonInWindow = new Button("Open window");
  27. buttonInWindow.setId("windowButton");
  28. lay.addComponent(buttonInWindow);
  29. w2.setContent(lay);
  30. buttonInWindow.addClickListener(clickEvent -> {
  31. Window w3 = new Window("This is third window");
  32. w3.setModal(true);
  33. w3.setId("window3");
  34. addWindow(w3);
  35. });
  36. });
  37. Button button2 = new Button(
  38. "Open unclosable and unresizable modal window");
  39. button2.setTabIndex(1);
  40. addComponent(button2);
  41. button2.setId("modalWindowButton");
  42. button2.addClickListener(event -> {
  43. Window modalWindow = new Window("Modal window");
  44. modalWindow.setModal(true);
  45. modalWindow.setClosable(false);
  46. modalWindow.setResizable(false);
  47. VerticalLayout vl = new VerticalLayout();
  48. TextField tf = new TextField("Textfield");
  49. tf.setId("focusfield");
  50. tf.addFocusListener(e -> tf.setValue("this has been focused"));
  51. TextField tf2 = new TextField("Another Textfield");
  52. tf2.focus();
  53. vl.addComponents(tf, tf2);
  54. modalWindow.setContent(vl);
  55. addWindow(modalWindow);
  56. });
  57. }
  58. @Override
  59. protected String getTestDescription() {
  60. return "Topmost modal window should be focused on opening "
  61. + "and on closing an overlying window";
  62. }
  63. @Override
  64. protected Integer getTicketNumber() {
  65. return 17021;
  66. }
  67. }