123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- package com.vaadin.tests;
-
- import com.vaadin.server.LegacyApplication;
- import com.vaadin.ui.Accordion;
- import com.vaadin.ui.Button;
- import com.vaadin.ui.Component;
- import com.vaadin.ui.HorizontalLayout;
- import com.vaadin.ui.Label;
- import com.vaadin.ui.LegacyWindow;
- import com.vaadin.ui.Panel;
- import com.vaadin.ui.TabSheet;
- import com.vaadin.ui.VerticalLayout;
- import com.vaadin.ui.VerticalSplitPanel;
- import com.vaadin.ui.Window;
- import com.vaadin.v7.ui.OptionGroup;
- import com.vaadin.v7.ui.Table;
-
- public class ScrollbarStressTest extends LegacyApplication {
-
- final LegacyWindow main = new LegacyWindow("Scrollbar Stress Test");
-
- final Panel panel = new Panel("Panel");
- final VerticalSplitPanel splitPanel = new VerticalSplitPanel();
- final Accordion accordion = new Accordion();
- final TabSheet tabsheet = new TabSheet();
- final Window subwindow = new Window("Subwindow");
-
- final OptionGroup width = new OptionGroup("LO Width");
- final OptionGroup height = new OptionGroup("LO Height");
-
- private boolean getTable;
-
- @Override
- public void init() {
- setTheme("tests-tickets");
- setMainWindow(main);
- createControlWindow();
- subwindow.setWidth("400px");
- subwindow.setHeight("400px");
- }
-
- private void createControlWindow() {
- final OptionGroup context = new OptionGroup("Context");
- context.addItem("Main window");
- context.addItem("ExpandLayout");
- context.addItem("Subwindow");
- context.addItem("Panel");
- context.addItem("Split Panel");
- context.addItem("TabSheet");
- context.addItem("Accordion");
- context.setValue("Main window");
-
- final OptionGroup testComponent = new OptionGroup(
- "TestComponent 100%x100%");
- testComponent.addItem("Label");
- testComponent.addItem("Table");
- testComponent.setValue("Label");
-
- width.addItem("100%");
- width.addItem("50%");
- width.addItem("150%");
- width.addItem("100px");
- width.addItem("500px");
- width.setValue("100%");
-
- height.addItem("100%");
- height.addItem("50%");
- height.addItem("150%");
- height.addItem("100px");
- height.addItem("500px");
- height.setValue("100%");
-
- final Button set = new Button("Set", event -> {
- getTable = testComponent.getValue().equals("Table");
-
- if (context.getValue() == "Main window") {
- drawInMainWindow();
- } else if (context.getValue() == "Subwindow") {
- drawInSubwindow();
- } else if (context.getValue() == "Panel") {
- drawInPanel();
- } else if (context.getValue() == "Split Panel") {
- drawInSplitPanel();
- } else if (context.getValue() == "TabSheet") {
- drawInTabSheet(false);
- } else if (context.getValue() == "Accordion") {
- drawInTabSheet(true);
- } else if (context.getValue() == "ExpandLayout") {
- drawInExpandLayout();
- }
- });
-
- HorizontalLayout ol = new HorizontalLayout();
- ol.addComponent(context);
- ol.addComponent(testComponent);
- ol.addComponent(width);
- ol.addComponent(height);
- ol.addComponent(set);
- ol.setSpacing(true);
- ol.setMargin(true);
-
- Window controller = new Window("Controller");
- controller.setContent(ol);
- main.addWindow(controller);
- }
-
- protected void drawInExpandLayout() {
- main.removeAllComponents();
- main.getContent().setSizeFull();
-
- VerticalLayout ol = new VerticalLayout();
-
- VerticalLayout el = new VerticalLayout();
-
- el.removeAllComponents();
-
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
-
- el.addComponent(ol);
-
- main.addComponent(el);
- main.removeWindow(subwindow);
-
- }
-
- protected void drawInTabSheet(boolean verticalAkaAccordion) {
- main.removeAllComponents();
- main.getContent().setSizeFull();
-
- VerticalLayout ol = new VerticalLayout();
- ol.setCaption("Tab 1");
- VerticalLayout ol2 = new VerticalLayout();
- ol2.setCaption("Tab 2");
-
- TabSheet ts = (verticalAkaAccordion ? accordion : tabsheet);
- ts.setSizeFull();
-
- ts.removeAllComponents();
-
- ts.addComponent(ol);
- ts.addComponent(ol2);
-
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
- ol2.setWidth((String) width.getValue());
- ol2.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
-
- ol2.addComponent(getTestComponent());
-
- main.addComponent(ts);
- main.removeWindow(subwindow);
- }
-
- private void drawInSplitPanel() {
- main.removeAllComponents();
- main.getContent().setSizeFull();
-
- VerticalLayout ol = new VerticalLayout();
- VerticalLayout ol2 = new VerticalLayout();
-
- splitPanel.setFirstComponent(ol);
- splitPanel.setSecondComponent(ol2);
-
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
- ol2.setWidth((String) width.getValue());
- ol2.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
-
- ol2.addComponent(getTestComponent());
-
- main.addComponent(splitPanel);
- main.removeWindow(subwindow);
- }
-
- private void drawInPanel() {
- main.removeAllComponents();
- main.getContent().setSizeFull();
-
- VerticalLayout ol = new VerticalLayout();
- panel.setSizeFull();
- panel.setContent(ol);
-
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
- main.addComponent(panel);
- main.removeWindow(subwindow);
- }
-
- private void drawInSubwindow() {
- main.removeAllComponents();
- main.getContent().setSizeFull();
- VerticalLayout ol = new VerticalLayout();
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
- subwindow.setContent(ol);
- main.addWindow(subwindow);
- }
-
- private void drawInMainWindow() {
- main.removeAllComponents();
- VerticalLayout ol = new VerticalLayout();
- main.setContent(ol);
- ol.setWidth((String) width.getValue());
- ol.setHeight((String) height.getValue());
-
- ol.addComponent(getTestComponent());
- main.removeWindow(subwindow);
- }
-
- private Component getTestComponent() {
- if (getTable) {
- Table testTable = TestForTablesInitialColumnWidthLogicRendering
- .getTestTable(4, 50);
- testTable.setSizeFull();
- return testTable;
- } else {
- Label l = new Label("Label");
- l.setStyleName("no-padding");
- l.setSizeFull();
- return l;
- }
- }
- }
|