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

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.TabSheet;
import com.vaadin.v7.data.Container;
import com.vaadin.v7.data.Item;
import com.vaadin.v7.data.util.IndexedContainer;
import com.vaadin.v7.ui.Table;

public class UpdateTableWhenUnfocused extends AbstractReindeerTestUI {

    @Override
    protected void setup(VaadinRequest request) {

        final Table table = createTable();

        TabSheet tabSheet = new TabSheet();
        tabSheet.addTab(table, "tab1");
        tabSheet.setHeight("5000px");
        tabSheet.setWidth("100%");
        addComponent(tabSheet);

        final Button button = new Button("Refresh table");
        button.addClickListener(event -> {
            button.focus();
            table.refreshRowCache();
        });
        addComponent(button);
    }

    private Table createTable() {
        Table table = new Table("Table");
        table.setImmediate(true);
        table.setMultiSelect(true);
        table.setSizeFull();
        table.setSelectable(true);

        Container ds = new IndexedContainer();
        ds.addContainerProperty("column", Integer.class, null);
        for (int i = 0; i < 500; i++) {
            Item item = ds.addItem(i);
            item.getItemProperty("column").setValue(i);
        }
        table.setContainerDataSource(ds);

        return table;
    }

    @Override
    protected String getTestDescription() {
        return "Clicking the button after selecting a row in the table should not cause the window to scroll.";
    }

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

}