aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/table/TableRepairsScrollPositionOnReAddingAllRows.java
blob: d9cbf007df1974cdd1435fbeeb0d96242ea3e945 (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
70
71
72
73
package com.vaadin.tests.components.table;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Table;

public class TableRepairsScrollPositionOnReAddingAllRows extends AbstractTestUI {

    private static final long serialVersionUID = 1L;

    @Override
    protected void setup(VaadinRequest request) {
        final BeanItemContainer<TableItem> cont = new BeanItemContainer<TableItem>(
                TableItem.class);
        final List<TableItem> itemList = new ArrayList<TableItem>();

        Button button1 = new Button("ReAdd rows");
        button1.setId("button1");
        button1.addClickListener(new ClickListener() {

            @Override
            public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                cont.removeAllItems();
                cont.addAll(itemList);
            }
        });

        for (int i = 0; i < 80; i++) {
            TableItem ti = new TableItem();
            ti.setName("Name_" + i);
            itemList.add(ti);
            cont.addBean(ti);
        }

        final Table table = new Table();
        table.setPageLength(-1);
        table.setContainerDataSource(cont);
        table.setSelectable(true);

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

    public class TableItem implements Serializable {
        private static final long serialVersionUID = -745849615488792221L;
        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

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

    @Override
    protected String getTestDescription() {
        return "The scroll position should not be changed if removing and re-adding all rows in Table.";
    }
}