Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Layout issues due to stringExtend miscalculation?
Layout issues due to stringExtend miscalculation? [message #1016163] Tue, 05 March 2013 10:18 Go to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
Hey again.

I'm having slight layout issues with our login dialog. It is a quite simple dialog with some labels and text-fields and an image. the shell is pack()ed, so i'd expect everything to be fine. Now, when opening the dialog for the very first time (i.e. firing up the application), it seems that string extents are calculated wrong. After this first time, no matter from which machine (session), the dialog looks correct. Only the very first user that connects gets a wrong layout.

I traced the issue down to the TextSizeUtil.determineTextSize, and set a conditional breakpoint there which sysout's the resulting point when calculating the length of "0" (which we use in that case).

This results in this output for the first user that connects:

font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {5, 13}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {5, 13}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {5, 13}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {7, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {5, 13}


all subsequently connections yield this:

font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {7, 12}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {7, 12}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {7, 12}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Verdana, "Lucida Sans", Arial, Helvetica, sans-serif,14,NORMAL},string=0, result=Point {8, 16}
font=Font {Courier New,11,ITALIC},string=0, result=Point {7, 12}


as you can see the results are quite different! i had no time until now to follow the issue deeper into the code. it must get something wrong somewhere. Is this a known issue, or shall i report a bug again?

Is there a possible workaround? (something like triggering calculation of extents when firing up the application, ...)

Thanks Smile
Re: Layout issues due to stringExtend miscalculation? [message #1016170 is a reply to message #1016163] Tue, 05 March 2013 10:36 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
hm, it seems from the code that it is actually intended to only estimate (wrong in my case) until calculation is done in another thread... hm. Interesting is: with the breakpoint the UI is slow enough to see that when the dialog opens the first time, all elements fit the dialog itself but are too small to fit the text (labels for example). after a short (very short) while, a background thread seems to calculate text extents, and the UI elements sizes are adapted for the new font size - the dialog itself however is not resized, thus elements are then larger than the dialog... phew.
Re: Layout issues due to stringExtend miscalculation? [message #1016380 is a reply to message #1016170] Wed, 06 March 2013 10:01 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
Hello, I had filled 2 bugs probably caused by this
https://bugs.eclipse.org/bugs/show_bug.cgi?id=366151 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=344835

For 344835 I describe a workaround at the end of the bug, maybe it could help.
Re: Layout issues due to stringExtend miscalculation? [message #1016418 is a reply to message #1016380] Wed, 06 March 2013 11:58 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi Markus,

that's a typical TextSizeDetermination issue. You can probably work
around it by overriding configureShell and add these lines:

@Override
protected void configureShell( Shell shell ) {
super.configureShell( shell );
// Workaround for RWT Text Size Determination
shell.addListener( SWT.Resize, new Listener() {
public void handleEvent( Event event ) {
initializeBounds();
}
} );
}

HTH, Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Layout issues due to stringExtend miscalculation? [message #1016486 is a reply to message #1016418] Wed, 06 March 2013 16:04 Go to previous message
Markus Duft is currently offline Markus DuftFriend
Messages: 148
Registered: February 2013
Senior Member
thanks for the reply. in the meantime i set fixed dialog sizes for the login dialog, which leaves me with wrongly dimensioned input fields in the layout, but a determinable dialog size. also hooking on the resize event and trying all kinds of funny stuff from re-layouting to updating to initializeBounds() does not have any positive effect on the layout... but it's a minor issue, as we don't want to restart the application every 5 minutes anyway. still i thought it is worth mentioning.
Previous Topic:RAP Running in Eclipse Internal Browser
Next Topic:TableViewer / LabelProvider Images with different width
Goto Forum:
  


Current Time: Tue Apr 16 11:52:39 GMT 2024

Powered by FUDForum. Page generated in 0.69524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top