aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/abstractcomponent/TooltipTests.java
blob: 01c7ab83ae7762cbb30bc29247fa5ef488c361e1 (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
package com.vaadin.tests.components.abstractcomponent;

import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;

public class TooltipTests extends TestBase {

    private Panel panel;
    private VerticalLayout layout;
    private Label label;

    @Override
    protected String getDescription() {
        return "Generic tooltip handling tests";
    }

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

    @Override
    protected void setup() {
        HorizontalLayout topLayout = new HorizontalLayout();
        addComponent(topLayout);
        CheckBox panelCbox = new CheckBox("Panel");
        panelCbox.addListener(panelListener);
        topLayout.addComponent(panelCbox);
        CheckBox layoutCbox = new CheckBox("Layout");
        layoutCbox.addListener(layoutListener);
        topLayout.addComponent(layoutCbox);
        CheckBox labelCbox = new CheckBox("Label");
        topLayout.addComponent(labelCbox);
        labelCbox.addListener(labelListener);

        panel = new Panel();
        panel.setCaption("Panel caption");
        panel.setId("panel");
        addComponent(panel);

        layout = new VerticalLayout();
        layout.setId("layout");
        layout.setMargin(true);
        layout.setSpacing(true);
        panel.setContent(layout);

        label = new Label("Hover me!");
        label.setId("label");
        layout.addComponent(label);
    }

    private final Property.ValueChangeListener panelListener = new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) (event.getProperty().getValue());
            if (value) {
                panel.setDescription("I'm panel!");
            } else {
                panel.setDescription("");
            }
        }

    };

    private final Property.ValueChangeListener layoutListener = new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) (event.getProperty().getValue());
            if (value) {
                layout.setDescription("I'm layout!");
            } else {
                layout.setDescription("");
            }
        }

    };

    private final Property.ValueChangeListener labelListener = new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean value = (Boolean) (event.getProperty().getValue());
            if (value) {
                label.setDescription("I'm label!");
            } else {
                label.setDescription("");
            }
        }

    };

}