aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket161.java
blob: 2e00bd3ff08871bfce5217d6fb480390c62d7d1a (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
package com.vaadin.tests.tickets;

import com.vaadin.LegacyApplication;
import com.vaadin.data.Container;
import com.vaadin.tests.TestForTablesInitialColumnWidthLogicRendering;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI.LegacyWindow;

/**
 */
public class Ticket161 extends LegacyApplication {

    private Table t;

    @Override
    public void init() {

        final LegacyWindow mainWin = new LegacyWindow("Test app to #1368");
        setMainWindow(mainWin);

        t = TestForTablesInitialColumnWidthLogicRendering.getTestTable(3, 100);
        t.setCurrentPageFirstItemIndex(50);

        mainWin.addComponent(t);

        Button b = new Button("Truncate to 20 rows");
        b.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {

                Container containerDataSource = t.getContainerDataSource();
                Object[] itemIds = containerDataSource.getItemIds().toArray();
                @SuppressWarnings("unused")
                int c = 0;
                for (int i = 0; i < itemIds.length; i++) {
                    if (i > 19) {
                        containerDataSource.removeItem(itemIds[i]);
                    }
                }
            }
        });

        mainWin.addComponent(b);

    }
}