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.

ComboboxMenuBarAutoopen.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.server.Page;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.tests.components.AbstractReindeerTestUI;
  5. import com.vaadin.ui.ComboBox;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.MenuBar;
  8. import com.vaadin.ui.MenuBar.MenuItem;
  9. import com.vaadin.ui.Notification;
  10. import com.vaadin.ui.Notification.Type;
  11. /**
  12. * Test UI for combobox popup which should be closed on any click outside it.
  13. *
  14. * @author Vaadin Ltd
  15. */
  16. public class ComboboxMenuBarAutoopen extends AbstractReindeerTestUI {
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. HorizontalLayout layout = new HorizontalLayout();
  20. layout.setSpacing(true);
  21. ComboBox<String> combo = new ComboBox<>();
  22. combo.setItems("1", "2", "3");
  23. layout.addComponent(combo);
  24. MenuBar menubar = getMenubar();
  25. layout.addComponent(menubar);
  26. addComponent(layout);
  27. }
  28. @Override
  29. protected String getTestDescription() {
  30. return "Combobox popup should close on click to other popup or associated components.";
  31. }
  32. @Override
  33. protected Integer getTicketNumber() {
  34. return 14321;
  35. }
  36. private MenuBar getMenubar() {
  37. MenuBar menubar = new MenuBar();
  38. menubar.setAutoOpen(true);
  39. MenuItem item = menubar.addItem("auto-open", null);
  40. item.addItem("sub-item 1", new MenuBar.Command() {
  41. @Override
  42. public void menuSelected(MenuItem selectedItem) {
  43. Notification notification = new Notification("Test",
  44. Type.HUMANIZED_MESSAGE);
  45. notification.show(Page.getCurrent());
  46. }
  47. });
  48. return menubar;
  49. }
  50. }