]> source.dussan.org Git - vaadin-framework.git/commitdiff
Show tooltips for ordered layout captions (#10046)
authordenisanisimov <denis@vaadin.com>
Fri, 2 Aug 2013 11:32:47 +0000 (14:32 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 2 Aug 2013 11:40:10 +0000 (11:40 +0000)
Change-Id: I80cb1cbd573d7e0de8aa200a4513dc32984ba9f5

client/src/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/orderedlayout/ErrorIndicator.java [new file with mode: 0644]

index cb6ad25e97419121534865b29a7386f0393eec1a..cea993310f818205d31ebcc5ee1aca837b2043bb 100644 (file)
@@ -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 (file)
index 0000000..81da3b8
--- /dev/null
@@ -0,0 +1,82 @@
+<?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>Required error tootlip</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Required error tooltip</td></tr>
+</thead><tbody>
+<tr>
+       <td>open</td>
+       <td>/run/com.vaadin.tests.components.orderedlayout.ErrorIndicator?restartApplication</td>
+       <td></td>
+</tr>
+<tr>
+       <td>showTooltip</td>
+       <td>//div[@id='gwt-uid-4']/span</td>
+       <td>43,4</td>
+</tr>
+
+<tr>
+        <td>screenCapture</td>
+        <td></td>
+        <td>tooltipVertivcalCaption</td>
+</tr>
+<tr>
+        <td>waitForVaadin</td>
+        <td></td>
+        <td></td>
+</tr>
+<tr>
+       <td>showTooltip</td>
+       <td>//div[@id='gwt-uid-4']/span[2]</td>
+       <td>3,6</td>
+</tr>
+<tr>
+        <td>screenCapture</td>
+        <td></td>
+        <td>tooltipVertivcalRequiredIndicator</td>
+</tr>
+<tr>
+        <td>waitForVaadin</td>
+        <td></td>
+        <td></td>
+</tr>
+<tr>
+       <td>showTooltip</td>
+       <td>//div[@id='gwt-uid-6']/span</td>
+       <td>38,11</td>
+</tr>
+<tr>
+        <td>screenCapture</td>
+        <td></td>
+        <td>tooltipHorizontalCaption</td>
+</tr>
+<tr>
+        <td>waitForVaadin</td>
+        <td></td>
+        <td></td>
+</tr>
+<tr>
+       <td>showTooltip</td>
+       <td>//div[@id='gwt-uid-6']/span[2]</td>
+       <td>3,4</td>
+</tr>
+<tr>
+        <td>screenCapture</td>
+        <td></td>
+        <td>tooltipHorizontalRequiredIndicator</td>
+</tr>
+<tr>
+        <td>waitForVaadin</td>
+        <td></td>
+        <td></td>
+</tr>
+</tbody></table>
+</body>
+</html>
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 (file)
index 0000000..9964e1e
--- /dev/null
@@ -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;
+    }
+
+}