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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package com.vaadin.tests.components.grid;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import com.vaadin.server.VaadinRequest;
  5. import com.vaadin.tests.components.AbstractTestUI;
  6. import com.vaadin.ui.TabSheet;
  7. import com.vaadin.ui.VerticalLayout;
  8. import com.vaadin.v7.data.Property;
  9. import com.vaadin.v7.shared.ui.grid.HeightMode;
  10. import com.vaadin.v7.ui.Grid;
  11. import com.vaadin.v7.ui.NativeSelect;
  12. public class GridRowHeightChange extends AbstractTestUI {
  13. private final List<String> themes = Arrays.asList("valo", "reindeer",
  14. "runo", "chameleon", "base");
  15. @Override
  16. protected void setup(VaadinRequest request) {
  17. Grid grid = new Grid();
  18. // create column and fill rows
  19. grid.addColumn("Header");
  20. for (int i = 1; i <= 10; i++) {
  21. grid.addRow("row_" + i);
  22. }
  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. TabSheet tabSheet = new TabSheet();
  29. tabSheet.setWidthUndefined();
  30. tabSheet.addTab(tab, "Tab");
  31. tab.addComponent(grid);
  32. // Theme selector
  33. NativeSelect themeSelector = new NativeSelect("Theme selector", themes);
  34. themeSelector.select("reindeer");
  35. themeSelector.setNullSelectionAllowed(false);
  36. themeSelector
  37. .addValueChangeListener(new Property.ValueChangeListener() {
  38. @Override
  39. public void valueChange(Property.ValueChangeEvent event) {
  40. setTheme((String) event.getProperty().getValue());
  41. }
  42. });
  43. VerticalLayout layout = new VerticalLayout();
  44. layout.setSpacing(true);
  45. layout.setSizeUndefined();
  46. layout.addComponent(themeSelector);
  47. layout.addComponent(tabSheet);
  48. addComponent(layout);
  49. }
  50. @Override
  51. protected String getTestDescription() {
  52. return "Test if Grid's height is adjusted when HeightMode.ROW and row height is recalculated.<br>"
  53. + "When loading is complete, all 10 rows should be visible with all themes.";
  54. }
  55. @Override
  56. protected Integer getTicketNumber() {
  57. return 20104;
  58. }
  59. }