summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2013-03-25 21:54:36 +0200
committerVaadin Code Review <review@vaadin.com>2013-04-03 06:42:36 +0000
commit9586a30b64bfd1e8645574d9d7b6568d52dc9e25 (patch)
treea26ec723ebac47fd78b6180bc41434029a502aaf
parent3cc90e37d8abfa53d127691ae0b7641298d64fa2 (diff)
downloadvaadin-framework-9586a30b64bfd1e8645574d9d7b6568d52dc9e25.tar.gz
vaadin-framework-9586a30b64bfd1e8645574d9d7b6568d52dc9e25.zip
Made is possible to configure tooltip on the server (#8065)
Change-Id: I35af6df1dfa75ef1de1268eb630fc0f4b9306170
-rw-r--r--client/src/com/vaadin/client/VTooltip.java138
-rw-r--r--client/src/com/vaadin/client/ui/ui/UIConnector.java17
-rw-r--r--server/src/com/vaadin/ui/Tooltip.java240
-rw-r--r--server/src/com/vaadin/ui/UI.java11
-rw-r--r--shared/src/com/vaadin/shared/ui/ui/UIState.java12
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html135
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java107
7 files changed, 650 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java
index e6d9a79a5b..53770f4201 100644
--- a/client/src/com/vaadin/client/VTooltip.java
+++ b/client/src/com/vaadin/client/VTooltip.java
@@ -48,11 +48,6 @@ public class VTooltip extends VOverlay {
public static final int TOOLTIP_EVENTS = Event.ONKEYDOWN
| Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONMOUSEMOVE
| Event.ONCLICK;
- protected static final int MAX_WIDTH = 500;
- private static final int QUICK_OPEN_TIMEOUT = 1000;
- private static final int CLOSE_TIMEOUT = 300;
- private static final int OPEN_DELAY = 750;
- private static final int QUICK_OPEN_DELAY = 100;
VErrorMessage em = new VErrorMessage();
Element description = DOM.createDiv();
@@ -64,6 +59,13 @@ public class VTooltip extends VOverlay {
private String uniqueId = DOM.createUniqueId();
private Element layoutElement;
+ private int maxWidth;
+
+ // Delays for the tooltip, configurable on the server side
+ private int openDelay;
+ private int quickOpenDelay;
+ private int quickOpenTimeout;
+ private int closeTimeout;
/**
* Used to show tooltips; usually used via the singleton in
@@ -126,8 +128,8 @@ public class VTooltip extends VOverlay {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
- if (offsetWidth > MAX_WIDTH) {
- setWidth(MAX_WIDTH + "px");
+ if (offsetWidth > getMaxWidth()) {
+ setWidth(getMaxWidth() + "px");
// Check new height and width with reflowed content
offsetWidth = getOffsetWidth();
@@ -172,7 +174,7 @@ public class VTooltip extends VOverlay {
// Schedule timer for showing the tooltip according to if it was
// recently closed or not.
- int timeout = justClosed ? QUICK_OPEN_DELAY : OPEN_DELAY;
+ int timeout = justClosed ? getQuickOpenDelay() : getOpenDelay();
showTimer.schedule(timeout);
opening = true;
}
@@ -222,10 +224,10 @@ public class VTooltip extends VOverlay {
// already about to close
return;
}
- closeTimer.schedule(CLOSE_TIMEOUT);
+ closeTimer.schedule(getCloseTimeout());
closing = true;
justClosed = true;
- justClosedTimer.schedule(QUICK_OPEN_TIMEOUT);
+ justClosedTimer.schedule(getQuickOpenTimeout());
}
@Override
@@ -466,4 +468,120 @@ public class VTooltip extends VOverlay {
Roles.getTooltipRole().setAriaHiddenState(layoutElement, false);
}
+
+ /**
+ * 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 (in ms)
+ */
+ public int getCloseTimeout() {
+ return closeTimeout;
+ }
+
+ /**
+ * 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 (in ms)
+ */
+ public void setCloseTimeout(int closeTimeout) {
+ this.closeTimeout = 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 (in ms)
+ */
+ public int getQuickOpenTimeout() {
+ return quickOpenTimeout;
+ }
+
+ /**
+ * 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 (in ms)
+ */
+ public void setQuickOpenTimeout(int quickOpenTimeout) {
+ this.quickOpenTimeout = 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 (in ms)
+ */
+ public int getQuickOpenDelay() {
+ return quickOpenDelay;
+ }
+
+ /**
+ * 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 (in ms)
+ */
+ public void setQuickOpenDelay(int quickOpenDelay) {
+ this.quickOpenDelay = 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 (in ms)
+ */
+ public int getOpenDelay() {
+ return openDelay;
+ }
+
+ /**
+ * 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 (in ms)
+ */
+ public void setOpenDelay(int openDelay) {
+ this.openDelay = openDelay;
+ }
+
+ /**
+ * Sets the maximum width of the tooltip popup.
+ *
+ * @param maxWidth
+ * The maximum width the tooltip popup (in pixels)
+ */
+ public void setMaxWidth(int maxWidth) {
+ this.maxWidth = maxWidth;
+ }
+
+ /**
+ * Returns the maximum width of the tooltip popup.
+ *
+ * @return The maximum width the tooltip popup (in pixels)
+ */
+ public int getMaxWidth() {
+ return maxWidth;
+ }
+
}
diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java
index 1df74afd2e..b8b7786d21 100644
--- a/client/src/com/vaadin/client/ui/ui/UIConnector.java
+++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java
@@ -599,4 +599,21 @@ public class UIConnector extends AbstractSingleComponentContainerConnector
}
});
}
+
+ @Override
+ public void onStateChanged(StateChangeEvent stateChangeEvent) {
+ super.onStateChanged(stateChangeEvent);
+ if (stateChangeEvent.hasPropertyChanged("tooltipConfiguration")) {
+ getConnection().getVTooltip().setCloseTimeout(
+ getState().tooltipConfiguration.closeTimeout);
+ getConnection().getVTooltip().setOpenDelay(
+ getState().tooltipConfiguration.openDelay);
+ getConnection().getVTooltip().setQuickOpenDelay(
+ getState().tooltipConfiguration.quickOpenDelay);
+ getConnection().getVTooltip().setQuickOpenTimeout(
+ getState().tooltipConfiguration.quickOpenTimeout);
+ getConnection().getVTooltip().setMaxWidth(
+ getState().tooltipConfiguration.maxWidth);
+ }
+ }
}
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;
+ }
}
diff --git a/shared/src/com/vaadin/shared/ui/ui/UIState.java b/shared/src/com/vaadin/shared/ui/ui/UIState.java
index 9abaf47f4b..cc6897dd0d 100644
--- a/shared/src/com/vaadin/shared/ui/ui/UIState.java
+++ b/shared/src/com/vaadin/shared/ui/ui/UIState.java
@@ -15,9 +15,21 @@
*/
package com.vaadin.shared.ui.ui;
+import java.io.Serializable;
+
import com.vaadin.shared.ui.TabIndexState;
public class UIState extends TabIndexState {
+ public TooltipConfiguration tooltipConfiguration = new TooltipConfiguration();
+
+ public static class TooltipConfiguration implements Serializable {
+ public int openDelay = 750;
+ public int quickOpenDelay = 100;
+ public int quickOpenTimeout = 1000;
+ public int closeTimeout = 300;
+ public int maxWidth = 500;
+ }
+
{
primaryStyleName = "v-ui";
// Default is 1 for legacy reasons
diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html
new file mode 100644
index 0000000000..5170d4408f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.html
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="http://localhost:8888/" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.ui.TooltipConfiguration?restartApplication</td>
+ <td></td>
+</tr>
+<!--Short close delay-->
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
+ <td>0</td>
+</tr>
+<tr>
+ <td>mouseMoveAt</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>id=gwt-uid-3</td>
+ <td>This is a short tooltip</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementNotPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<!--Long close delay-->
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
+ <td>3000</td>
+</tr>
+<tr>
+ <td>mouseMoveAt</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SshortTooltip</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>id=gwt-uid-3</td>
+ <td>This is a short tooltip</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
+ <td>60,9</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SClose timeout</td>
+ <td>0</td>
+</tr>
+<!--Max width 500-->
+<tr>
+ <td>mouseMoveAt</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementWidth</td>
+ <td>id=gwt-uid-3</td>
+ <td>500</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::</td>
+ <td></td>
+</tr>
+<!--Max width 100-->
+<tr>
+ <td>type</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SMax width</td>
+ <td>100</td>
+</tr>
+<tr>
+ <td>mouseMoveAt</td>
+ <td>vaadin=runcomvaadintestscomponentsuiTooltipConfiguration::PID_SlongTooltip</td>
+ <td>0,0</td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>id=gwt-uid-3</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertElementWidth</td>
+ <td>id=gwt-uid-3</td>
+ <td>100</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
new file mode 100644
index 0000000000..b8998ff32e
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java
@@ -0,0 +1,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) {
+ getTooltip().setCloseTimeout(
+ (Integer) closeTimeout.getConvertedValue());
+ }
+ });
+ maxWidth = createIntegerTextField("Max width",
+ getState().tooltipConfiguration.maxWidth);
+ maxWidth.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ getTooltip()
+ .setMaxWidth((Integer) maxWidth.getConvertedValue());
+ }
+ });
+ openDelay = createIntegerTextField("Open delay",
+ getState().tooltipConfiguration.openDelay);
+ openDelay.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ getTooltip().setOpenDelay(
+ (Integer) openDelay.getConvertedValue());
+ }
+ });
+
+ quickOpenDelay = createIntegerTextField("Quick open delay",
+ getState().tooltipConfiguration.quickOpenDelay);
+ quickOpenDelay
+ .addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ getTooltip().setQuickOpenDelay(
+ (Integer) quickOpenDelay.getConvertedValue());
+ }
+ });
+
+ quickOpenTimeout = createIntegerTextField("Quick open timeout",
+ getState().tooltipConfiguration.quickOpenTimeout);
+ quickOpenTimeout
+ .addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ getTooltip().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;
+ }
+
+}