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

Bug 313352

Summary: ampersand could only appear in one continuous sequence in tooltips
Product: [Eclipse Project] Platform Reporter: chen zhichao <c.zhichao>
Component: SWTAssignee: Felipe Heidrich <eclipse.felipe>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe, Silenio_Quarti, vwine
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug
Attachments:
Description Flags
TableItem implementation
none
LabelProvider implementation none

Description chen zhichao CLA 2010-05-18 09:43:52 EDT
Build Identifier: 20100218-1602

hi, 
I'm trying to make to Tree cell showing tooltips like: aa=11&bb=22&cc=33 which is common is http post URL. I read the javadoc in TableColumn which says "douling ampersand for escape" and try using && instead of &. 
But the tooltips I get for text "aa=11&&bb=22&&cc=33" is "aa=11&bb=22cc=33"
more over, 
aa=11&&&& shows aa=11&&
aa=11&&&&bb=22&&&&cc=33 shows aa=11&&bb=2222cc=33
The second sequence of two ampersand are taken by "22". I'm not sure this is an intended behaviour or not, but for me, it's confusing.

I attached two snnipests for this problem, one is implemented by TableItem and the other is implemented by LabelProvider, you will see that for TreeCellTooltips1, the tooltips are exactly the text in the cell while for TreeCellTooltips2, the tooltips is as described. I think at least there is this inconsistency and more over, it does not behave like javadoc says...I think it is a bug.

Best Regards,
Zhichao

Reproducible: Always
Comment 1 chen zhichao CLA 2010-05-18 09:45:39 EDT
Created attachment 168927 [details]
TableItem implementation

In this test, we see that tooltips are showing exactly the same text as table cell.
Comment 2 chen zhichao CLA 2010-05-18 09:46:22 EDT
Created attachment 168928 [details]
LabelProvider implementation

LabelProvider Implementation shows confusing tooltips...
Comment 3 Prakash Rangaraj CLA 2010-05-19 05:05:34 EDT
The tree item's tooltip is provided by SWT. Assigning to SWT for comments
Comment 4 Felipe Heidrich CLA 2010-05-19 12:15:55 EDT
public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	shell.setLayout(new FillLayout());
	final Tree tree = new Tree (shell, SWT.FULL_SELECTION | SWT.MULTI);
	tree.setHeaderVisible(true);
	tree.setLinesVisible(true);
	TreeColumn column = new TreeColumn(tree, SWT.LEFT);
	column.setText("ampersand");
	column.setWidth(50);
	for (int i=0; i<4; i++) {
		TreeItem iItem = new TreeItem (tree, 0);
		iItem.setText ("aa=11&&bb=22&&cc=33");
	}
	shell.setSize (200, 200);
	shell.open ();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}

It seems we are forgetting to espace the text before setting the tooltip.

In your post, this line: "aa=11&&&&bb=22&&&&cc=33 shows aa=11&&bb=2222cc=33"
didn't you mean to say:  "aa=11&&&&bb=22&&&&cc=33 shows aa=11&&bb=22&&cc=33"
?
Comment 5 Felipe Heidrich CLA 2010-05-19 12:16:42 EDT
SSQ, After 3.6 ?
Comment 6 Felipe Heidrich CLA 2010-05-19 13:22:54 EDT
Note: the native tree tooltip has the problem. When the custom tooltip is used this problem doesn't happen. For testing, try adding these lines to see if the problem gets fixed:
tree.addListener(SWT.MeasureItem, new Listener() {
	public void handleEvent(Event event) {
	}
});
Comment 7 Silenio Quarti CLA 2010-05-19 15:07:04 EDT
Not for 3.6
Comment 8 chen zhichao CLA 2010-05-20 07:18:34 EDT
forget to mention that I'm using 3.5(In reply to comment #7)
> Not for 3.6
Comment 9 chen zhichao CLA 2010-05-20 07:19:12 EDT
Yes, this workround works! Thanks a lot!
> Note: the native tree tooltip has the problem. When the custom tooltip is used
> this problem doesn't happen. For testing, try adding these lines to see if the
> problem gets fixed:
> tree.addListener(SWT.MeasureItem, new Listener() {
>     public void handleEvent(Event event) {
>     }
> });
Comment 10 Felipe Heidrich CLA 2010-05-20 10:58:58 EDT
(In reply to comment #9)
> Yes, this workround works! Thanks a lot!

Keep in mind the code I suggested enables custom draw for the table. It will cause considerable extra code to run.
Comment 11 Vaughn Wine CLA 2011-07-26 17:48:40 EDT
I'm having the same problem with a Hyperlink control added to a Composite on a Properties Page.  I'm doing something like this:

String url = "http://mycompany.com/dosomething.jsp?param1=value1&param2=value2&param3=value3";
Hyperlink myLink = formToolkit.createHyperlink(myComposite, "MyLink", SWT.NONE);
mylink.setToolTipText(url.replace("&", "&&");

The first ampersand appears but not the second.

I tried the workaround, but it didn't work.  However, perhaps I'm not adding the listener to the right Control.  I tried adding the listener to the hyperlink Control, to its parent, and also to the Composite (which is probably the same as its parent), but none of these approached solved the problem.  This seems like a bug to me.  If there's a workaround, I'd love to know about it!  I'm going to have to suppress the showing of this useful tool tip for now until I figure out a way to show it correctly.
Comment 12 Felipe Heidrich CLA 2011-07-27 11:36:16 EDT
(In reply to comment #11)
> I'm having the same problem with a Hyperlink control added to a Composite on a
> Properties Page.  I'm doing something like this:
> String url =
> "http://mycompany.com/dosomething.jsp?param1=value1&param2=value2&param3=value3";
> Hyperlink myLink = formToolkit.createHyperlink(myComposite, "MyLink",
> SWT.NONE);

This is a different bug, the bug here is against the SWT Tree widget. You are having the bug with Hyperlink from Forms. Please, report the bug against user assistance.
Comment 13 Lars Vogel CLA 2019-11-14 03:39:51 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.