aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/TooltipConfiguration.java
blob: ecb8ac75347624fecff3420b3b28571b44969344 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
 * Copyright 2000-2014 Vaadin Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.vaadin.ui;

import java.io.Serializable;

import com.vaadin.shared.ui.ui.UIState.TooltipConfigurationState;

/**
 * Provides method for configuring the tooltip.
 * 
 * @author Vaadin Ltd
 * @since 7.1
 */
public interface TooltipConfiguration extends Serializable {
    /**
     * Returns the time (in ms) the tooltip should be displayed after an event
     * that will cause it to be closed (e.g. mouse click outside the component,
     * key down).
     * 
     * @return The close timeout
     */
    public int getCloseTimeout();

    /**
     * Sets the time (in ms) the tooltip should be displayed after an event that
     * will cause it to be closed (e.g. mouse click outside the component, key
     * down).
     * 
     * @param closeTimeout
     *            The close timeout
     */
    public void setCloseTimeout(int closeTimeout);

    /**
     * Returns the time (in ms) during which {@link #getQuickOpenDelay()} should
     * be used instead of {@link #getOpenDelay()}. The quick open delay is used
     * when the tooltip has very recently been shown, is currently hidden but
     * about to be shown again.
     * 
     * @return The quick open timeout
     */
    public int getQuickOpenTimeout();

    /**
     * Sets the time (in ms) that determines when {@link #getQuickOpenDelay()}
     * should be used instead of {@link #getOpenDelay()}. The quick open delay
     * is used when the tooltip has very recently been shown, is currently
     * hidden but about to be shown again.
     * 
     * @param quickOpenTimeout
     *            The quick open timeout
     */
    public void setQuickOpenTimeout(int quickOpenTimeout);

    /**
     * Returns the time (in ms) that should elapse before a tooltip will be
     * shown, in the situation when a tooltip has very recently been shown
     * (within {@link #getQuickOpenDelay()} ms).
     * 
     * @return The quick open delay
     */
    public int getQuickOpenDelay();

    /**
     * Sets the time (in ms) that should elapse before a tooltip will be shown,
     * in the situation when a tooltip has very recently been shown (within
     * {@link #getQuickOpenDelay()} ms).
     * 
     * @param quickOpenDelay
     *            The quick open delay
     */
    public void setQuickOpenDelay(int quickOpenDelay);

    /**
     * Returns the time (in ms) that should elapse after an event triggering
     * tooltip showing has occurred (e.g. mouse over) before the tooltip is
     * shown. If a tooltip has recently been shown, then
     * {@link #getQuickOpenDelay()} is used instead of this.
     * 
     * @return The open delay
     */
    public int getOpenDelay();

    /**
     * Sets the time (in ms) that should elapse after an event triggering
     * tooltip showing has occurred (e.g. mouse over) before the tooltip is
     * shown. If a tooltip has recently been shown, then
     * {@link #getQuickOpenDelay()} is used instead of this.
     * 
     * @param openDelay
     *            The open delay
     */
    public void setOpenDelay(int openDelay);

    /**
     * Returns the maximum width of the tooltip popup.
     * 
     * @return The maximum width the tooltip popup
     */
    public int getMaxWidth();

    /**
     * Sets the maximum width of the tooltip popup.
     * 
     * @param maxWidth
     *            The maximum width the tooltip popup
     */
    public void setMaxWidth(int maxWidth);
}

class TooltipConfigurationImpl implements TooltipConfiguration {
    private UI ui;

    public TooltipConfigurationImpl(UI ui) {
        this.ui = ui;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.UI.Tooltip#getCloseTimeout()
     */
    @Override
    public int getCloseTimeout() {
        return getState(false).closeTimeout;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#setCloseTimeout(int)
     */
    @Override
    public void setCloseTimeout(int closeTimeout) {
        getState().closeTimeout = closeTimeout;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#getQuickOpenTimeout()
     */
    @Override
    public int getQuickOpenTimeout() {
        return getState(false).quickOpenTimeout;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#setQuickOpenTimeout(int)
     */
    @Override
    public void setQuickOpenTimeout(int quickOpenTimeout) {
        getState().quickOpenTimeout = quickOpenTimeout;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#getQuickOpenDelay()
     */
    @Override
    public int getQuickOpenDelay() {
        return getState(false).quickOpenDelay;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#setQuickOpenDelay(int)
     */
    @Override
    public void setQuickOpenDelay(int quickOpenDelay) {
        getState().quickOpenDelay = quickOpenDelay;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#getOpenDelay()
     */
    @Override
    public int getOpenDelay() {
        return getState(false).openDelay;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#setOpenDelay(int)
     */
    @Override
    public void setOpenDelay(int openDelay) {
        getState().openDelay = openDelay;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#getMaxWidth()
     */
    @Override
    public int getMaxWidth() {
        return getState(false).maxWidth;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.vaadin.ui.Tooltip#setMaxWidth(int)
     */
    @Override
    public void setMaxWidth(int maxWidth) {
        getState().maxWidth = maxWidth;
    }

    private TooltipConfigurationState getState() {
        return ui.getState().tooltipConfiguration;
    }

    private TooltipConfigurationState getState(boolean markAsDirty) {
        return ui.getState(markAsDirty).tooltipConfiguration;
    }

}