From 99c7d0b3cde116bf31b00bd31f62f9f4920b1762 Mon Sep 17 00:00:00 2001 From: denisanisimov Date: Fri, 2 Aug 2013 14:32:47 +0300 Subject: [PATCH] Show tooltips for ordered layout captions (#10046) Change-Id: I80cb1cbd573d7e0de8aa200a4513dc32984ba9f5 --- .../AbstractOrderedLayoutConnector.java | 39 +++++++++ .../orderedlayout/ErrorIndicator.html | 82 +++++++++++++++++++ .../orderedlayout/ErrorIndicator.java | 79 ++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.html create mode 100644 uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.java diff --git a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java index cb6ad25e97..cea993310f 100644 --- a/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java +++ b/client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java @@ -25,6 +25,7 @@ import com.vaadin.client.ConnectorHierarchyChangeEvent; import com.vaadin.client.LayoutManager; import com.vaadin.client.Profiler; import com.vaadin.client.ServerConnector; +import com.vaadin.client.TooltipInfo; import com.vaadin.client.Util; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler; @@ -349,6 +350,44 @@ public abstract class AbstractOrderedLayoutConnector extends updateInternalState(); } + /* + * (non-Javadoc) + * + * @see + * com.vaadin.client.ui.AbstractComponentConnector#getTooltipInfo(com.google + * .gwt.dom.client.Element) + */ + @Override + public TooltipInfo getTooltipInfo(com.google.gwt.dom.client.Element element) { + if (element != getWidget().getElement()) { + Slot slot = Util.findWidget( + (com.google.gwt.user.client.Element) element, Slot.class); + if (slot != null && slot.getCaptionElement() != null + && slot.getCaptionElement().isOrHasChild(element)) { + ComponentConnector connector = Util.findConnectorFor(slot + .getWidget()); + if (connector != null) { + return connector.getTooltipInfo(element); + } + } + } + return super.getTooltipInfo(element); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.client.ui.AbstractComponentConnector#hasTooltip() + */ + @Override + public boolean hasTooltip() { + /* + * Tooltips are fetched from child connectors -> there's no quick way of + * checking whether there might a tooltip hiding somewhere + */ + return true; + } + /** * Updates DOM properties and listeners based on the current state of this * layout and its children. diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.html b/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.html new file mode 100644 index 0000000000..81da3b897e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.html @@ -0,0 +1,82 @@ + + + + + + +Required error tootlip + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Required error tooltip
open/run/com.vaadin.tests.components.orderedlayout.ErrorIndicator?restartApplication
showTooltip//div[@id='gwt-uid-4']/span43,4
screenCapturetooltipVertivcalCaption
waitForVaadin
showTooltip//div[@id='gwt-uid-4']/span[2]3,6
screenCapturetooltipVertivcalRequiredIndicator
waitForVaadin
showTooltip//div[@id='gwt-uid-6']/span38,11
screenCapturetooltipHorizontalCaption
waitForVaadin
showTooltip//div[@id='gwt-uid-6']/span[2]3,4
screenCapturetooltipHorizontalRequiredIndicator
waitForVaadin
+ + diff --git a/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.java b/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.java new file mode 100644 index 0000000000..9964e1ee78 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.java @@ -0,0 +1,79 @@ +/* + * 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.tests.components.orderedlayout; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class ErrorIndicator extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + + TextField inVertical = new TextField(); + inVertical.setRequired(true); + inVertical.setRequiredError("Vertical layout tooltip"); + inVertical.setCaption("Vertical layout caption"); + + layout.addComponent(inVertical); + addComponent(layout); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + + TextField inHorizontal = new TextField(); + inHorizontal.setRequired(true); + inHorizontal.setRequiredError("Horizontal layout tooltip"); + inHorizontal.setCaption("Horizontal layout caption"); + + horizontalLayout.addComponent(inHorizontal); + layout.addComponent(horizontalLayout); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Show tooltip for caption and required indicator"; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 10046; + } + +} -- 2.39.5