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.

MenuBarTooltipsNearEdge.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.menubar;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.tests.components.AbstractReindeerTestUI;
  19. import com.vaadin.ui.Alignment;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.ui.MenuBar;
  22. import com.vaadin.ui.MenuBar.MenuItem;
  23. import com.vaadin.ui.VerticalLayout;
  24. /**
  25. * Test to see if tooltips will render in the correct locations near the edges.
  26. *
  27. * @author Vaadin Ltd
  28. */
  29. public class MenuBarTooltipsNearEdge extends AbstractReindeerTestUI {
  30. /*
  31. * (non-Javadoc)
  32. *
  33. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  34. * VaadinRequest)
  35. */
  36. @Override
  37. protected void setup(VaadinRequest request) {
  38. VerticalLayout vlayout = new VerticalLayout();
  39. vlayout.setSizeFull();
  40. vlayout.addComponent(buildMenu("Menu"));
  41. vlayout.setComponentAlignment(vlayout.getComponent(0),
  42. Alignment.BOTTOM_RIGHT);
  43. setContent(vlayout);
  44. getTooltipConfiguration().setOpenDelay(0);
  45. getTooltipConfiguration().setQuickOpenDelay(0);
  46. getTooltipConfiguration().setCloseTimeout(1000);
  47. }
  48. private Component buildMenu(String label) {
  49. MenuBar menu = new MenuBar();
  50. MenuItem item = menu.addItem(label, null);
  51. item.addItem("Item 1", null).setDescription("TOOLTIP FOR ITEM 1");
  52. item.addItem("Item 2", null).setDescription("TOOLTIP FOR ITEM 2");
  53. item.addItem("Item 3", null).setDescription("TOOLTIP FOR ITEM 3");
  54. item.addItem("Item 4", null).setDescription("TOOLTIP FOR ITEM 4");
  55. return menu;
  56. }
  57. /*
  58. * (non-Javadoc)
  59. *
  60. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  61. */
  62. @Override
  63. protected String getTestDescription() {
  64. return "Menu item tooltips should not abscure other menu items";
  65. }
  66. /*
  67. * (non-Javadoc)
  68. *
  69. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  70. */
  71. @Override
  72. protected Integer getTicketNumber() {
  73. return 12870;
  74. }
  75. }