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

import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Label;
import com.vaadin.v7.data.Item;
import com.vaadin.v7.data.util.IndexedContainer;
import com.vaadin.v7.ui.Table;

public class ColumnWidths extends TestBase {

    @Override
    protected String getDescription() {
        return "On window resize undefined "
                + "columns (by server or user (dragged)) columns "
                + "must consume the excess space. Space is divided "
                + "by default according to natural widths of columns."
                + "In example last column is fixed width. Other columns"
                + " should divide excess space relatively to 'natural' width unless user has resized column.";

    }

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

    private static final int ROWS = 100;

    @Override
    public void setup() {
        Table table1 = initTable();
        addComponent(new Label("Plain table"));
        addComponent(table1);

    }

    private Table initTable() {
        Table table = new Table();
        table.setWidth("100%");

        IndexedContainer idx = new IndexedContainer();
        idx.addContainerProperty("firstname", String.class, null);
        idx.addContainerProperty("lastname", String.class, null);
        Item i = idx.addItem(1);
        i.getItemProperty("firstname").setValue("John");
        i.getItemProperty("lastname").setValue("Johnson");
        i = idx.addItem(2);
        i.getItemProperty("firstname").setValue("Jane");
        i.getItemProperty("lastname").setValue("Janeine");

        for (int index = 3; index < ROWS; index++) {
            i = idx.addItem(index);
            i.getItemProperty("firstname").setValue("Jane");
            i.getItemProperty("lastname").setValue("Janeine");
        }

        idx.addContainerProperty("150pxfixedCol", String.class, "foobar");

        table.setContainerDataSource(idx);

        table.setColumnHeader("firstname", "FirstName");
        table.setColumnHeader("lastname", "LastName with long header");

        table.setColumnWidth("150pxfixedCol", 150);

        return table;
    }

}