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.

ScrollbarStressTest.java 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. package com.vaadin.tests;
  2. import com.vaadin.server.LegacyApplication;
  3. import com.vaadin.ui.Accordion;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Component;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.Label;
  8. import com.vaadin.ui.LegacyWindow;
  9. import com.vaadin.ui.Panel;
  10. import com.vaadin.ui.TabSheet;
  11. import com.vaadin.ui.VerticalLayout;
  12. import com.vaadin.ui.VerticalSplitPanel;
  13. import com.vaadin.ui.Window;
  14. import com.vaadin.v7.ui.OptionGroup;
  15. import com.vaadin.v7.ui.Table;
  16. public class ScrollbarStressTest extends LegacyApplication {
  17. final LegacyWindow main = new LegacyWindow("Scrollbar Stress Test");
  18. final Panel panel = new Panel("Panel");
  19. final VerticalSplitPanel splitPanel = new VerticalSplitPanel();
  20. final Accordion accordion = new Accordion();
  21. final TabSheet tabsheet = new TabSheet();
  22. final Window subwindow = new Window("Subwindow");
  23. final OptionGroup width = new OptionGroup("LO Width");
  24. final OptionGroup height = new OptionGroup("LO Height");
  25. private boolean getTable;
  26. @Override
  27. public void init() {
  28. setTheme("tests-tickets");
  29. setMainWindow(main);
  30. createControlWindow();
  31. subwindow.setWidth("400px");
  32. subwindow.setHeight("400px");
  33. }
  34. private void createControlWindow() {
  35. final OptionGroup context = new OptionGroup("Context");
  36. context.addItem("Main window");
  37. context.addItem("ExpandLayout");
  38. context.addItem("Subwindow");
  39. context.addItem("Panel");
  40. context.addItem("Split Panel");
  41. context.addItem("TabSheet");
  42. context.addItem("Accordion");
  43. context.setValue("Main window");
  44. final OptionGroup testComponent = new OptionGroup(
  45. "TestComponent 100%x100%");
  46. testComponent.addItem("Label");
  47. testComponent.addItem("Table");
  48. testComponent.setValue("Label");
  49. width.addItem("100%");
  50. width.addItem("50%");
  51. width.addItem("150%");
  52. width.addItem("100px");
  53. width.addItem("500px");
  54. width.setValue("100%");
  55. height.addItem("100%");
  56. height.addItem("50%");
  57. height.addItem("150%");
  58. height.addItem("100px");
  59. height.addItem("500px");
  60. height.setValue("100%");
  61. final Button set = new Button("Set", event -> {
  62. getTable = testComponent.getValue().equals("Table");
  63. if (context.getValue() == "Main window") {
  64. drawInMainWindow();
  65. } else if (context.getValue() == "Subwindow") {
  66. drawInSubwindow();
  67. } else if (context.getValue() == "Panel") {
  68. drawInPanel();
  69. } else if (context.getValue() == "Split Panel") {
  70. drawInSplitPanel();
  71. } else if (context.getValue() == "TabSheet") {
  72. drawInTabSheet(false);
  73. } else if (context.getValue() == "Accordion") {
  74. drawInTabSheet(true);
  75. } else if (context.getValue() == "ExpandLayout") {
  76. drawInExpandLayout();
  77. }
  78. });
  79. HorizontalLayout ol = new HorizontalLayout();
  80. ol.addComponent(context);
  81. ol.addComponent(testComponent);
  82. ol.addComponent(width);
  83. ol.addComponent(height);
  84. ol.addComponent(set);
  85. ol.setSpacing(true);
  86. ol.setMargin(true);
  87. Window controller = new Window("Controller");
  88. controller.setContent(ol);
  89. main.addWindow(controller);
  90. }
  91. protected void drawInExpandLayout() {
  92. main.removeAllComponents();
  93. main.getContent().setSizeFull();
  94. VerticalLayout ol = new VerticalLayout();
  95. VerticalLayout el = new VerticalLayout();
  96. el.removeAllComponents();
  97. ol.setWidth((String) width.getValue());
  98. ol.setHeight((String) height.getValue());
  99. ol.addComponent(getTestComponent());
  100. el.addComponent(ol);
  101. main.addComponent(el);
  102. main.removeWindow(subwindow);
  103. }
  104. protected void drawInTabSheet(boolean verticalAkaAccordion) {
  105. main.removeAllComponents();
  106. main.getContent().setSizeFull();
  107. VerticalLayout ol = new VerticalLayout();
  108. ol.setCaption("Tab 1");
  109. VerticalLayout ol2 = new VerticalLayout();
  110. ol2.setCaption("Tab 2");
  111. TabSheet ts = (verticalAkaAccordion ? accordion : tabsheet);
  112. ts.setSizeFull();
  113. ts.removeAllComponents();
  114. ts.addComponent(ol);
  115. ts.addComponent(ol2);
  116. ol.setWidth((String) width.getValue());
  117. ol.setHeight((String) height.getValue());
  118. ol2.setWidth((String) width.getValue());
  119. ol2.setHeight((String) height.getValue());
  120. ol.addComponent(getTestComponent());
  121. ol2.addComponent(getTestComponent());
  122. main.addComponent(ts);
  123. main.removeWindow(subwindow);
  124. }
  125. private void drawInSplitPanel() {
  126. main.removeAllComponents();
  127. main.getContent().setSizeFull();
  128. VerticalLayout ol = new VerticalLayout();
  129. VerticalLayout ol2 = new VerticalLayout();
  130. splitPanel.setFirstComponent(ol);
  131. splitPanel.setSecondComponent(ol2);
  132. ol.setWidth((String) width.getValue());
  133. ol.setHeight((String) height.getValue());
  134. ol2.setWidth((String) width.getValue());
  135. ol2.setHeight((String) height.getValue());
  136. ol.addComponent(getTestComponent());
  137. ol2.addComponent(getTestComponent());
  138. main.addComponent(splitPanel);
  139. main.removeWindow(subwindow);
  140. }
  141. private void drawInPanel() {
  142. main.removeAllComponents();
  143. main.getContent().setSizeFull();
  144. VerticalLayout ol = new VerticalLayout();
  145. panel.setSizeFull();
  146. panel.setContent(ol);
  147. ol.setWidth((String) width.getValue());
  148. ol.setHeight((String) height.getValue());
  149. ol.addComponent(getTestComponent());
  150. main.addComponent(panel);
  151. main.removeWindow(subwindow);
  152. }
  153. private void drawInSubwindow() {
  154. main.removeAllComponents();
  155. main.getContent().setSizeFull();
  156. VerticalLayout ol = new VerticalLayout();
  157. ol.setWidth((String) width.getValue());
  158. ol.setHeight((String) height.getValue());
  159. ol.addComponent(getTestComponent());
  160. subwindow.setContent(ol);
  161. main.addWindow(subwindow);
  162. }
  163. private void drawInMainWindow() {
  164. main.removeAllComponents();
  165. VerticalLayout ol = new VerticalLayout();
  166. main.setContent(ol);
  167. ol.setWidth((String) width.getValue());
  168. ol.setHeight((String) height.getValue());
  169. ol.addComponent(getTestComponent());
  170. main.removeWindow(subwindow);
  171. }
  172. private Component getTestComponent() {
  173. if (getTable) {
  174. Table testTable = TestForTablesInitialColumnWidthLogicRendering
  175. .getTestTable(4, 50);
  176. testTable.setSizeFull();
  177. return testTable;
  178. } else {
  179. Label l = new Label("Label");
  180. l.setStyleName("no-padding");
  181. l.setSizeFull();
  182. return l;
  183. }
  184. }
  185. }