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.

AbsoluteLayoutRelativeSizeContent.java 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. package com.vaadin.tests.components.absolutelayout;
  2. import com.vaadin.annotations.Theme;
  3. import com.vaadin.server.VaadinRequest;
  4. import com.vaadin.shared.ui.MarginInfo;
  5. import com.vaadin.tests.components.AbstractReindeerTestUI;
  6. import com.vaadin.ui.AbsoluteLayout;
  7. import com.vaadin.ui.Component;
  8. import com.vaadin.ui.HorizontalLayout;
  9. import com.vaadin.v7.ui.Table;
  10. /**
  11. * Tests how AbsoluteLayout handles relative sized contents.
  12. *
  13. * @author Vaadin Ltd
  14. */
  15. @Theme("tests-tickets")
  16. public class AbsoluteLayoutRelativeSizeContent extends AbstractReindeerTestUI {
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. HorizontalLayout level1 = new HorizontalLayout(
  20. createComparisonTableOnFixed(), createTableOnFixed(),
  21. createHalfTableOnFixed(), createHalfTableAndFixedTableOnFixed(),
  22. createHalfTableOnFull());
  23. level1.setSpacing(true);
  24. level1.setWidth(100, Unit.PERCENTAGE);
  25. level1.setExpandRatio(
  26. level1.getComponent(level1.getComponentCount() - 1), 1);
  27. level1.setMargin(new MarginInfo(true, false, false, false));
  28. HorizontalLayout level2 = new HorizontalLayout(createFullOnFixed(),
  29. createFullOnFull());
  30. level2.setSpacing(true);
  31. level2.setWidth(100, Unit.PERCENTAGE);
  32. level2.setExpandRatio(
  33. level2.getComponent(level2.getComponentCount() - 1), 1);
  34. level2.setMargin(new MarginInfo(true, false, false, false));
  35. addComponent(level1);
  36. addComponent(level2);
  37. }
  38. /**
  39. * Creates an {@link AbsoluteLayout} of fixed size that contains a
  40. * full-sized {@link Table} that has been forced to full size with css.
  41. * Represents the workaround given for this ticket.
  42. *
  43. * @return the created layout
  44. */
  45. private Component createComparisonTableOnFixed() {
  46. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  47. absoluteLayout.setWidth(200, Unit.PIXELS);
  48. absoluteLayout.setHeight(200, Unit.PIXELS);
  49. absoluteLayout.setCaption("comparison table in full size");
  50. Table table = new Table();
  51. table.setSizeFull();
  52. table.setId("comparison-table");
  53. absoluteLayout.addComponent(table, "top:0;bottom:0;left:0;right:0;");
  54. return absoluteLayout;
  55. }
  56. /**
  57. * Creates an {@link AbsoluteLayout} of fixed size that contains a
  58. * full-sized {@link Table}.
  59. *
  60. * @return the created layout
  61. */
  62. private Component createTableOnFixed() {
  63. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  64. absoluteLayout.setWidth(200, Unit.PIXELS);
  65. absoluteLayout.setHeight(200, Unit.PIXELS);
  66. absoluteLayout.setCaption("full-sized table expected");
  67. Table table = new Table();
  68. table.setSizeFull();
  69. table.setId("full-table");
  70. absoluteLayout.addComponent(table);
  71. return absoluteLayout;
  72. }
  73. /**
  74. * Creates an {@link AbsoluteLayout} of fixed size that contains a
  75. * half-sized {@link Table}.
  76. *
  77. * @return the created layout
  78. */
  79. private Component createHalfTableOnFixed() {
  80. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  81. absoluteLayout.setWidth(200, Unit.PIXELS);
  82. absoluteLayout.setHeight(200, Unit.PIXELS);
  83. absoluteLayout.setCaption("half-sized table expected");
  84. Table table = new Table();
  85. table.setWidth(50, Unit.PERCENTAGE);
  86. table.setHeight(50, Unit.PERCENTAGE);
  87. table.setId("half-table");
  88. absoluteLayout.addComponent(table);
  89. return absoluteLayout;
  90. }
  91. /**
  92. * Creates an {@link AbsoluteLayout} of fixed size that contains a
  93. * half-sized {@link Table} and a fixed size {@link Table}.
  94. *
  95. * @return the created layout
  96. */
  97. private Component createHalfTableAndFixedTableOnFixed() {
  98. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  99. absoluteLayout.setWidth(200, Unit.PIXELS);
  100. absoluteLayout.setHeight(200, Unit.PIXELS);
  101. absoluteLayout.setCaption("half-sized and tiny expected");
  102. Table table = new Table();
  103. table.setWidth(50, Unit.PERCENTAGE);
  104. table.setHeight(50, Unit.PERCENTAGE);
  105. table.setId("halfwithtiny-table");
  106. absoluteLayout.addComponent(table);
  107. Table tableTiny = new Table();
  108. tableTiny.setWidth(50, Unit.PIXELS);
  109. tableTiny.setHeight(50, Unit.PIXELS);
  110. absoluteLayout.addComponent(tableTiny, "right:50;");
  111. return absoluteLayout;
  112. }
  113. /**
  114. * Creates an {@link AbsoluteLayout} of full size that contains a half-sized
  115. * {@link Table}.
  116. *
  117. * @return the created layout
  118. */
  119. private Component createHalfTableOnFull() {
  120. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  121. absoluteLayout.setSizeFull();
  122. absoluteLayout.setId("halfinfull-layout");
  123. absoluteLayout.setCaption("half-sized table expected");
  124. Table table = new Table();
  125. table.setWidth(50, Unit.PERCENTAGE);
  126. table.setHeight(50, Unit.PERCENTAGE);
  127. table.setId("halfinfull-table");
  128. absoluteLayout.addComponent(table);
  129. return absoluteLayout;
  130. }
  131. /**
  132. * Creates an {@link AbsoluteLayout} of fixed size that contains a
  133. * fixed-sized {@link AbsoluteLayout}.
  134. *
  135. * @return the created layout
  136. */
  137. private Component createFullOnFixed() {
  138. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  139. absoluteLayout.setWidth(200, Unit.PIXELS);
  140. absoluteLayout.setHeight(200, Unit.PIXELS);
  141. absoluteLayout.setId("fullonfixed-outer");
  142. absoluteLayout.addStyleName("green");
  143. absoluteLayout.setCaption("yellow area expected");
  144. AbsoluteLayout absoluteLayout2 = new AbsoluteLayout();
  145. absoluteLayout2.setSizeFull();
  146. absoluteLayout2.setId("fullonfixed-inner");
  147. absoluteLayout2.addStyleName("yellow");
  148. absoluteLayout.addComponent(absoluteLayout2, "top:50px;left:100px;");
  149. return absoluteLayout;
  150. }
  151. /**
  152. * Creates an {@link AbsoluteLayout} of full size that contains another
  153. * full-sized {@link AbsoluteLayout}.
  154. *
  155. * @return the created layout
  156. */
  157. private AbsoluteLayout createFullOnFull() {
  158. AbsoluteLayout absoluteLayout = new AbsoluteLayout();
  159. absoluteLayout.setSizeFull();
  160. absoluteLayout.setId("fullonfull-outer");
  161. absoluteLayout.addStyleName("cyan");
  162. absoluteLayout.setCaption("area with red border expected");
  163. AbsoluteLayout absoluteLayout2 = new AbsoluteLayout();
  164. absoluteLayout2.setSizeFull();
  165. absoluteLayout2.setId("fullonfull-inner");
  166. absoluteLayout2.addStyleName("redborder");
  167. absoluteLayout.addComponent(absoluteLayout2, "top:50px;left:100px;");
  168. return absoluteLayout;
  169. }
  170. @Override
  171. protected String getTestDescription() {
  172. return "Full size component in AbsoluteLayout shouldn't get undefined size";
  173. }
  174. @Override
  175. protected Integer getTicketNumber() {
  176. return 13131;
  177. }
  178. }