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.

MissingScrollbar.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.vaadin.tests.components.table;
  2. import java.io.ObjectOutputStream;
  3. import java.io.Serializable;
  4. import com.vaadin.tests.components.TestBase;
  5. import com.vaadin.ui.Button;
  6. import com.vaadin.ui.HorizontalLayout;
  7. import com.vaadin.ui.VerticalLayout;
  8. import com.vaadin.v7.data.Item;
  9. import com.vaadin.v7.data.util.IndexedContainer;
  10. import com.vaadin.v7.ui.Table;
  11. public class MissingScrollbar extends TestBase {
  12. private Table table;
  13. private IndexedContainer container50;
  14. private IndexedContainer container2;
  15. @Override
  16. protected String getDescription() {
  17. return "Increasing the number of items to more than is displayed at once should show the scrollbar.";
  18. }
  19. @Override
  20. protected Integer getTicketNumber() {
  21. return 3076;
  22. }
  23. @Override
  24. protected void setup() {
  25. HorizontalLayout hl = new HorizontalLayout();
  26. container50 = createContainer(50);
  27. container2 = createContainer(2);
  28. table = new Table();
  29. table.setContainerDataSource(container2);
  30. table.setPageLength(10);
  31. VerticalLayout buttonLayout = new VerticalLayout();
  32. buttonLayout.setWidth(null);
  33. Button b = new Button("Set items to 2",
  34. event -> table.setContainerDataSource(container2));
  35. buttonLayout.addComponent(b);
  36. b = new Button("Set items to 50",
  37. event -> table.setContainerDataSource(container50));
  38. buttonLayout.addComponent(b);
  39. hl.addComponent(buttonLayout);
  40. hl.addComponent(table);
  41. addComponent(hl);
  42. }
  43. private static IndexedContainer createContainer(int items) {
  44. IndexedContainer ic = new IndexedContainer();
  45. ic.addContainerProperty("License number", Integer.class, "");
  46. ic.addContainerProperty("First", String.class, "");
  47. ic.addContainerProperty("Last", String.class, "");
  48. for (int i = 0; i < items; i++) {
  49. Item item = ic.addItem("" + i);
  50. item.getItemProperty("License number").setValue(i);
  51. item.getItemProperty("First").setValue("First " + i);
  52. item.getItemProperty("Last").setValue("Last " + i);
  53. }
  54. return ic;
  55. }
  56. private void writeObject(ObjectOutputStream out) throws Exception {
  57. out.defaultWriteObject();
  58. System.out.println("Serialize " + getClass().getName() + "("
  59. + (this instanceof Serializable) + ")");
  60. }
  61. }