--- /dev/null
+package com.vaadin.tests.components.table;\r
+\r
+import com.vaadin.data.util.IndexedContainer;\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Button;\r
+import com.vaadin.ui.Table;\r
+\r
+@SuppressWarnings("serial")\r
+public class ModifyContainerProperty extends TestBase {\r
+\r
+ private Table table = new Table();\r
+ private IndexedContainer ic = new IndexedContainer();\r
+\r
+ @Override\r
+ protected void setup() {\r
+ addComponent(table);\r
+\r
+ ic.addContainerProperty("one", String.class, "one");\r
+ ic.addContainerProperty("two", String.class, "two");\r
+\r
+ ic.addItem("foo");\r
+\r
+ ic.getContainerProperty("foo", "one").setValue("bar");\r
+ ic.getContainerProperty("foo", "two").setValue("baz");\r
+\r
+ table.setContainerDataSource(ic);\r
+ addComponent(new Button("Remove container property",\r
+ new Button.ClickListener() {\r
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {\r
+ ic.removeContainerProperty("one");\r
+ }\r
+ }));\r
+ addComponent(new Button("Add container property",\r
+ new Button.ClickListener() {\r
+ public void buttonClick(com.vaadin.ui.Button.ClickEvent arg0) {\r
+ ic.addContainerProperty("three", String.class, "three");\r
+ Object[] current = table.getVisibleColumns();\r
+ Object[] vis = new Object[current.length + 1];\r
+ for (int i = 0; i < current.length; i++) {\r
+ vis[i] = current[i];\r
+ }\r
+ vis[current.length] = "three";\r
+ table.setVisibleColumns(vis);\r
+ }\r
+ }));\r
+ }\r
+\r
+ @Override\r
+ protected String getDescription() {\r
+ return "Clicking on \"Add container property\" adds a property to the container and sets it visible. The table should then show a \"three\" column in addition to the others. Clicking on \"Remove container property\" should remove column \"two\" from the table.";\r
+ }\r
+\r
+ @Override\r
+ protected Integer getTicketNumber() {\r
+ return 3165;\r
+ }\r
+}\r