選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

MemoryLeakTable.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.v7.data.util.IndexedContainer;
  6. import com.vaadin.v7.ui.Table;
  7. /**
  8. * Test UI Class for testing memory leak in table (#14159).
  9. *
  10. * @author Vaadin Ltd
  11. */
  12. public class MemoryLeakTable extends AbstractReindeerTestUI {
  13. Button btnAdd = new Button("Add rows");
  14. Button btnRemove = new Button("Remove rows");
  15. Button btnTenTimes = new Button("Do ten times");
  16. Table tbl = new Table();
  17. static final int COLS = 15;
  18. static final int ROWS = 2000;
  19. private void addRows() {
  20. IndexedContainer idx = new IndexedContainer();
  21. for (int i = 0; i < COLS; i++) {
  22. idx.addContainerProperty("name " + i, String.class, "value");
  23. }
  24. for (int i = 0; i < ROWS; i++) {
  25. idx.addItem("item" + i);
  26. }
  27. tbl.setContainerDataSource(idx);
  28. addComponent(tbl);
  29. }
  30. private void removeRows() {
  31. tbl.removeAllItems();
  32. removeComponent(tbl);
  33. }
  34. @Override
  35. protected void setup(VaadinRequest request) {
  36. btnAdd.addClickListener(event -> addRows());
  37. btnRemove.addClickListener(event -> removeRows());
  38. addComponent(btnAdd);
  39. addComponent(btnRemove);
  40. }
  41. @Override
  42. protected String getTestDescription() {
  43. return "Generates table for memory leaking test";
  44. }
  45. @Override
  46. protected Integer getTicketNumber() {
  47. return 14159;
  48. }
  49. }