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

import com.vaadin.data.Item;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;

public class RowAdditionTest extends TestBase {

    @Override
    protected String getDescription() {
        return "Adding a row should refresh client area only if newly added row is in the rendered area.";
    }

    @Override
    protected Integer getTicketNumber() {
        return new Integer(2799);
    }

    @Override
    protected void setup() {
        final Table table = new Table();
        final IndexedContainer container = (IndexedContainer) table
                .getContainerDataSource();
        table.addContainerProperty("column1", String.class, "test");

        for (int i = 0; i < 100; ++i) {
            table.addItem();
        }

        HorizontalLayout hl = new HorizontalLayout();
        hl.addComponent(new Button("Add first", new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Item item = container.addItemAt(0, new Object());
                item.getItemProperty("column1").setValue("0");
            }
        }));
        hl.addComponent(new Button("Add at position 50",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        Item item = container.addItemAt(50, new Object());
                        item.getItemProperty("column1").setValue("50");
                    }
                }));
        hl.addComponent(new Button("Add at position 100",
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        Item item = container.addItemAt(100, new Object());
                        item.getItemProperty("column1").setValue("100");
                    }
                }));

        getLayout().addComponent(table);
        getLayout().addComponent(hl);
    }
}