|
Re: Label text is initially truncated [message #1143949 is a reply to message #1143270] |
Fri, 18 October 2013 14:38 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
this is an expected behavior and it's how Text Size Determination (TSD)
works in RAP.
- When the application is started for the first time (after server
start) the size of the text "TRUNCATED LONG PIECE OF TEXT:" is estimated
(real text size in browser is not known yet)
- Text is sent to the client for measurement.
- With the next request real text size is send to the server and
re-layout is performed to adjust the widget bounds.
- The real text size is kept into a "text size database"
- With the next application start (reload), the text size is already
know (available in the "text size database") and it's used directly.
I hope that this explains it.
Best,
Ivan
On 10/18/2013 3:54 PM, M Küng wrote:
> Hi Everyone,
>
> I've currently doing some work on a RAP application and have encountered a strange issue with Label sizes. What I'm trying to do is determine the largest width Label on a form and set all the labels to the same widthHint in a GridLayout. The means that in a two column layout of "buddied" controls (e.g. a Label and a Text control in each column) the layout is symmetrical.
>
> This works great in a matching RCP application but what's happening in RAP is that that the first time the app is loaded in a browser the longer labels are being truncated because the width calculation is not returning the correct value.
>
> If I refresh the page in the browser the text size calculations are corrected and the labels display untruncated.
>
> The issue seems to happen in the text size estimation code but I'm not sure why refreshing the page in the browser is resetting the calculation.
>
> I've attached screenshots from a simple hello app to demonstrate the before and after refresh display. The code used to create the control is as follows:
>
> Composite container = new Composite(parent, SWT.NONE);
> GridLayoutFactory.fillDefaults().applyTo(container);
> Label label = new Label(container, SWT.BORDER);
> label.setText("TRUNCATED LONG PIECE OF TEXT:");
> label.pack();
> GridDataFactory.swtDefaults().hint(label.getSize().x, SWT.DEFAULT).applyTo(label);
>
> Any ideas on how to work around this?
>
>
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Re: Label text is initially truncated [message #1145058 is a reply to message #1144553] |
Sat, 19 October 2013 08:14 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Marcel,
the common workaround is to add a resize listener to the widget and do
your logic there. When widget is created, its bounds are estimated,
based on text size estimation. With the next request from the client (it
happens automatically if there are text for measuring) the layout will
be triggered and the widget bounds will be automatically adjusted to the
real text size. No need to reload the application.
Best,
Ivan
On 10/19/2013 3:00 AM, M Küng wrote:
> Hi Ivan,
>
> Thanks for the quick response. That does indeed explain why it's
> happening but it doesn't explain how to work around the issue.
>
> It there an elegant way to force the re-layout to happen without
> requiring the user to refresh the page in the browser?
>
> I tried calling layout(true, true) on the parent Composite but that
> doesn't work and I can see that the TSD code is simply returning the
> last value it cached rather then updating the cached value.
>
> Thanks,
>
> Marcel
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
Re: Label text is initially truncated [message #1145979 is a reply to message #1145058] |
Sat, 19 October 2013 22:51 |
M Küng Messages: 3 Registered: October 2012 |
Junior Member |
|
|
Hi Ivan,
Awesome. Adding the resize listener does the trick and the same code works nicely in both RAP and RCP.
Thanks very much,
Marcel
Ivan Furnadjiev wrote on Sat, 19 October 2013 21:14Hi Marcel,
the common workaround is to add a resize listener to the widget and do
your logic there. When widget is created, its bounds are estimated,
based on text size estimation. With the next request from the client (it
happens automatically if there are text for measuring) the layout will
be triggered and the widget bounds will be automatically adjusted to the
real text size. No need to reload the application.
Best,
Ivan
On 10/19/2013 3:00 AM, M Küng wrote:
> Hi Ivan,
>
> Thanks for the quick response. That does indeed explain why it's
> happening but it doesn't explain how to work around the issue.
>
> It there an elegant way to force the re-layout to happen without
> requiring the user to refresh the page in the browser?
>
> I tried calling layout(true, true) on the parent Composite but that
> doesn't work and I can see that the TSD code is simply returning the
> last value it cached rather then updating the cached value.
>
> Thanks,
>
> Marcel
|
|
|
Powered by
FUDForum. Page generated in 0.05589 seconds