Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 561337

Summary: Tooltip for a node is working just one time
Product: [Tools] GEF Reporter: Gerhard Kreuzer <gerhard.kreuzer>
Component: GEF ZestAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gerhard.kreuzer, nyssen
Version: 5.3.0   
Target Milestone: 5.3.0 (2019-12) M2   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Gerhard Kreuzer CLA 2020-03-22 05:04:28 EDT
The tooltip for a node is displayed just one time: hover over node 1 => tooltip appears, hover over (other) node 2 => tooltip appears go back to node 1 => tooltip is not displayed again.

IMHO the reason for this is is buried in refreshTooltip() (code from org.eclipse.gef.zest.fx.parts.NodePart):

protected void refreshTooltip() {
	String tooltip = ZestProperties.getTooltip(getContent());
	if (tooltip != null && !tooltip.isEmpty()) {
		if (tooltipNode == null) {
			tooltipNode = new Tooltip(tooltip);
			Tooltip.install(getVisual(), tooltipNode);
		} else {
			tooltipNode.setText(tooltip);
		}
	} else {
		if (tooltipNode != null) {
			Tooltip.uninstall(getVisual(), tooltipNode);
			/////////////////////////////////////
			tooltipNode = null; // <= missing !!!
			/////////////////////////////////////
		}
	}
}
Comment 1 Alexander Nyßen CLA 2020-03-23 02:40:35 EDT
I cannot reproduce the behavior you describe (tested with OpenJDK 11 and OpenJFX 11). The tooltip is correctly shown more than once for each node. The code also does not look suspicious to me. The tooltip is lazily initialized and properly reinstalled upon refresh. IMHO there should be no need to reinitialize it. 

I am resolving this as WORKSFORME. Please reopen when providing further information on where/how to reproduce this.
Comment 2 Gerhard Kreuzer CLA 2020-03-23 05:11:14 EDT
Alexander, thanks for your quick response and sorry for my sloppy description in the first place. My nodes are rather complex beasts potentially with a number of "sub-areas" that provide different (or no) tooltips, depending on where the mouse hovers within die node. (You had a chance to look at them in January 2017, when Joachim Freytag organized a web meeting and I showed you my project. Probably you do remember this?) 
That means, that the else clause (line 11 - 13, where the uninstall takes place) can be executed after a tooltip was shown. But once uninstalled there is no chance to get reinstalled, because the field tooltipNode remains set. (What you see here is the original code, I removed my suggested fix.)

01 protected void refreshTooltip() {
02	String tooltip = ZestProperties.getTooltip(getContent());
03	if (tooltip != null && !tooltip.isEmpty()) {
04		if (tooltipNode == null) {
05			tooltipNode = new Tooltip(tooltip);
06			Tooltip.install(getVisual(), tooltipNode);
07		} else {
08			tooltipNode.setText(tooltip);
09		}
10	} else {
11		if (tooltipNode != null) {
12			Tooltip.uninstall(getVisual(), tooltipNode);
13		}
14	}
15 }
Comment 3 Gerhard Kreuzer CLA 2020-04-20 11:41:37 EDT
Alexander, were you able to reproduce or at least comprehend the effect I described? Do you want me to provide a Gerrit for it?
Comment 4 Alexander Nyßen CLA 2020-04-20 13:52:37 EDT
I already committed a fix for it: [561337] Clear tooltipNode when tooltip is removed.

I did not resolve this bugzilla, as our list of target milestones was (and still is) not up-to-date. Resolving as fixed now (in 5.3.0 M2).
Comment 5 Gerhard Kreuzer CLA 2020-04-20 14:26:59 EDT
(In reply to Alexander Nyßen from comment #4)
> I already committed a fix for it: [561337] Clear tooltipNode when tooltip is
> removed.
> 
> I did not resolve this bugzilla, as our list of target milestones was (and
> still is) not up-to-date. Resolving as fixed now (in 5.3.0 M2).

Great! Thanks!