summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2016-09-06 17:00:26 +0300
committerArtur Signell <artur@vaadin.com>2016-09-08 11:33:37 +0000
commit3017820a537808c3b6baa337a17f2a8f1585d543 (patch)
treedfae03caf87e8ad73fe69561c6e70f7c3de6919e /client
parent74df0fadeb7d6c2a6e15b4716602d6ab7ffb54b1 (diff)
downloadvaadin-framework-3017820a537808c3b6baa337a17f2a8f1585d543.tar.gz
vaadin-framework-3017820a537808c3b6baa337a17f2a8f1585d543.zip
Add DescriptionGenerators for Grid and Columns
Change-Id: Ib32726ba3297a05cbc05898f37579777b9a921e0
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
index 880de07d55..006aa65318 100644
--- a/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
+++ b/client/src/main/java/com/vaadin/client/connectors/grid/GridConnector.java
@@ -21,15 +21,18 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.google.gwt.dom.client.Element;
import com.google.gwt.event.shared.HandlerRegistration;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ConnectorHierarchyChangeEvent;
import com.vaadin.client.ConnectorHierarchyChangeEvent.ConnectorHierarchyChangeHandler;
import com.vaadin.client.DeferredWorker;
import com.vaadin.client.HasComponentsConnector;
+import com.vaadin.client.TooltipInfo;
import com.vaadin.client.connectors.AbstractListingConnector;
import com.vaadin.client.data.DataSource;
import com.vaadin.client.ui.SimpleManagedLayout;
+import com.vaadin.client.widget.grid.CellReference;
import com.vaadin.client.widget.grid.selection.ClickSelectHandler;
import com.vaadin.client.widget.grid.selection.SpaceSelectHandler;
import com.vaadin.client.widget.grid.sort.SortEvent;
@@ -235,4 +238,44 @@ public class GridConnector
clickSelectHandler = null;
}
}
+
+ @Override
+ public boolean hasTooltip() {
+ // Always check for generated descriptions.
+ return true;
+ }
+
+ @Override
+ public TooltipInfo getTooltipInfo(Element element) {
+ CellReference<JsonObject> cell = getWidget().getCellReference(element);
+
+ if (cell != null) {
+ JsonObject row = cell.getRow();
+
+ if (row != null && (row.hasKey(GridState.JSONKEY_ROWDESCRIPTION)
+ || row.hasKey(GridState.JSONKEY_CELLDESCRIPTION))) {
+
+ Column<?, JsonObject> column = cell.getColumn();
+ if (columnToIdMap.containsKey(column)) {
+ JsonObject cellDescriptions = row
+ .getObject(GridState.JSONKEY_CELLDESCRIPTION);
+
+ String id = columnToIdMap.get(column);
+ if (cellDescriptions != null
+ && cellDescriptions.hasKey(id)) {
+ return new TooltipInfo(cellDescriptions.getString(id));
+ } else if (row.hasKey(GridState.JSONKEY_ROWDESCRIPTION)) {
+ return new TooltipInfo(row
+ .getString(GridState.JSONKEY_ROWDESCRIPTION));
+ }
+ }
+ }
+ }
+
+ if (super.hasTooltip()) {
+ return super.getTooltipInfo(element);
+ } else {
+ return null;
+ }
+ }
}