diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-06-30 20:34:36 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-06-30 20:34:36 +0000 |
commit | 7a1cee077c05019da3a2fed4d398091624ded95f (patch) | |
tree | e4050e21d5b9e20279a4b52020775f95b27398d8 /tests | |
parent | 29f7c2dc647df242dfa100340e23f98637e612bf (diff) | |
download | vaadin-framework-7a1cee077c05019da3a2fed4d398091624ded95f.tar.gz vaadin-framework-7a1cee077c05019da3a2fed4d398091624ded95f.zip |
test case for #5279 and #4607
svn changeset:13981/svn branch:6.4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java b/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java new file mode 100644 index 0000000000..1384bc27cf --- /dev/null +++ b/tests/src/com/vaadin/tests/components/combobox/ComboBoxDataSourceChange.java @@ -0,0 +1,107 @@ +package com.vaadin.tests.components.combobox;
+
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class ComboBoxDataSourceChange extends TestBase {
+
+ private ComboBox cb2;
+
+ @Override
+ protected void setup() {
+ final IndexedContainer ds1 = new IndexedContainer();
+ // ds1.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ Item addItem = ds1.addItem("ds1-" + i);
+ }
+
+ final IndexedContainer ds2 = new IndexedContainer();
+ // ds2.addContainerProperty("caption", String.class, "");
+ for (int i = 0; i < 32; i++) {
+ Item addItem = ds2.addItem("ds2-" + i);
+ }
+
+ HorizontalLayout hl = new HorizontalLayout();
+ hl.setWidth("100%");
+
+ cb2 = new ComboBox();
+ cb2.setImmediate(true);
+ hl.addComponent(cb2);
+ HorizontalLayout state = new HorizontalLayout();
+ hl.addComponent(state);
+
+ final Label currentValue = new Label();
+ currentValue.setCaption("Current Value:");
+ currentValue.setSizeUndefined();
+ final Label currentDS = new Label();
+ currentDS.setCaption("Current DS:");
+ currentDS.setSizeUndefined();
+ state.addComponent(currentValue);
+ state.addComponent(currentDS);
+
+ Table t = new Table("ds1");
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ t.setContainerDataSource(ds1);
+ state.addComponent(t);
+
+ Button b = new Button("Use ds1");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cb2.setContainerDataSource(ds1);
+ currentDS.setValue("ds1");
+ }
+ });
+ state.addComponent(b);
+
+ t = new Table("ds2");
+ t.setContainerDataSource(ds2);
+ t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+ state.addComponent(t);
+
+ b = new Button("Use ds2");
+ b.addListener(new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ cb2.setContainerDataSource(ds2);
+ currentDS.setValue("ds2");
+ }
+ });
+ state.addComponent(b);
+
+ addComponent(hl);
+
+ cb2.addListener(new Property.ValueChangeListener() {
+ public void valueChange(ValueChangeEvent event) {
+ currentValue.setValue(event.getProperty().getValue());
+ }
+ });
+ }
+
+ private void populate(ComboBox cb) {
+ for (int i = 1; i < 10; i++) {
+ cb.addItem("Item " + i);
+ }
+ }
+
+ @Override
+ protected String getDescription() {
+ return "A test for combobox and its container changes.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ // TODO should be list of integers applies for #5279
+ return 4607;
+ }
+
+}
|