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.

TooltipPosition.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2000-2014 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;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.ui.Button;
  19. import com.vaadin.ui.UI;
  20. import com.vaadin.ui.VerticalLayout;
  21. /**
  22. * This UI is used for testing that a tooltip is not positioned partially
  23. * outside the browser window when there is enough space to display it.
  24. *
  25. * @author Vaadin Ltd
  26. */
  27. public class TooltipPosition extends AbstractTestUI {
  28. public static final int NUMBER_OF_BUTTONS = 5;
  29. @Override
  30. protected void setup(VaadinRequest request) {
  31. // These tooltip delay settings can be removed once #13854 is resolved.
  32. getTooltipConfiguration().setOpenDelay(0);
  33. getTooltipConfiguration().setQuickOpenDelay(0);
  34. getTooltipConfiguration().setCloseTimeout(1000);
  35. VerticalLayout layout = new VerticalLayout();
  36. layout.setSpacing(true);
  37. layout.setHeight(UI.getCurrent().getPage().getBrowserWindowHeight(),
  38. Unit.PIXELS);
  39. addComponent(layout);
  40. for (int i = 0; i < NUMBER_OF_BUTTONS; i++) {
  41. Button button = new Button("Button");
  42. button.setDescription(generateTooltipText());
  43. layout.addComponent(button);
  44. }
  45. }
  46. private String generateTooltipText() {
  47. StringBuilder result = new StringBuilder();
  48. for (int i = 0; i < 50; i++) {
  49. result.append("This is the line ").append(i)
  50. .append(" of the long tooltip text.<br>");
  51. }
  52. return result.toString();
  53. }
  54. @Override
  55. public String getTestDescription() {
  56. return "The tooltips of the buttons should not be clipped when there is enough space to display them.";
  57. }
  58. @Override
  59. public Integer getTicketNumber() {
  60. return 15129;
  61. }
  62. }