aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithFullWidthComponents.java
blob: 233a2609840da8511d7a2bd2538edc1b685a97fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.vaadin.tests.components.grid;

import java.util.ArrayList;
import java.util.List;

import com.vaadin.data.provider.DataProvider;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Grid;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;

public class GridWithFullWidthComponents extends AbstractTestUI {
    private String s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
            + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

    @Override
    protected void setup(VaadinRequest request) {
        getPage().getStyles()
                .add(".v-grid .v-label, .v-grid .v-csslayout:not(:empty) { "
                        + "background-color: yellow; min-width: 300px; }");

        List<Integer> content = new ArrayList<>();
        for (int i = 0; i < 100; ++i) {
            content.add(i);
        }

        Grid<Integer> grid = new Grid<>(DataProvider.ofCollection(content));
        grid.setSizeFull();
        grid.setSelectionMode(Grid.SelectionMode.NONE);
        grid.setBodyRowHeight(70);
        grid.addComponentColumn(this::labelResponse).setCaption("Label");
        grid.addComponentColumn(this::hLayoutResponse)
                .setCaption("HorizontalLayout");
        grid.addComponentColumn(this::cssLayoutResponse)
                .setCaption("CssLayout");

        addComponent(grid);
    }

    private Label labelResponse(Integer item) {
        Label label = new Label(s);
        label.setWidthFull();
        return label;
    }

    private HorizontalLayout hLayoutResponse(Integer ite) {
        HorizontalLayout layout = new HorizontalLayout();
        layout.setWidthFull();
        for (int i = 0; i < 5; ++i) {
            layout.addComponent(new Button("Button" + i));
        }
        return layout;
    }

    private CssLayout cssLayoutResponse(Integer ite) {
        CssLayout layout = new CssLayout();
        layout.setWidthFull();
        for (int i = 0; i < 5; ++i) {
            layout.addComponent(new Button("Button" + i));
        }
        return layout;
    }

    @Override
    protected String getTestDescription() {
        return "All column contents are components with 100% width, "
                + "in first and third column the contents are styled "
                + "to have background color and minimum width of 300px. "
                + "Initial render and browser resize should behave accordingly.";
    }

    @Override
    protected Integer getTicketNumber() {
        return 11973;
    }
}