Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328297 - need a way to initialize the width of columns, similar to initialzie the columns in IColumnPresentation
Summary: need a way to initialize the width of columns, similar to initialzie the colu...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7 M6   Edit
Assignee: Pawel Piech CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2010-10-20 17:06 EDT by Winnie Lai CLA
Modified: 2011-05-26 14:27 EDT (History)
4 users (show)

See Also:
Michael_Rennie: review+


Attachments
patch of this enhancement (5.99 KB, patch)
2011-01-21 13:47 EST, Winnie Lai CLA
pawel.1.piech: iplog+
Details | Diff
testcase (12.25 KB, text/plain)
2011-01-26 17:36 EST, Winnie Lai CLA
no flags Details
testcase2 (13.42 KB, text/plain)
2011-01-27 13:53 EST, Winnie Lai CLA
pawel.1.piech: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Winnie Lai CLA 2010-10-20 17:06:13 EDT
Build Identifier: 3.6.1

In org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation, I can specify my initial columns through getInitialColumns().
I need to specify my initial widths as well either through this interface or its derived interface.

The org.eclipse.debug.internal.ui.viewers.model.InternalTreeModelViewer protected void buildColumns(IColumnPresentation presentation) method gets the initial columns from IColumnPresentation, but it computes the inital column widths using an average approach (if not restored from memento) as coded in its private void initColumns(int widthHint) method.

The average approach makes a view of 4 columns in a tree widget width of 193 end up having each column width of 72. This is too less for the name column in a variables view or expression view for variables that has recursive nested variables. Users have to resize columns to see the tree of var.


The method may look like this,
    int[] getInitialWidths(int treeWidgetWidth).
And the InternalTreeModelViewer calls this method with treeWidegtWidth being tree2.getSize().x.

This flexiblity enables viewer model provider to specify its logic of computing the initial column width.



Reproducible: Always
Comment 1 Pawel Piech CLA 2010-10-20 19:27:38 EDT
I think its fair to call this an enhancement.  Also if we were to start messing with column widths it seems that we should also have a mechanism to persist the user changes to them.
Comment 2 Winnie Lai CLA 2011-01-21 13:47:29 EST
Created attachment 187309 [details]
patch of this enhancement

The change is small and backward compatible.
A new interface IColumnPresentation2 is added and InternalTreeModelViewer is modified.

IColumnPresentation2 is optional. If a view model does not implement this interface, the behavior is same as before this patch is applied.

The only time that InternalTreeModelViewer uses IColumnPresentation2.getInitialColumnWidth is when fColumnSizes does not store the width of a given column. This ensures we do not mess up user settings and memento.
Also, if IColumnPresentation2.getInitialColumnWidth returns -1, InternalTreeModelViewer will use the average width as before.
Comment 3 Winnie Lai CLA 2011-01-21 14:00:36 EST
Could someone please review this change ASAP? I want to make sure this change can be merged before eclipse 3.7 API is frozen. thanks.
Comment 4 Pawel Piech CLA 2011-01-21 16:48:06 EST
(In reply to comment #3)
> Could someone please review this change ASAP? I want to make sure this change
> can be merged before eclipse 3.7 API is frozen. thanks.

Smart thinking, and thanks for the patch!  It'll be easiest if we can get this in for M5 (i.e. end of next week).  Although this is a small change so I think we could still swing it in M6 with more paperwork.

I have one request though.  I'd rather not put in an API without a use case where it can be tested.  Also I've made a big effort to unit-test the flex hierarchy viewer as much as possible.  So can you try to write a unit test for this feature?  If a unit test turns out impossible, then an extension to the PDA example would be good enough to let us test this manualy.
Comment 5 Pawel Piech CLA 2011-01-26 11:17:08 EST
M5 is this week after all, will look at this for M6.
Comment 6 Winnie Lai CLA 2011-01-26 17:36:27 EST
Created attachment 187695 [details]
testcase

add unit test case as requested
Comment 7 Winnie Lai CLA 2011-01-27 13:53:28 EST
Created attachment 187762 [details]
testcase2

Please ignore testcase, and use testcase2 that contains up-to-date test cases.
Comment 8 Pawel Piech CLA 2011-02-16 16:53:34 EST
I committed the interface extension and the tests.  I had to modify the tests because they didn't work on my Linux system.
Comment 9 Michael Rennie CLA 2011-02-24 15:03:07 EST
verified.

I updated the copyrights of IColumnPresentation2 and implemented IColumnPresentation2 in AbstractColumnPresentation (does nothing, just consuming the new API).