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.

RefreshRenderedCellsOnlyIfAttached.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.ui.Label;
  6. import com.vaadin.ui.VerticalLayout;
  7. import com.vaadin.v7.ui.Table;
  8. /**
  9. * There shouldn't be any attempts to refresh table's cells if the table isn't
  10. * attached.
  11. *
  12. * @author Vaadin Ltd
  13. */
  14. public class RefreshRenderedCellsOnlyIfAttached extends AbstractReindeerTestUI {
  15. VerticalLayout layout;
  16. boolean check;
  17. /*
  18. * (non-Javadoc)
  19. *
  20. * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
  21. * VaadinRequest)
  22. */
  23. @Override
  24. protected void setup(VaadinRequest request) {
  25. getLayout().setMargin(true);
  26. check = false;
  27. layout = new VerticalLayout();
  28. final Label l1 = new Label("default");
  29. l1.setId("label");
  30. final Label l2 = new Label("should be: default");
  31. final Table t = new Table() {
  32. /*
  33. * (non-Javadoc)
  34. *
  35. * @see com.vaadin.ui.Table#refreshRenderedCells()
  36. */
  37. @Override
  38. protected void refreshRenderedCells() {
  39. boolean original = isRowCacheInvalidated();
  40. super.refreshRenderedCells();
  41. if (check) {
  42. l1.setValue("original: " + original + ", now: "
  43. + isRowCacheInvalidated());
  44. l2.setValue("should be: false & false");
  45. }
  46. }
  47. };
  48. t.addContainerProperty("text", String.class, "");
  49. t.addItem(new Object[] { "Foo" }, "foo");
  50. t.setId("table");
  51. layout.addComponent(t);
  52. addComponent(l1);
  53. addComponent(l2);
  54. addComponent(layout);
  55. Button b = new Button("Detach table", event -> {
  56. check = true;
  57. removeTableParent();
  58. // call refreshRenderedCells
  59. t.setColumnCollapsingAllowed(true);
  60. });
  61. b.setId("button");
  62. addComponent(b);
  63. }
  64. /**
  65. * Remove Table's parent component.
  66. *
  67. */
  68. protected void removeTableParent() {
  69. removeComponent(layout);
  70. }
  71. /*
  72. * (non-Javadoc)
  73. *
  74. * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
  75. */
  76. @Override
  77. protected String getTestDescription() {
  78. return "There shouldn't be any attempts to refresh table's cells if the table isn't attached.";
  79. }
  80. /*
  81. * (non-Javadoc)
  82. *
  83. * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
  84. */
  85. @Override
  86. protected Integer getTicketNumber() {
  87. return 9138;
  88. }
  89. }