aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket2104.java
blob: 17b3e9732cd0b500562e1a1eae47914e4e0932d3 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.vaadin.tests.tickets;

import com.vaadin.LegacyApplication;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.server.ExternalResource;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Table;
import com.vaadin.ui.Tree;

public class Ticket2104 extends LegacyApplication {

    private static final Label info = new Label(
            "Click event should _always_ come trough. Switching features on/off should immediatly affect the tree (verify w/ debug window)",
            ContentMode.RAW);

    Tree tree = new Tree();
    Table table = new Table();

    @Override
    public void init() {
        LegacyWindow main = new LegacyWindow();
        setMainWindow(main);

        main.addComponent(info);

        HorizontalLayout ol = new HorizontalLayout();
        main.addComponent(ol);
        CheckBox cb = new CheckBox("immediate", new MethodProperty<Boolean>(
                tree, "immediate"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("selectable", new MethodProperty<Boolean>(tree,
                "selectable"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("nullsel", new MethodProperty<Boolean>(tree,
                "nullSelectionAllowed"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("multi", new MethodProperty<Boolean>(tree,
                "multiSelect"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("icon");
        cb.addListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (tree.getItemIconPropertyId() == null) {
                    tree.setItemIconPropertyId("icon");
                } else {
                    tree.setItemIconPropertyId(null);
                }

            }
        });
        cb.setImmediate(true);
        ol.addComponent(cb);

        main.addComponent(tree);
        tree.setImmediate(true);
        tree.setNullSelectionAllowed(false);
        tree.addItem("UI 1");
        tree.addItem("1. Child 1");
        tree.setParent("1. Child 1", "UI 1");
        tree.addItem("1. Child 2");
        tree.setParent("1. Child 2", "UI 1");
        tree.addItem("UI 2");
        tree.addItem("2. Child 1");
        tree.setParent("2. Child 1", "UI 2");
        tree.addItem("2. Child 2");
        tree.setParent("2. Child 2", "UI 2");
        tree.addContainerProperty("icon", ExternalResource.class,
                new ExternalResource(
                        "http://www.itmill.com/res/images/itmill_logo.gif"));

        tree.addListener(new ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                getMainWindow().addComponent(
                        new Label(event.toString() + " // " + event.getItemId()
                                + "//" + event.getSource()));

            }
        });

        ol = new HorizontalLayout();
        main.addComponent(ol);
        cb = new CheckBox("immediate", new MethodProperty<Boolean>(table,
                "immediate"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("selectable", new MethodProperty<Boolean>(table,
                "selectable"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("nullsel", new MethodProperty<Boolean>(table,
                "nullSelectionAllowed"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        cb = new CheckBox("multi", new MethodProperty<Boolean>(table,
                "multiSelect"));
        cb.setImmediate(true);
        ol.addComponent(cb);
        main.addComponent(table);
        table.setWidth("150px");
        table.setImmediate(true);
        table.setSelectable(true);
        table.setNullSelectionAllowed(false);
        for (int i = 0; i < 10; i++) {
            table.addItem("Item " + i);
        }
        table.addListener(new ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                getMainWindow().addComponent(
                        new Label(event.toString() + " // " + event.getItemId()
                                + "//" + event.getSource()));

            }
        });
        table.addContainerProperty("Column", String.class, "value");
    }

}