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

import com.vaadin.tests.components.TestBase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.NativeButton;
import com.vaadin.v7.data.Item;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.Table.ColumnGenerator;

public class TableWithChildComponents extends TestBase
        implements ClickListener {

    private static final String COL2 = "Column 2 - generated";
    private static final String COL1 = "Column 1 - components";
    private Log log = new Log(10);

    @Override
    protected void setup() {
        Table table = new Table();
        table.setWidth("500px");
        table.setPageLength(10);
        table.addContainerProperty(COL1, Component.class, null);
        table.addContainerProperty(COL2, Component.class, null);

        table.addGeneratedColumn(COL2, new ColumnGenerator() {

            @Override
            public Object generateCell(Table source, Object itemId,
                    Object columnId) {
                return new Button("Item id: " + itemId + " column: " + columnId,
                        TableWithChildComponents.this);
            }
        });

        for (int i = 0; i < 100; i++) {
            Item item = table.addItem("Row " + i);
            item.getItemProperty(COL1)
                    .setValue(new NativeButton("Row " + i + " native", this));
        }

        addComponent(table);
        addComponent(log);

    }

    @Override
    protected String getDescription() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    protected Integer getTicketNumber() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void buttonClick(ClickEvent event) {
        log.log("Click on " + event.getButton().getCaption());

    }

}