Bug 209924 - [NoteTextLabel] WrapLabel # getPreferredSize(int, int) contract has changed after recent refactoring
Summary: [NoteTextLabel] WrapLabel # getPreferredSize(int, int) contract has changed a...
Status: ASSIGNED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal
Target Milestone: ---   Edit
Assignee: Cherie Revells CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 209644
  Show dependency tree
 
Reported: 2007-11-15 07:05 EST by Michael Golubev CLA
Modified: 2010-07-19 21:59 EDT (History)
3 users (show)

See Also:


Attachments
Test case (2.06 KB, text/plain)
2007-11-15 07:05 EST, Michael Golubev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Golubev CLA 2007-11-15 07:05:07 EST
Created attachment 82955 [details]
Test case

Hello, 

After recent refactoring of WrapLabel class (introduction of WrappingLabel) the contract of the method getPreferredSize(int, int) is changed. 

I believe that prior to refactoring the attached testcase was not failing (also I can't directly check it now, but I am pretty sure that WrapLabel and Label behaved the same way in the past and was in fact interchangeable from layout point of view). 

The main consequence of this for the UML2Tools is described in the #209644 
-- that is, ToolbarLayout passes complete available space of container as hints. With the old version of code, the "natural" size was returned, and the label was centered by layouter. With actual version of the code, the hints are returned as is, and the label is drawn left-aligned.
Comment 1 Cherie Revells CLA 2007-11-15 09:19:06 EST
This is how the flow figures work in GEF.  The preferred size uses up the whole width even if the text isn't that long.  I tried to avoid this by returning the preferred size as it used to be returned, but had other issues.  I will need to revisit this, but unfortunately it is not a simple fix.  

Would you like me to put the old WrapLabel back in the code so you can use that for now in the UML2Tools project?
Comment 2 Michael Golubev CLA 2007-11-15 10:42:06 EST
I digged into this code yesterday :), and I agree that there seems to be no easy  fixes. 

I have two suggestions, if possible, 
1. Yes, the resurrection of the old version of the WrapLabel would probably help.
2. Also, I would like to have some utility method in the new WrappingLabel that may calculate the "natural" preferred size of the figure. It would allow us to modify external layouter code to take into account preferredSize contract changes.

What do you think?

Regards, 
Michael

Comment 3 Cherie Revells CLA 2008-01-03 10:27:03 EST
Michael, the method WrappingLabel.getTextBounds() calculates the bounds of the label's text. This uses the label's complete text regardless of whether the text is currently truncated.  Is this sufficient for what you need?
Comment 4 Eclipse Webmaster CLA 2010-07-19 21:59:59 EDT
[GMF Restructure] Bug 319140 : product GMF and component
Runtime was the original product and component for this bug