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

Bug 377633

Summary: API to know how much space editor needs to display whole file
Product: [ECD] Orion Reporter: Szymon Brandys <Szymon.Brandys>
Component: GitAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: libingw, Silenio_Quarti
Version: 0.2   
Target Milestone: 0.5 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Illustration none

Description Szymon Brandys CLA 2012-04-25 10:06:05 EDT
On git commit and status pages I always allocate the same amount of space for compare views (around 500px), no matter how big the file is. It may end up as shown on the screenshot. I need a way to check how much space is needed to show whole file. Based on that I can allocate space better.
Comment 1 Szymon Brandys CLA 2012-04-25 10:07:27 EDT
Created attachment 214532 [details]
Illustration
Comment 2 Silenio Quarti CLA 2012-04-25 12:13:27 EDT
API already exists:

textView.computeSize()

Note that calling this API on a large file is very slow because it has to render HTML and measure all the lines.  If you just care about the height of the widget, it might be ok to do something like this:

textView.getLineHeight() * Math.min(some maximum number of lines, text.getModel().getLineCount())
Comment 3 libing wang CLA 2012-04-25 16:47:37 EDT
I think it will be chicken-egg issue if you want to know it before you create the widget.
Szymon, I think you can always create the compare widget by passing a DIV with minimal height.
So in the callback when widget is loaded(currently the function where you create the next widget), I will pass the height(in pixel) required to the callback. You decide how tall the parent DIV should be and resize it before you create the next one.
Make sense?
Comment 4 Szymon Brandys CLA 2012-04-29 05:32:25 EDT
Makes sense. So the callback will pass a result param or something like that, right?
Comment 5 libing wang CLA 2012-05-18 09:17:26 EDT
(In reply to comment #4)
> Makes sense. So the callback will pass a result param or something like that,
> right?

Right. And I think all the embedded compare widget in a section need this to save space. 

There is already a callback in CompareContainer.startup(callback) used in gitCommitExplorer. I will pass an object back to the callback function. The object will only contain .widgetMaxHeight property for now but we can add more properties later.
Comment 6 libing wang CLA 2012-05-22 13:50:13 EDT
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=a5d666db07c8142944becf9aae8506cb256721d8.

Applied the parameter to  both commit and status pages.