diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-01-08 08:58:55 +0000 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-01-08 08:58:55 +0000 |
commit | d833f915873f8c3bec9ebbc31ba23b07c611c0a9 (patch) | |
tree | f8defdb584b28510d58532cb73212081c7ad69de | |
parent | 513a64d6345047da985db62d2112e0ec4a3ebbab (diff) | |
parent | 9d9df80a3b906ae50f85008153462c3abdc6779a (diff) | |
download | vaadin-framework-d833f915873f8c3bec9ebbc31ba23b07c611c0a9.tar.gz vaadin-framework-d833f915873f8c3bec9ebbc31ba23b07c611c0a9.zip |
Merge "Only show tooltips for the Form itself (#9173)"
3 files changed, 269 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/form/FormConnector.java b/client/src/com/vaadin/client/ui/form/FormConnector.java index 45dc0f61fe..09b7fbcd91 100644 --- a/client/src/com/vaadin/client/ui/form/FormConnector.java +++ b/client/src/com/vaadin/client/ui/form/FormConnector.java @@ -15,6 +15,7 @@ */ package com.vaadin.client.ui.form; +import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.user.client.ui.Widget; @@ -23,7 +24,9 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Paintable; +import com.vaadin.client.TooltipInfo; import com.vaadin.client.UIDL; +import com.vaadin.client.Util; import com.vaadin.client.ui.AbstractComponentContainerConnector; import com.vaadin.client.ui.Icon; import com.vaadin.client.ui.ShortcutActionHandler; @@ -206,4 +209,15 @@ public class FormConnector extends AbstractComponentContainerConnector } getWidget().setLayoutWidget(newLayoutWidget); } + + @Override + public TooltipInfo getTooltipInfo(Element element) { + if (Util.getConnectorForElement(getConnection(), getWidget() + .getParent(), (com.google.gwt.user.client.Element) element + .cast()) != this) { + // Do not show tooltips when hovering over child fields + return null; + } + return super.getTooltipInfo(element); + } } diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.html b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html new file mode 100644 index 0000000000..0d069efb0b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.html @@ -0,0 +1,199 @@ +<?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.form.FormTooltips?restartApplication</td> + <td></td> +</tr> +<!--first name tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Fields own tooltip</td> +</tr> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> + <td></td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--first name caption tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Fields own tooltip</td> +</tr> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> + <td></td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--Form description tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]/domChild[0]</td> + <td>Form error</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Some description</td> +</tr> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> + <td></td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--Form error message tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]/domChild[0]</td> + <td>Form error</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Some description</td> +</tr> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> + <td></td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--last name parent should have error tooltip--> +<tr> + <td>showTooltip</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/domChild[0]/domChild[3]</td> + <td></td> +</tr> +<tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/VErrorMessage[0]/HTML[0]/domChild[0]</td> + <td>Form error</td> +</tr> +<tr> + <td>assertText</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td>Some description</td> +</tr> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::</td> + <td></td> +</tr> +<tr> + <td>waitForElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--last name should have no tooltip--> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[1]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> +<!--last name caption should have no tooltip--> +<tr> + <td>mouseMove</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VForm[0]/VFormLayout[0]/domChild[0]/domChild[1]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td> + <td></td> +</tr> +<tr> + <td>pause</td> + <td>300</td> + <td></td> +</tr> +<tr> + <td>assertElementNotPresent</td> + <td>vaadin=runcomvaadintestscomponentsformFormTooltips::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> + <td></td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltips.java b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java new file mode 100644 index 0000000000..b70f66c710 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltips.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012 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.tests.components.form; + +import java.util.Arrays; + +import com.vaadin.data.util.BeanItem; +import com.vaadin.server.UserError; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.tests.data.bean.Sex; +import com.vaadin.ui.Form; +import com.vaadin.ui.TextField; + +public class FormTooltips extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final Form form = new Form(); + form.setDescription("Some description"); + form.setItemDataSource(new BeanItem<Person>(new Person("foo", "bar", + "baz", 12, Sex.MALE, null)), Arrays.asList(new String[] { + "firstName", "lastName", "age" })); + ((TextField) form.getField("firstName")) + .setDescription("Fields own tooltip"); + + form.setComponentError(new UserError("Form error")); + addComponent(form); + + } + + @Override + protected String getTestDescription() { + return "The 'first name' should show its own tooltip, the other fields should show no tooltip"; + } + + @Override + protected Integer getTicketNumber() { + return 9173; + } + +} |