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.2KB

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