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.

TooManySetColumnCollapsedCalls.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Label;
  4. import com.vaadin.v7.ui.Table;
  5. public class TooManySetColumnCollapsedCalls extends TestBase {
  6. private int counter = 0;
  7. private Label label;
  8. private Table table;
  9. @Override
  10. protected void setup() {
  11. label = new Label(String.valueOf(counter));
  12. label.setId("label");
  13. table = createTable();
  14. table.setId("table");
  15. addComponent(table);
  16. addComponent(label);
  17. getLayout().setSpacing(true);
  18. table.setColumnCollapsed("p2", true);
  19. }
  20. @Override
  21. protected String getDescription() {
  22. return "Table.setColumnCollapsed is called too many times in Table.changeVariables."
  23. + " Collapsing column 'P3' should only increase the counter by one.";
  24. }
  25. @Override
  26. protected Integer getTicketNumber() {
  27. return 5681;
  28. }
  29. private Table createTable() {
  30. Table table = new Table() {
  31. @Override
  32. public void setColumnCollapsed(Object propertyId, boolean collapsed)
  33. throws IllegalStateException {
  34. ++counter;
  35. label.setValue(String.valueOf(counter));
  36. super.setColumnCollapsed(propertyId, collapsed);
  37. }
  38. };
  39. table.setWidth("400px");
  40. table.setHeight("100px");
  41. table.setPageLength(100);
  42. table.setColumnCollapsingAllowed(true);
  43. table.setImmediate(true);
  44. table.addContainerProperty("p1", String.class, null);
  45. table.addContainerProperty("p2", String.class, null);
  46. table.addContainerProperty("p3", String.class, null);
  47. table.addContainerProperty("p4", String.class, null);
  48. for (int i = 0; i < 10; i++) {
  49. table.addItem(new Object[] { "a" + i, "b" + i, "c" + i, "X" + i },
  50. "" + i);
  51. }
  52. return table;
  53. }
  54. }