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.

TestSelectAndDatefieldInDeepLayouts.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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;
  17. import java.util.Collection;
  18. import java.util.Vector;
  19. import com.vaadin.ui.AbstractOrderedLayout;
  20. import com.vaadin.ui.Component;
  21. import com.vaadin.ui.ComponentContainer;
  22. import com.vaadin.ui.CustomComponent;
  23. import com.vaadin.ui.DateField;
  24. import com.vaadin.ui.Panel;
  25. import com.vaadin.ui.Select;
  26. import com.vaadin.ui.VerticalLayout;
  27. /**
  28. * This test has a somewhat deep layout within one page. At the bottom, Select
  29. * and Datefield render their popups incorrectly. Popus tend to be "left behind"
  30. * from the actual components. When the page is even bigger or longer, the
  31. * popups are eventually rendered outside the visual parts of the page.
  32. *
  33. * @author Ville Ingman
  34. *
  35. */
  36. public class TestSelectAndDatefieldInDeepLayouts extends CustomComponent {
  37. public TestSelectAndDatefieldInDeepLayouts() {
  38. final AbstractOrderedLayout root = getOrderedLayout();
  39. setCompositionRoot(root);
  40. root.addComponent(getSelect());
  41. root.addComponent(getDateField());
  42. root.addComponent(getSelect());
  43. root.addComponent(getDateField());
  44. final VerticalLayout p1Layout = createPanelLayout();
  45. final Panel p1 = getPanel(p1Layout);
  46. p1.setContent(p1Layout);
  47. root.addComponent(p1);
  48. p1Layout.addComponent(getSelect());
  49. p1Layout.addComponent(getDateField());
  50. p1Layout.addComponent(getSelect());
  51. p1Layout.addComponent(getDateField());
  52. final AbstractOrderedLayout l1 = getOrderedLayout();
  53. p1Layout.addComponent(l1);
  54. l1.addComponent(getSelect());
  55. l1.addComponent(getDateField());
  56. l1.addComponent(getSelect());
  57. l1.addComponent(getDateField());
  58. final VerticalLayout p2Layout = createPanelLayout();
  59. final Panel p2 = getPanel(p2Layout);
  60. l1.addComponent(p2);
  61. p2Layout.addComponent(getSelect());
  62. p2Layout.addComponent(getDateField());
  63. p2Layout.addComponent(getSelect());
  64. p2Layout.addComponent(getDateField());
  65. }
  66. VerticalLayout getOrderedLayout() {
  67. final VerticalLayout l = new VerticalLayout();
  68. l.setCaption(getCaption("orderedlayout"));
  69. return l;
  70. }
  71. private VerticalLayout createPanelLayout() {
  72. VerticalLayout layout = new VerticalLayout();
  73. layout.setMargin(true);
  74. return layout;
  75. }
  76. Panel getPanel(ComponentContainer content) {
  77. final Panel panel = new Panel(content);
  78. panel.setCaption(getCaption("panel"));
  79. return panel;
  80. }
  81. Component getSelect() {
  82. return new Select(getCaption("select"), getSelectOptions());
  83. }
  84. Component getDateField() {
  85. return new DateField(getCaption("datefield"));
  86. }
  87. private Collection<String> getSelectOptions() {
  88. final Collection<String> opts = new Vector<String>(3);
  89. opts.add(getCaption("opt 1"));
  90. opts.add(getCaption("opt 2"));
  91. opts.add(getCaption("opt 3"));
  92. return opts;
  93. }
  94. private String getCaption(String string) {
  95. return string + (Math.random() * 99999.9);
  96. // This is Java 5 code:
  97. // return string + " " + UUID.randomUUID().toString().substring(0, 5);
  98. }
  99. }