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.

GridWithFullWidthComponents.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.vaadin.tests.components.grid;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import com.vaadin.data.provider.DataProvider;
  5. import com.vaadin.server.VaadinRequest;
  6. import com.vaadin.tests.components.AbstractTestUI;
  7. import com.vaadin.ui.Button;
  8. import com.vaadin.ui.CssLayout;
  9. import com.vaadin.ui.Grid;
  10. import com.vaadin.ui.HorizontalLayout;
  11. import com.vaadin.ui.Label;
  12. public class GridWithFullWidthComponents extends AbstractTestUI {
  13. private String s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
  14. + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
  15. @Override
  16. protected void setup(VaadinRequest request) {
  17. getPage().getStyles()
  18. .add(".v-grid .v-label, .v-grid .v-csslayout:not(:empty) { "
  19. + "background-color: yellow; min-width: 300px; }");
  20. List<Integer> content = new ArrayList<>();
  21. for (int i = 0; i < 100; ++i) {
  22. content.add(i);
  23. }
  24. Grid<Integer> grid = new Grid<>(DataProvider.ofCollection(content));
  25. grid.setSizeFull();
  26. grid.setSelectionMode(Grid.SelectionMode.NONE);
  27. grid.setBodyRowHeight(70);
  28. grid.addComponentColumn(this::labelResponse).setCaption("Label");
  29. grid.addComponentColumn(this::hLayoutResponse)
  30. .setCaption("HorizontalLayout");
  31. grid.addComponentColumn(this::cssLayoutResponse)
  32. .setCaption("CssLayout");
  33. addComponent(grid);
  34. }
  35. private Label labelResponse(Integer item) {
  36. Label label = new Label(s);
  37. label.setWidthFull();
  38. return label;
  39. }
  40. private HorizontalLayout hLayoutResponse(Integer ite) {
  41. HorizontalLayout layout = new HorizontalLayout();
  42. layout.setWidthFull();
  43. for (int i = 0; i < 5; ++i) {
  44. layout.addComponent(new Button("Button" + i));
  45. }
  46. return layout;
  47. }
  48. private CssLayout cssLayoutResponse(Integer ite) {
  49. CssLayout layout = new CssLayout();
  50. layout.setWidthFull();
  51. for (int i = 0; i < 5; ++i) {
  52. layout.addComponent(new Button("Button" + i));
  53. }
  54. return layout;
  55. }
  56. @Override
  57. protected String getTestDescription() {
  58. return "All column contents are components with 100% width, "
  59. + "in first and third column the contents are styled "
  60. + "to have background color and minimum width of 300px. "
  61. + "Initial render and browser resize should behave accordingly.";
  62. }
  63. @Override
  64. protected Integer getTicketNumber() {
  65. return 11973;
  66. }
  67. }