aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/elements/table/TableScroll.java
blob: ac5e0081232efcfbc9330c0fe7a2d38b15bbfe46 (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
package com.vaadin.tests.elements.table;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.v7.ui.Table;

public class TableScroll extends AbstractTestUI {

    Table table;
    public static final int COLUMNS = 5;
    public static final int ROWS = 100;

    @Override
    protected void setup(VaadinRequest request) {
        VerticalLayout layout = new VerticalLayout();
        layout.setWidth("200px");
        layout.setHeight("200px");

        Table table = new Table();
        table.setWidth("200px");
        table.setHeight("200px");
        initProperties(table);
        fillTable(table);
        layout.addComponent(table);
        addComponent(layout);
    }

    @Override
    protected String getTestDescription() {
        return "Test table element scroll and scrollLeft";
    }

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

    // set up the properties (columns)
    private void initProperties(Table table) {
        for (int i = 0; i < COLUMNS; i++) {
            table.addContainerProperty("property" + i, String.class,
                    "some value");
        }
    }

    // fill the table with some random data
    private void fillTable(Table table) {
        initProperties(table);
        for (int i = 0; i < ROWS; i++) {
            String[] line = new String[COLUMNS];
            for (int j = 0; j < COLUMNS; j++) {
                line[j] = "col=" + j + " row=" + i;
            }
            table.addItem(line, null);
        }
    }
}