aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
blob: 4d201d2a1a7f63b8596ebc066ea621b9e47a38e0 (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
package com.vaadin.tests.components.ui;

import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.tests.util.LoremIpsum;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.TextField;

public class TooltipConfiguration extends AbstractTestUIWithLog {

    private TextField closeTimeout;
    private TextField quickOpenTimeout;
    private TextField maxWidth;
    private TextField openDelay;
    private TextField quickOpenDelay;

    @Override
    protected void setup(VaadinRequest request) {
        NativeButton componentWithShortTooltip = new NativeButton(
                "Short tooltip");
        componentWithShortTooltip.setDescription("This is a short tooltip");
        componentWithShortTooltip.setId("shortTooltip");

        NativeButton componentWithLongTooltip = new NativeButton("Long tooltip");
        componentWithLongTooltip.setId("longTooltip");
        componentWithLongTooltip.setDescription(LoremIpsum.get(5000));

        closeTimeout = createIntegerTextField("Close timeout",
                getState().tooltipConfiguration.closeTimeout);
        closeTimeout.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                getTooltipConfiguration().setCloseTimeout(
                        (Integer) closeTimeout.getConvertedValue());
            }
        });
        maxWidth = createIntegerTextField("Max width",
                getState().tooltipConfiguration.maxWidth);
        maxWidth.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                getTooltipConfiguration().setMaxWidth(
                        (Integer) maxWidth.getConvertedValue());
            }
        });
        openDelay = createIntegerTextField("Open delay",
                getState().tooltipConfiguration.openDelay);
        openDelay.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(ValueChangeEvent event) {
                getTooltipConfiguration().setOpenDelay(
                        (Integer) openDelay.getConvertedValue());
            }
        });

        quickOpenDelay = createIntegerTextField("Quick open delay",
                getState().tooltipConfiguration.quickOpenDelay);
        quickOpenDelay
                .addValueChangeListener(new Property.ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        getTooltipConfiguration().setQuickOpenDelay(
                                (Integer) quickOpenDelay.getConvertedValue());
                    }
                });

        quickOpenTimeout = createIntegerTextField("Quick open timeout",
                getState().tooltipConfiguration.quickOpenTimeout);
        quickOpenTimeout
                .addValueChangeListener(new Property.ValueChangeListener() {
                    @Override
                    public void valueChange(ValueChangeEvent event) {
                        getTooltipConfiguration().setQuickOpenTimeout(
                                (Integer) quickOpenTimeout.getConvertedValue());
                    }
                });

        getLayout().addComponents(closeTimeout, openDelay, quickOpenDelay,
                quickOpenTimeout, maxWidth);

        getLayout().addComponents(componentWithShortTooltip,
                componentWithLongTooltip);

    }

    private TextField createIntegerTextField(String caption, int initialValue) {
        TextField tf = new TextField(caption);
        tf.setId(caption);
        tf.setConverter(Integer.class);
        tf.setImmediate(true);
        tf.setConvertedValue(initialValue);
        return tf;
    }

    @Override
    protected String getTestDescription() {
        return "Tests that tooltip delays can be configured";
    }

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

}