aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <anna@vaadin.com>2012-12-21 15:25:40 +0200
committerAnna Koskinen <anna@vaadin.com>2012-12-21 15:25:40 +0200
commit52ccef6debd4e26b8249d1a00569f8b8b7e611cb (patch)
tree1129b9a252a850e73f47d3ef3f86a56111e0b42b /uitest
parent3f4c7a849dc219b3d458248bb812fa827ba2c898 (diff)
downloadvaadin-framework-52ccef6debd4e26b8249d1a00569f8b8b7e611cb.tar.gz
vaadin-framework-52ccef6debd4e26b8249d1a00569f8b8b7e611cb.zip
Merge of (#9986) to Vaadin 7.
It should be possible to clear Table's value after container changes. Change-Id: Ibacdae2b303375fc8303abd63a5673542a80ad38
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java121
1 files changed, 121 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java b/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java
new file mode 100644
index 0000000000..93e7cafa99
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/ValueAfterClearingContainer.java
@@ -0,0 +1,121 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.Log;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Table;
+
+public class ValueAfterClearingContainer extends TestBase {
+
+ private static final String PROPERTY_ID = "property";
+
+ private Log log = new Log(5);
+ private final Table table = new Table();
+
+ @Override
+ protected void setup() {
+ table.setSelectable(true);
+ table.addContainerProperty(PROPERTY_ID, Integer.class, null);
+ table.setImmediate(true);
+ table.addValueChangeListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ log.log("Value changed to " + event.getProperty().getValue());
+ }
+ });
+ addComponent(log);
+
+ addComponent(table);
+ final CheckBox multiselect = new CheckBox("Multiselect");
+ multiselect.setImmediate(true);
+ multiselect.addValueChangeListener(new ValueChangeListener() {
+
+ public void valueChange(ValueChangeEvent event) {
+ Boolean value = multiselect.getValue();
+ table.setMultiSelect(value == null ? false : value);
+ }
+ });
+ addComponent(multiselect);
+ addComponent(new Button("Add table items", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ if (!table.getItemIds().isEmpty()) {
+ Notification.show("Only possible when the table is empty");
+ return;
+ } else {
+ for (int i = 0; i < 5; i++) {
+ table.addItem(new Object[] { Integer.valueOf(i) },
+ Integer.valueOf(i));
+ }
+ }
+ }
+ }));
+
+ addComponent(new Button("Show value", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ log.log("Table selection: " + table.getValue());
+ }
+ }));
+
+ addComponent(new Button("Remove items from table",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.removeAllItems();
+ }
+ }));
+
+ addComponent(new Button("Remove items from container",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.getContainerDataSource().removeAllItems();
+ }
+ }));
+ addComponent(new Button("Remove items from container and sanitize",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ table.getContainerDataSource().removeAllItems();
+ table.sanitizeSelection();
+ }
+ }));
+ addComponent(new Button("Remove selected item from table",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Object selection = table.getValue();
+ if (selection == null) {
+ Notification.show("There is no selection");
+ return;
+ } else {
+ table.removeItem(selection);
+ }
+ }
+ }));
+ addComponent(new Button("Remove selected item from container",
+ new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ Object selection = table.getValue();
+ if (selection == null) {
+ Notification.show("There is no selection");
+ return;
+ } else {
+ table.getContainerDataSource()
+ .removeItem(selection);
+ }
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Table value should be cleared when the selected item is removed from the container.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return Integer.valueOf(9986);
+ }
+
+}