You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModifyContainerProperty.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.v7.data.util.IndexedContainer;
  5. import com.vaadin.v7.ui.Table;
  6. @SuppressWarnings("serial")
  7. public class ModifyContainerProperty extends TestBase {
  8. private Table table = new Table();
  9. private IndexedContainer ic = new IndexedContainer();
  10. @Override
  11. protected void setup() {
  12. addComponent(table);
  13. ic.addContainerProperty("one", String.class, "one");
  14. ic.addContainerProperty("two", String.class, "two");
  15. ic.addItem("foo");
  16. ic.getContainerProperty("foo", "one").setValue("bar");
  17. ic.getContainerProperty("foo", "two").setValue("baz");
  18. table.setContainerDataSource(ic);
  19. addComponent(new Button("Remove container property",
  20. event -> ic.removeContainerProperty("one")));
  21. addComponent(new Button("Add container property", event -> {
  22. boolean added = ic.addContainerProperty("three", String.class,
  23. "three");
  24. if (added) {
  25. Object[] current = table.getVisibleColumns();
  26. Object[] vis = new Object[current.length + 1];
  27. for (int i = 0; i < current.length; i++) {
  28. vis[i] = current[i];
  29. }
  30. vis[current.length] = "three";
  31. table.setVisibleColumns(vis);
  32. }
  33. }));
  34. }
  35. @Override
  36. protected String getDescription() {
  37. 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.";
  38. }
  39. @Override
  40. protected Integer getTicketNumber() {
  41. return 3165;
  42. }
  43. }