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.

ColumnGeneratorAddingOrder.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.data.util.IndexedContainer;
  3. import com.vaadin.tests.components.TestBase;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Component;
  6. import com.vaadin.ui.Table;
  7. public class ColumnGeneratorAddingOrder extends TestBase {
  8. @Override
  9. protected Integer getTicketNumber() {
  10. return 2457;
  11. }
  12. @Override
  13. protected String getDescription() {
  14. return "Column generator must be allowed to be added both before and after data source setting and overriding should work. Bugs in 5.3-rc7 if added after DS.";
  15. }
  16. @Override
  17. protected void setup() {
  18. Table t = new Table();
  19. t.addGeneratedColumn("col2", new Table.ColumnGenerator() {
  20. @Override
  21. public Component generateCell(Table source, Object itemId,
  22. Object columnId) {
  23. return new Button("generated b c2");
  24. }
  25. });
  26. IndexedContainer c = new IndexedContainer();
  27. c.addContainerProperty("col1", String.class, "col1 ds data");
  28. c.addContainerProperty("col2", String.class, "col2 ds data");
  29. c.addContainerProperty("col3", String.class, "col3 ds data");
  30. for (int i = 0; i < 100; i++) {
  31. c.addItem();
  32. }
  33. t.setContainerDataSource(c);
  34. t.addGeneratedColumn("col1", new Table.ColumnGenerator() {
  35. @Override
  36. public Component generateCell(Table source, Object itemId,
  37. Object columnId) {
  38. return new Button("generated b c1");
  39. }
  40. });
  41. getLayout().addComponent(t);
  42. }
  43. }