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.

GridRowHeightChange.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.vaadin.tests.components.grid;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import java.util.stream.IntStream;
  5. import com.vaadin.annotations.Widgetset;
  6. import com.vaadin.server.VaadinRequest;
  7. import com.vaadin.shared.ui.grid.HeightMode;
  8. import com.vaadin.tests.components.AbstractReindeerTestUI;
  9. import com.vaadin.ui.Grid;
  10. import com.vaadin.ui.NativeSelect;
  11. import com.vaadin.ui.TabSheet;
  12. import com.vaadin.ui.VerticalLayout;
  13. @Widgetset("com.vaadin.DefaultWidgetSet")
  14. public class GridRowHeightChange extends AbstractReindeerTestUI {
  15. private final List<String> themes = Arrays.asList("valo", "reindeer",
  16. "runo", "chameleon", "base");
  17. @Override
  18. protected void setup(VaadinRequest request) {
  19. Grid<Integer> grid = new Grid<>();
  20. // create column and fill rows
  21. grid.addColumn(item -> "row_" + item).setCaption("Header");
  22. grid.setItems(IntStream.range(1, 11).boxed());
  23. // set height mode and height
  24. grid.setHeightMode(HeightMode.ROW);
  25. grid.setHeightByRows(10);
  26. // create a tabsheet with one tab and place grid inside
  27. VerticalLayout tab = new VerticalLayout();
  28. tab.setSpacing(false);
  29. tab.setMargin(false);
  30. TabSheet tabSheet = new TabSheet();
  31. tabSheet.setWidthUndefined();
  32. tabSheet.addTab(tab, "Tab");
  33. tab.addComponent(grid);
  34. // Theme selector
  35. NativeSelect<String> themeSelector = new NativeSelect<>(
  36. "Theme selector", themes);
  37. themeSelector.setSelectedItem("reindeer");
  38. themeSelector.setEmptySelectionAllowed(false);
  39. themeSelector
  40. .addValueChangeListener(event -> setTheme(event.getValue()));
  41. VerticalLayout layout = new VerticalLayout();
  42. layout.setSpacing(true);
  43. layout.setSizeUndefined();
  44. layout.addComponent(themeSelector);
  45. layout.addComponent(tabSheet);
  46. addComponent(layout);
  47. }
  48. @Override
  49. protected String getTestDescription() {
  50. return "Test if Grid's height is adjusted when HeightMode.ROW and row height is recalculated.<br>"
  51. + "When loading is complete, all 10 rows should be visible with all themes.";
  52. }
  53. @Override
  54. protected Integer getTicketNumber() {
  55. return 20104;
  56. }
  57. }