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.

TableWithChildComponents.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.tests.util.Log;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.Button.ClickEvent;
  6. import com.vaadin.ui.Button.ClickListener;
  7. import com.vaadin.ui.Component;
  8. import com.vaadin.ui.NativeButton;
  9. import com.vaadin.v7.data.Item;
  10. import com.vaadin.v7.ui.Table;
  11. import com.vaadin.v7.ui.Table.ColumnGenerator;
  12. public class TableWithChildComponents extends TestBase
  13. implements ClickListener {
  14. private static final String COL2 = "Column 2 - generated";
  15. private static final String COL1 = "Column 1 - components";
  16. private Log log = new Log(10);
  17. @Override
  18. protected void setup() {
  19. Table table = new Table();
  20. table.setWidth("500px");
  21. table.setPageLength(10);
  22. table.addContainerProperty(COL1, Component.class, null);
  23. table.addContainerProperty(COL2, Component.class, null);
  24. table.addGeneratedColumn(COL2, new ColumnGenerator() {
  25. @Override
  26. public Object generateCell(Table source, Object itemId,
  27. Object columnId) {
  28. return new Button("Item id: " + itemId + " column: " + columnId,
  29. TableWithChildComponents.this);
  30. }
  31. });
  32. for (int i = 0; i < 100; i++) {
  33. Item item = table.addItem("Row " + i);
  34. item.getItemProperty(COL1)
  35. .setValue(new NativeButton("Row " + i + " native", this));
  36. }
  37. addComponent(table);
  38. addComponent(log);
  39. }
  40. @Override
  41. protected String getDescription() {
  42. // TODO Auto-generated method stub
  43. return null;
  44. }
  45. @Override
  46. protected Integer getTicketNumber() {
  47. // TODO Auto-generated method stub
  48. return null;
  49. }
  50. @Override
  51. public void buttonClick(ClickEvent event) {
  52. log.log("Click on " + event.getButton().getCaption());
  53. }
  54. }