summaryrefslogtreecommitdiffstats
path: root/tests/testbench
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-04-10 12:56:39 +0300
committerLeif Åstrand <leif@vaadin.com>2012-04-10 12:56:39 +0300
commita8941d2e09c6b0f5e904b60378f9b469d2d9fd9e (patch)
tree84f3021591df5fec93f11bcf1ed140294555f81c /tests/testbench
parent105d563f6622256d00d580dc52cc302e7c810e56 (diff)
parent18dd267cfe3757adee20aaae556b64746c677683 (diff)
downloadvaadin-framework-a8941d2e09c6b0f5e904b60378f9b469d2d9fd9e.tar.gz
vaadin-framework-a8941d2e09c6b0f5e904b60378f9b469d2d9fd9e.zip
Merge remote branch 'origin/6.8'
Conflicts: src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java src/com/vaadin/terminal/gwt/client/ui/VTree.java src/com/vaadin/terminal/gwt/client/ui/VWindow.java src/com/vaadin/ui/AbstractField.java
Diffstat (limited to 'tests/testbench')
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html100
-rw-r--r--tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java11
-rw-r--r--tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html114
-rw-r--r--tests/testbench/com/vaadin/tests/layouts/LayoutPerformanceTests.java285
4 files changed, 484 insertions, 26 deletions
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html
index d7876ba646..129061e69c 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.html
@@ -27,9 +27,9 @@
<td>right</td>
</tr>
<tr>
- <td>assertTextPresent</td>
+ <td>assertText</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[1]/ChildComponentContainer[0]/VLabel[0]</td>
<td>Tab 2</td>
- <td></td>
</tr>
<tr>
<td>screenCapture</td>
@@ -47,9 +47,9 @@
<td>right</td>
</tr>
<tr>
- <td>assertTextPresent</td>
+ <td>assertText</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[3]/ChildComponentContainer[0]/VLabel[0]</td>
<td>Tab 5</td>
- <td></td>
</tr>
<tr>
<td>screenCapture</td>
@@ -57,14 +57,44 @@
<td>skip-disabled-to-tab5</td>
</tr>
<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
<td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
<td>right</td>
</tr>
<tr>
- <td>assertTextPresent</td>
- <td>Tab 1</td>
- <td>wraparound-to-tab1</td>
+ <td>assertText</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[4]/ChildComponentContainer[0]/VLabel[0]</td>
+ <td>Tab 6</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
</tr>
<tr>
<td>click</td>
@@ -73,23 +103,63 @@
</tr>
<tr>
<td>mouseClick</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>14,9</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>18,10</td>
</tr>
<tr>
<td>pressSpecialKey</td>
- <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
- <td>left</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[8]</td>
+ <td>right</td>
</tr>
<tr>
- <td>assertTextPresent</td>
- <td>Tab 6</td>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[9]</td>
+ <td>right</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[10]</td>
+ <td>right</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[8]/ChildComponentContainer[0]/VLabel[0]</td>
+ <td>Tab 12</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
<td></td>
+ <td>scrolled-right-to-tab-12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>11,2</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[4]</td>
+ <td>left</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]</td>
+ <td>left</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]</td>
+ <td>left</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runTabKeyboardNavigation::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td>
+ <td>Tab 1</td>
</tr>
<tr>
<td>screenCapture</td>
<td></td>
- <td>moved-left-to-tab6</td>
+ <td>scrolled-left-to-tab-1</td>
</tr>
</tbody></table>
diff --git a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
index cc82704d16..a3886853ff 100644
--- a/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
+++ b/tests/testbench/com/vaadin/tests/components/tabsheet/TabKeyboardNavigation.java
@@ -15,8 +15,6 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Layout;
import com.vaadin.ui.TabSheet;
-import com.vaadin.ui.TabSheet.SelectedTabChangeEvent;
-import com.vaadin.ui.TabSheet.SelectedTabChangeListener;
import com.vaadin.ui.TabSheet.Tab;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
@@ -32,7 +30,6 @@ public class TabKeyboardNavigation extends TestBase {
protected void setup() {
ts.setWidth("500px");
ts.setHeight("500px");
- // ts.setTabIndex(0);
ts.addListener(new FocusListener() {
public void focus(FocusEvent event) {
@@ -46,14 +43,6 @@ public class TabKeyboardNavigation extends TestBase {
}
});
- ts.addListener(new SelectedTabChangeListener() {
-
- public void selectedTabChange(SelectedTabChangeEvent event) {
- // ts.setSelectedTab(tabs.get(Math.max(0,
- // tabs.indexOf(ts.getSelectedTab()) - 1)));
- }
- });
-
for (int i = 0; i < 5; ++i) {
addTab();
}
diff --git a/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html b/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html
new file mode 100644
index 0000000000..75ad4b5ff5
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/tree/TreeShiftMultiSelectNodes.html
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>Trees</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Trees</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.tree.Trees/?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/expand</td>
+ <td>9,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/expand</td>
+ <td>9,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[0]</td>
+ <td>23,8</td>
+</tr>
+<tr>
+ <td>shiftKeyDown</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/n[1]</td>
+ <td>28,8</td>
+</tr>
+<tr>
+ <td>shiftKeyUp</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>all-items-inside-selection-are-selected</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>Trees</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Trees</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.tree.Trees/?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/expand</td>
+ <td>9,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/expand</td>
+ <td>9,10</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[0]</td>
+ <td>23,8</td>
+</tr>
+<tr>
+ <td>shiftKeyDown</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstreeTrees::PID_StestComponent#n[1]/n[2]/n[1]</td>
+ <td>28,8</td>
+</tr>
+<tr>
+ <td>shiftKeyUp</td>
+ <td></td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>all-items-inside-selection-are-selected</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/layouts/LayoutPerformanceTests.java b/tests/testbench/com/vaadin/tests/layouts/LayoutPerformanceTests.java
new file mode 100644
index 0000000000..23cf868085
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/layouts/LayoutPerformanceTests.java
@@ -0,0 +1,285 @@
+package com.vaadin.tests.layouts;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Iterator;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractOrderedLayout;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.ComponentContainer;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class LayoutPerformanceTests extends TestBase {
+ private static final String[] widths = { null, "100%", "200px" };
+
+ private enum ContainerType {
+ SIMPLE_WRAPS {
+ @Override
+ public ComponentContainer buildLayout(int depth, int leafs,
+ SampleType leafType, boolean fullHeight) {
+ if (depth == 0) {
+ return buildInnerLayout(leafs, leafType, fullHeight);
+ }
+
+ AbstractOrderedLayout layout = createOrderedLayout(depth,
+ fullHeight);
+ layout.addComponent(buildLayout(depth - 1, leafs, leafType,
+ fullHeight));
+ return layout;
+ }
+ },
+ BORDER_LAYOUT {
+ @Override
+ public ComponentContainer buildLayout(int depth, int leafs,
+ SampleType leafType, boolean fullHeight) {
+ if (depth == 0) {
+ return buildInnerLayout(leafs, leafType, fullHeight);
+ }
+
+ AbstractOrderedLayout layout = createOrderedLayout(depth,
+ fullHeight);
+ Component content = leafType.createContent();
+ content.setSizeUndefined();
+ layout.addComponent(content);
+ layout.addComponent(buildLayout(depth - 1, leafs, leafType,
+ fullHeight));
+ layout.setExpandRatio(layout.getComponent(1), 1);
+ return layout;
+ }
+ },
+ FRACTAL {
+ @Override
+ public ComponentContainer buildLayout(int depth, int leafs,
+ SampleType leafType, boolean fullHeight) {
+ if (depth == 0) {
+ return buildInnerLayout(leafs, leafType, fullHeight);
+ }
+
+ AbstractOrderedLayout layout = createOrderedLayout(depth,
+ fullHeight);
+ layout.addComponent(buildLayout(depth - 1, leafs, leafType,
+ fullHeight));
+ layout.addComponent(buildLayout(depth - 1, leafs, leafType,
+ fullHeight));
+ layout.setExpandRatio(layout.getComponent(0), 1);
+ layout.setExpandRatio(layout.getComponent(1), 2);
+ return layout;
+ }
+ };
+ public abstract ComponentContainer buildLayout(int depth, int leafs,
+ SampleType leafType, boolean fullHeight);
+
+ protected AbstractOrderedLayout createOrderedLayout(int depth,
+ boolean fullHeight) {
+ AbstractOrderedLayout layout = (depth % 2) == 0 ? new VerticalLayout()
+ : new HorizontalLayout();
+ layout.setWidth("100%");
+ if (fullHeight) {
+ layout.setHeight("100%");
+ } else {
+ layout.setHeight(null);
+ }
+
+ return layout;
+ }
+
+ public ComponentContainer buildInnerLayout(int leafs,
+ SampleType leafType, boolean fullHeight) {
+ VerticalLayout layout = new VerticalLayout();
+ if (fullHeight) {
+ layout.setHeight("100%");
+ layout.setWidth("100%");
+ }
+ for (int i = 0; i < leafs; i++) {
+ Component leaf = leafType.createContent();
+ if (leaf.getWidth() <= 0) {
+ leaf.setWidth(widths[i % 3]);
+ }
+ layout.addComponent(leaf);
+ }
+ return layout;
+ }
+ }
+
+ private enum SampleType {
+ SHORT_LABEL {
+ @Override
+ public Component createContent() {
+ return new Label("Short label");
+ }
+ },
+ LONG_LABEL {
+ @Override
+ public Component createContent() {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < 100; i++) {
+ builder.append("A rather long text. ");
+ }
+ return new Label(builder.toString());
+ }
+ },
+ BUTTON {
+ @Override
+ public Component createContent() {
+ return new Button("Text");
+ }
+ },
+ TEXT_FIELD {
+ @Override
+ public Component createContent() {
+ return new TextField("Field label");
+ }
+ },
+ HORIZONTAL_LAYOUT {
+ @Override
+ public Component createContent() {
+ HorizontalLayout layout = new HorizontalLayout();
+ layout.addComponent(new Label("Left"));
+ layout.addComponent(new Label("Right"));
+ layout.setComponentAlignment(layout.getComponent(1),
+ Alignment.BOTTOM_RIGHT);
+
+ return layout;
+ }
+ },
+ WRAPPED_PANEL {
+ @Override
+ public Component createContent() {
+ HorizontalLayout horizontal = new HorizontalLayout();
+ horizontal.setWidth("100%");
+ horizontal.setHeight(null);
+ horizontal.setMargin(true);
+
+ VerticalLayout left = new VerticalLayout();
+ left.setWidth("100%");
+ left.addComponent(new Label("Text 1"));
+ left.addComponent(new Label("Text 2"));
+ left.addComponent(new Label("Text 3"));
+ horizontal.addComponent(left);
+
+ VerticalLayout right = new VerticalLayout();
+ right.setWidth("100%");
+ right.addComponent(new Label("Text 1"));
+ right.addComponent(new Label("Text 2"));
+ right.addComponent(new Label("Text 3"));
+ horizontal.addComponent(right);
+
+ Panel panel = new Panel(horizontal);
+ panel.setCaption("Panel caption");
+ panel.setWidth("100%");
+ panel.setHeight(null);
+
+ return panel;
+ }
+ };
+ public abstract Component createContent();
+ }
+
+ private Component testLayout = new Label("");
+
+ private final CheckBox wrapInPanel = new CheckBox("Wrap in Panel");
+ private final NativeSelect containerSelector = new NativeSelect(
+ "Wrapping structure", EnumSet.allOf(ContainerType.class));
+ @SuppressWarnings("boxing")
+ private final NativeSelect levels = new NativeSelect("Wrapping depth",
+ Arrays.asList(0, 1, 2, 3, 4, 5, 10, 15, 20, 25));
+ private final NativeSelect leafSelector = new NativeSelect("Leaf type",
+ EnumSet.allOf(SampleType.class));
+ @SuppressWarnings("boxing")
+ private final NativeSelect childAmount = new NativeSelect("Leaf count",
+ Arrays.asList(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,
+ 4096, 8192, 16384));
+
+ @Override
+ protected void setup() {
+ HorizontalLayout controls = new HorizontalLayout();
+ controls.setSpacing(true);
+
+ controls.addComponent(wrapInPanel);
+ controls.addComponent(containerSelector);
+ controls.addComponent(levels);
+ controls.addComponent(leafSelector);
+ controls.addComponent(childAmount);
+
+ controls.addComponent(new Button("Clear", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ setTestLayout(new Label(""));
+ }
+ }));
+
+ controls.addComponent(new Button("Apply", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ SampleType leafType = (SampleType) leafSelector.getValue();
+ if (leafType == null) {
+ return;
+ }
+
+ ContainerType containerType = (ContainerType) containerSelector
+ .getValue();
+ if (containerType == null) {
+ return;
+ }
+
+ boolean wrapped = wrapInPanel.booleanValue();
+ ComponentContainer container = containerType.buildLayout(
+ ((Number) levels.getValue()).intValue(),
+ ((Number) childAmount.getValue()).intValue(), leafType,
+ !wrapped);
+ if (wrapped) {
+ Panel panel = new Panel(container);
+ panel.setSizeFull();
+ container = panel;
+ }
+ setTestLayout(container);
+ }
+ }));
+
+ for (Iterator<Component> i = controls.getComponentIterator(); i
+ .hasNext();) {
+ Component component = i.next();
+ if (component instanceof NativeSelect) {
+ NativeSelect nativeSelect = (NativeSelect) component;
+ nativeSelect.setNullSelectionAllowed(false);
+ nativeSelect.setValue(new ArrayList<Object>(nativeSelect
+ .getItemIds()).get(0));
+ }
+ controls.setComponentAlignment(component, Alignment.BOTTOM_LEFT);
+ }
+
+ VerticalLayout layout = getLayout();
+ layout.addComponent(controls);
+ layout.addComponent(testLayout);
+ layout.setExpandRatio(testLayout, 1);
+ layout.setSizeFull();
+ }
+
+ public void setTestLayout(Component testLayout) {
+ getLayout().replaceComponent(this.testLayout, testLayout);
+ getLayout().setExpandRatio(testLayout, 1);
+ this.testLayout = testLayout;
+ }
+
+ @Override
+ protected String getDescription() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}