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

import com.vaadin.LegacyApplication;
import com.vaadin.data.Item;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Table;

/**
 */
public class Ticket1632 extends LegacyApplication {

    private Table t;

    @Override
    public void init() {

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

        t = new Table();

        t.addContainerProperty("col1", String.class, "");
        t.addContainerProperty("col2", String.class, "");
        t.addContainerProperty("col3", String.class, "");

        t.addItem(new Object[] { "jep", "foo", "bar" }, "1");
        t.addItem(new Object[] { "jep", "foo", "bar" }, "2");
        t.addItem(new Object[] { "jep", "foo", "bar" }, "3");

        t.setVisibleColumns(new Object[] { "col1", "col2" });

        t.addItem(new Object[] { "foo", "bar" }, "4");

        // workaround to add item with all values
        Item i = t.addItem("5");
        i.getItemProperty("col1").setValue("jep");
        i.getItemProperty("col2").setValue("foo");
        i.getItemProperty("col3").setValue("bar");

        mainWin.addComponent(t);

        Button b = new Button("Toggle col3");
        b.addListener(new Button.ClickListener() {
            boolean visible = false;

            @Override
            public void buttonClick(ClickEvent event) {
                visible = !visible;
                if (visible) {
                    t.setVisibleColumns(new Object[] { "col1", "col2", "col3" });

                } else {
                    t.setVisibleColumns(new Object[] { "col1", "col2" });

                }

            }
        });

        mainWin.addComponent(b);

    }
}