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.

ExpandingContainerVisibleRowRaceCondition.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package com.vaadin.tests.components.table;
  2. import java.util.Map;
  3. import com.vaadin.annotations.Theme;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.ui.Label;
  6. import com.vaadin.ui.UI;
  7. import com.vaadin.ui.VerticalLayout;
  8. import com.vaadin.v7.ui.Table;
  9. @SuppressWarnings("serial")
  10. @Theme("reindeer")
  11. public class ExpandingContainerVisibleRowRaceCondition extends UI {
  12. static final String TABLE = "table";
  13. @Override
  14. public void init(VaadinRequest request) {
  15. final VerticalLayout rootLayout = new VerticalLayout();
  16. rootLayout.setSpacing(true);
  17. rootLayout.setSizeFull();
  18. rootLayout.setMargin(true);
  19. final Label sizeLabel = new Label();
  20. final ExpandingContainer container = new ExpandingContainer(sizeLabel);
  21. container.logDetails(false);
  22. Table table = new Table(null, container) {
  23. @Override
  24. public void changeVariables(Object source,
  25. Map<String, Object> variables) {
  26. if (variables.containsKey("firstvisible")) {
  27. int index = (Integer) variables.get("firstvisible");
  28. container.checkExpand(index);
  29. }
  30. if (variables.containsKey("reqfirstrow")
  31. || variables.containsKey("reqrows")) {
  32. try {
  33. int index = ((Integer) variables
  34. .get("lastToBeRendered")).intValue();
  35. container.checkExpand(index);
  36. } catch (Exception e) {
  37. // do nothing
  38. }
  39. }
  40. super.changeVariables(source, variables);
  41. }
  42. };
  43. table.setId(TABLE);
  44. table.setCacheRate(0);
  45. table.setSizeFull();
  46. table.setVisibleColumns((Object[]) ExpandingContainer.PROPERTY_IDS
  47. .toArray(new String[ExpandingContainer.PROPERTY_IDS.size()]));
  48. table.setCurrentPageFirstItemIndex(120);
  49. rootLayout.addComponent(table);
  50. rootLayout.setExpandRatio(table, 1);
  51. rootLayout.addComponent(sizeLabel);
  52. setContent(rootLayout);
  53. container.checkExpand(300);
  54. }
  55. }