diff options
author | Juuso Valli <juuso@vaadin.com> | 2014-06-06 12:55:56 +0300 |
---|---|---|
committer | Juuso Valli <juuso@vaadin.com> | 2014-06-11 16:06:21 +0300 |
commit | 534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf (patch) | |
tree | bfbf47e13fe2ee7e91690f7a22d4477ef54c48ce /client/src/com/vaadin | |
parent | 3e5c5bc10752ae011ee74c82530452ba26521833 (diff) | |
download | vaadin-framework-534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf.tar.gz vaadin-framework-534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf.zip |
Make tooltips stationary when hovering (#13981)
Change-Id: I44acce87ea5c37d7b210e6c6c3dd9cd511192524
Diffstat (limited to 'client/src/com/vaadin')
-rw-r--r-- | client/src/com/vaadin/client/TooltipInfo.java | 21 | ||||
-rw-r--r-- | client/src/com/vaadin/client/VTooltip.java | 21 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VMenuBar.java | 2 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VTabsheet.java | 2 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/tree/TreeConnector.java | 3 |
6 files changed, 43 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/TooltipInfo.java b/client/src/com/vaadin/client/TooltipInfo.java index 67d2ad37c2..06940536c8 100644 --- a/client/src/com/vaadin/client/TooltipInfo.java +++ b/client/src/com/vaadin/client/TooltipInfo.java @@ -21,6 +21,11 @@ public class TooltipInfo { private String errorMessageHtml; + // Contains the tooltip's identifier. If a tooltip's contents and this + // identifier haven't changed, the tooltip won't be updated in subsequent + // events. + private Object identifier; + public TooltipInfo() { } @@ -29,10 +34,23 @@ public class TooltipInfo { } public TooltipInfo(String tooltip, String errorMessage) { + this(tooltip, errorMessage, null); + } + + public TooltipInfo(String tooltip, String errorMessage, Object identifier) { + setIdentifier(identifier); setTitle(tooltip); setErrorMessage(errorMessage); } + public void setIdentifier(Object identifier) { + this.identifier = identifier; + } + + public Object getIdentifier() { + return identifier; + } + public String getTitle() { return title; } @@ -61,6 +79,7 @@ public class TooltipInfo { } public boolean equals(TooltipInfo other) { - return (other != null && other.title == title && other.errorMessageHtml == errorMessageHtml); + return (other != null && other.title == title + && other.errorMessageHtml == errorMessageHtml && other.identifier == identifier); } } diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java index 77720089b1..8e653a0476 100644 --- a/client/src/com/vaadin/client/VTooltip.java +++ b/client/src/com/vaadin/client/VTooltip.java @@ -358,11 +358,9 @@ public class VTooltip extends VWindowOverlay { * @return TooltipInfo if connector and tooltip found, null if not */ private TooltipInfo getTooltipFor(Element element) { - ApplicationConnection ac = getApplicationConnection(); ComponentConnector connector = Util.getConnectorForElement(ac, RootPanel.get(), element); - // Try to find first connector with proper tooltip info TooltipInfo info = null; while (connector != null) { @@ -447,10 +445,26 @@ public class VTooltip extends VWindowOverlay { return; } + // If the parent (sub)component already has a tooltip open and it + // hasn't changed, we ignore the event. + // TooltipInfo contains a reference to the parent component that is + // checked in it's equals-method. + if (currentElement != null && isActuallyVisible()) { + TooltipInfo currentTooltip = getTooltipFor(currentElement); + TooltipInfo newTooltip = getTooltipFor(element); + if (currentTooltip != null && currentTooltip.equals(newTooltip)) { + return; + } + } + TooltipInfo info = getTooltipFor(element); if (info == null) { handleHideEvent(); } else { + if (closing) { + closeTimer.cancel(); + closing = false; + } setTooltipText(info); updatePosition(event, isFocused); if (isActuallyVisible() && !isFocused) { @@ -460,8 +474,7 @@ public class VTooltip extends VWindowOverlay { closeNow(); } // Schedule timer for showing the tooltip according to if it - // was - // recently closed or not. + // was recently closed or not. int timeout = justClosed ? getQuickOpenDelay() : getOpenDelay(); if (timeout == 0) { diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java index f17ffbefed..11fda6222c 100644 --- a/client/src/com/vaadin/client/ui/VMenuBar.java +++ b/client/src/com/vaadin/client/ui/VMenuBar.java @@ -1034,7 +1034,7 @@ public class VMenuBar extends SimpleFocusablePanel implements return null; } - return new TooltipInfo(description); + return new TooltipInfo(description, null, this); } /** diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d6eec66561..d3317abd4d 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -5157,7 +5157,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, String rowDescription = uidl.getStringAttribute("rowdescr"); if (rowDescription != null && !rowDescription.equals("")) { - tooltipInfo = new TooltipInfo(rowDescription); + tooltipInfo = new TooltipInfo(rowDescription, null, this); } else { tooltipInfo = null; } @@ -5430,7 +5430,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, private void setTooltip(TableCellElement td, String description) { if (description != null && !description.equals("")) { - TooltipInfo info = new TooltipInfo(description); + TooltipInfo info = new TooltipInfo(description, null, this); cellToolTips.put(td, info); } else { cellToolTips.remove(td); diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index 3f2d90b721..15d9c83c49 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -329,7 +329,7 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private boolean update(TabState tabState) { if (tabState.description != null || tabState.componentError != null) { setTooltipInfo(new TooltipInfo(tabState.description, - tabState.componentError)); + tabState.componentError, this)); } else { setTooltipInfo(null); } diff --git a/client/src/com/vaadin/client/ui/tree/TreeConnector.java b/client/src/com/vaadin/client/ui/tree/TreeConnector.java index c57430b3b4..55224b455f 100644 --- a/client/src/com/vaadin/client/ui/tree/TreeConnector.java +++ b/client/src/com/vaadin/client/ui/tree/TreeConnector.java @@ -269,7 +269,8 @@ public class TreeConnector extends AbstractComponentConnector implements String description = uidl.getStringAttribute("descr"); if (description != null) { - tooltipMap.put(treeNode, new TooltipInfo(description)); + tooltipMap.put(treeNode, new TooltipInfo(description, null, + treeNode)); } if (uidl.getBooleanAttribute("expanded") && !treeNode.getState()) { |