diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-06-14 08:18:04 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2012-06-14 08:18:04 +0000 |
commit | 835c03b8633454861b491dd6053a990579e19de8 (patch) | |
tree | 9b6fdb660270504e78f6392cfbd1f71643329ed1 | |
parent | 6fc4fd79a6b96bcdd66058173e78beec3d9ce9ac (diff) | |
download | vaadin-framework-835c03b8633454861b491dd6053a990579e19de8.tar.gz vaadin-framework-835c03b8633454861b491dd6053a990579e19de8.zip |
#7766 Applied Sami's patch
svn changeset:23935/svn branch:6.8
3 files changed, 100 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java index ff649ebeb1..c16ad8a76f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapper.java @@ -62,6 +62,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements private static final String CLASSNAME = "v-ddwrapper"; protected static final String DRAGGABLE = "draggable"; + private boolean hasTooltip = false; + public VDragAndDropWrapper() { super(); sinkEvents(VTooltip.TOOLTIP_EVENTS); @@ -94,7 +96,8 @@ public class VDragAndDropWrapper extends VCustomComponent implements public void onBrowserEvent(Event event) { super.onBrowserEvent(event); - if (client != null) { + if (hasTooltip && client != null) { + // Override child tooltips if the wrapper has a tooltip defined client.handleTooltipEvent(event, this); } } @@ -158,6 +161,10 @@ public class VDragAndDropWrapper extends VCustomComponent implements this.client = client; super.updateFromUIDL(uidl, client); if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) { + + // Used to prevent wrapper from stealing tooltips when not defined + hasTooltip = uidl.hasAttribute("description"); + UIDL acceptCrit = uidl.getChildByTagName("-ac"); if (acceptCrit == null) { dropHandler = null; diff --git a/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.html b/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.html new file mode 100644 index 0000000000..4d2fde6b45 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.html @@ -0,0 +1,52 @@ +<?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="" /> +<title>TooltipHandlingWhenNotDefined</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">TooltipHandlingWhenNotDefined</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.draganddropwrapper.TooltipHandlingWhenNotDefined?restartApplication</td> + <td></td> +</tr> +<tr> + <td>mouseOver</td> + <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperTooltipHandlingWhenNotDefined::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VDragAndDropWrapper[0]/VCssLayout[0]/VCssLayout$FlowPane[0]/VLabel[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>5000</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>tooltip_shown</td> +</tr> +<tr> + <td>mouseOut</td> + <td>vaadin=runcomvaadintestscomponentsdraganddropwrapperTooltipHandlingWhenNotDefined::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VDragAndDropWrapper[0]/VCssLayout[0]/VCssLayout$FlowPane[0]/VLabel[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td></td> + <td>2000</td> +</tr> +<tr> + <td>screenCapture</td> + <td></td> + <td>tooltip_hidden</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.java b/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.java new file mode 100644 index 0000000000..4b07175cd8 --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/draganddropwrapper/TooltipHandlingWhenNotDefined.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.components.draganddropwrapper; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.DragAndDropWrapper.DragStartMode; +import com.vaadin.ui.Label; + +public class TooltipHandlingWhenNotDefined extends TestBase { + + @Override + protected void setup() { + + CssLayout wrapperLayout = new CssLayout(); + wrapperLayout.setWidth("100%"); + + Label label = new Label("Can I has the tooltip?", Label.CONTENT_XHTML); + label.setDescription("Good! Tooltip works!"); + label.setSizeUndefined(); + wrapperLayout.addComponent(label); + + DragAndDropWrapper wrapper = new DragAndDropWrapper(wrapperLayout); + wrapper.setWidth("100%"); + wrapper.setDragStartMode(DragStartMode.WRAPPER); + + addComponent(wrapper); + + } + + @Override + protected String getDescription() { + return "Wrapper most not prevent child from showing tooltip"; + } + + @Override + protected Integer getTicketNumber() { + return 7766; + } + +} |