Ticket #1973: Ticket1973.java

File Ticket1973.java, 1.5 kB (added by Risto Yrjana, 5 months ago)

Testcase for the ticket

Line 
1package com.itmill.toolkit.ui;
2
3import com.itmill.toolkit.Application;
4import com.itmill.toolkit.data.Item;
5import com.itmill.toolkit.data.util.IndexedContainer;
6
7public class ToolkitTest extends Application {
8
9    Window main = new Window();
10    Table table = new Table();
11
12    public void init() {
13        setMainWindow(main);
14
15        final IndexedContainer container1 = new IndexedContainer();
16        container1.addContainerProperty("layout", Component.class, null);
17
18        final IndexedContainer container2 = new IndexedContainer();
19        container2.addContainerProperty("layout", Component.class, null);
20
21        fill(container1, 100);
22        fill(container2, 100);
23
24        table.setContainerDataSource(container1);
25
26        Button refreshTable = new Button("Change table container");
27        refreshTable.addListener(new Button.ClickListener() {
28            public void buttonClick(Button.ClickEvent e) {
29                table.setContainerDataSource(container2);
30                table.setContainerDataSource(container1);
31            }
32        });
33
34        main.addComponent(table);
35        main.addComponent(refreshTable);
36    }
37
38    public void fill(IndexedContainer container, int size) {
39        for (int i = 0; i < size; i++) {
40            int randInt = (int) (Math.random() * 100);
41            Item item = container.addItem(new Integer(i));
42            OrderedLayout layout = new OrderedLayout();
43            layout.addComponent(new Button("Testi " + randInt));
44            item.getItemProperty("layout").setValue(layout);
45        }
46    }
47}