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

Bug 465365

Summary: The height of the title area in TitleAreaDialog doesn't take the length of the contained message into account
Product: [Eclipse Project] Platform Reporter: Baochuan Lin <baochlin>
Component: UIAssignee: Noopur Gupta <noopur_gupta>
Status: RESOLVED WORKSFORME QA Contact:
Severity: minor    
Priority: P3 CC: baochlin, cjxu, daniel_megert, eclipse.sprigogin, kitlo, kqli, Lars.Vogel, markus.kell.r, xbpan
Version: 4.5   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=156790
Whiteboard:
Attachments:
Description Flags
The default panels are truncated on Windows
none
The default panels is horizontal truncation on Linux
none
Screenshot - Eclipse Mars none

Description Baochuan Lin CLA 2015-04-24 02:22:40 EDT
Created attachment 252707 [details]
The default panels are truncated on Windows

Build ID: I20150320-0800

Platform: Windows and Linux

Steps to reproduce:
1. Double click eclipse.exe file
2. Click Window -> Preferences
3. Click General -> Tracing -> UI Responsiveness Monitoring in left frame
4. Click Add Filter

Problem Description:
1.The default Add Filter panels are truncated on Windows.
2.The default Add Filter panels are horizontal truncation in English Linux.

Even though user could resize the panel but with the default truncation user might think the message is incomplete. The user experience is not friendly.
Please help fix. Thanks a lot.
Comment 1 Baochuan Lin CLA 2015-04-24 02:23:13 EDT
Created attachment 252708 [details]
The default panels is horizontal truncation on Linux
Comment 2 Sergey Prigogin CLA 2015-04-29 21:08:00 EDT
The bug is in TitleAreaDialog class. Line 291 of TitleAreaDialog.java reads:
messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;

This statement is incorrect since it always returns the height of a single line of text, regardless of the width of the message area.

See also bug 156790.
Comment 3 Sergey Prigogin CLA 2015-04-29 21:11:33 EDT
In particular http://bugs.eclipse.org/bugs/show_bug.cgi?id=156790#c14
Comment 4 Dani Megert CLA 2015-04-30 09:05:56 EDT
I don't want to touch TitleAreaDialog at this point.
Comment 5 Dani Megert CLA 2015-07-06 15:32:54 EDT
Noopur, please take a look for 4.5.1.
Comment 6 Noopur Gupta CLA 2015-07-07 06:14:32 EDT
Created attachment 255019 [details]
Screenshot - Eclipse Mars

I don't see the truncated text issue in "Add Filter" dialog with Eclipse Mars release build using English on both Windows 7 and Ubuntu 14.04 (GTK3).

See attached screenshot.

Please let me know if this is still reproducible at your end with Mars release build.
Comment 7 Sergey Prigogin CLA 2015-07-07 19:51:03 EDT
(In reply to Noopur Gupta from comment #6)

Has the issue described in comment #2 been fixed?
Comment 8 Chang Jing Xu CLA 2015-07-08 01:12:32 EDT
Hi, all

After check in 
OS: Windows7
Screen Resolution : 1600 * 900
Build ID:  I20150603-2000  

And 

OS: RHEL 7.1
GTK: GTK3 version 3.8.8
Screen Resolution : 1600 * 1200
Build ID:  I20150603-2000  

Problem still exist
Comment 9 Markus Keller CLA 2015-07-09 08:20:57 EDT
(In reply to Sergey Prigogin from comment #7)
> Has the issue described in comment #2 been fixed?

Line 291 of TitleAreaDialog.java has not been touched, and it's actually OK. A few lines above there is ...

		messageLabel.setText(" \n "); // two lines//$NON-NLS-1$

... which ensures the label actually extends to two lines.

The last bigger update to TitleAreaDialog was done in bug 16552, where it was decided to generally keep the title message short, and add a tooltip if it's still too long. IMO, that's good enough (i.e. WORKSFORME).
Comment 10 Dani Megert CLA 2015-07-10 03:53:34 EDT
The strange font in the Windows screenshot is probably caused by special characters used in the pseudo translations.
Comment 11 Dani Megert CLA 2015-07-10 10:01:34 EDT
(In reply to Dani Megert from comment #10)
> The strange font in the Windows screenshot is probably caused by special
> characters used in the pseudo translations.

I tested with the pseudo translation and can't see the font issue on Windows.
Comment 12 Kit Lo CLA 2015-08-13 12:01:14 EDT
Dani was right. I don't see the truncation problem if I reset the JFace dialog font back to the default.
Comment 13 Sergey Prigogin CLA 2015-08-13 13:32:37 EDT
(In reply to Markus Keller from comment #9)

The height of an arbitrary two-line text is not guaranteed to be the same at the height of " \n ", is it?
Comment 14 Markus Keller CLA 2015-08-14 09:31:40 EDT
(In reply to Sergey Prigogin from comment #13)
> The height of an arbitrary two-line text is not guaranteed to be the same at
> the height of " \n ", is it?

In theory, you're probably right. In practice, with well-behaved fonts and UI messages, it usually is the same.

For layout stability, we need to set a constant height. There's no API to get the "maximal possible height of two lines of text", but measuring " \n " is a good approximation.
Comment 15 Sergey Prigogin CLA 2015-08-14 13:18:23 EDT
(In reply to Markus Keller from comment #14)

Since the current solution is already an approximation, it can be slightly improved upon by using a more representative text, for example "A\np". Another option is to introduce some extra margin by multiplying messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y by some coefficient, for example 9/8.