diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-25 21:54:36 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-03 06:42:36 +0000 |
commit | 9586a30b64bfd1e8645574d9d7b6568d52dc9e25 (patch) | |
tree | a26ec723ebac47fd78b6180bc41434029a502aaf /server/src/com/vaadin | |
parent | 3cc90e37d8abfa53d127691ae0b7641298d64fa2 (diff) | |
download | vaadin-framework-9586a30b64bfd1e8645574d9d7b6568d52dc9e25.tar.gz vaadin-framework-9586a30b64bfd1e8645574d9d7b6568d52dc9e25.zip |
Made is possible to configure tooltip on the server (#8065)
Change-Id: I35af6df1dfa75ef1de1268eb630fc0f4b9306170
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/ui/Tooltip.java | 240 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/UI.java | 11 |
2 files changed, 251 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/Tooltip.java b/server/src/com/vaadin/ui/Tooltip.java new file mode 100644 index 0000000000..093bb33b51 --- /dev/null +++ b/server/src/com/vaadin/ui/Tooltip.java @@ -0,0 +1,240 @@ +/* + * Copyright 2000-2013 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.TooltipConfiguration; + +/** + * Provides method for configuring the tooltip. + * + * @author Vaadin Ltd + * @since 7.1 + */ +public interface Tooltip 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 TooltipImpl implements Tooltip { + private UI ui; + + public TooltipImpl(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 TooltipConfiguration getState() { + return ui.getState().tooltipConfiguration; + } + + private TooltipConfiguration getState(boolean markAsDirty) { + return ui.getState(markAsDirty).tooltipConfiguration; + } + +} diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 47cfd471cd..e9499da7f3 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -155,6 +155,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements private boolean closing = false; + private Tooltip tooltip = new TooltipImpl(this); + /** * Creates a new empty UI without a caption. The content of the UI must be * set by calling {@link #setContent(Component)} before using the UI. @@ -1095,4 +1097,13 @@ public abstract class UI extends AbstractSingleComponentContainer implements } } + + /** + * Retrieves the object used for configuring tooltips. + * + * @return The instance used for tooltip configuration + */ + public Tooltip getTooltip() { + return tooltip; + } } |