Bug 93611 - [Viewers] Please refactor TableLayout to behave like standard layout
Summary: [Viewers] Please refactor TableLayout to behave like standard layout
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: 3.3 M3   Edit
Assignee: Thomas Schindl CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 95030 96285 (view as bug list)
Depends on: 13467 96440
Blocks:
  Show dependency tree
 
Reported: 2005-05-04 00:10 EDT by Stefan Xenos CLA
Modified: 2006-12-13 13:00 EST (History)
10 users (show)

See Also:


Attachments
Implementation from bug #13467 (5.48 KB, text/plain)
2006-10-10 10:54 EDT, Thomas Schindl CLA
no flags Details
Snippet to test (8.73 KB, text/plain)
2006-10-10 10:58 EDT, Thomas Schindl CLA
no flags Details
Fixed copyright (5.23 KB, text/plain)
2006-10-10 11:03 EDT, Thomas Schindl CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2005-05-04 00:10:27 EDT
TableLayout doesn't follow the expected protocol of a layout.

1. It only lays out once, and ignores subsequent changes in size.
2. Setting a Table to size A followed by size B will result in a different
layout than setting it to size C followed by size B. (Layouts should be purely a
function of the current size, and should not be affected by previous sizes)
3. If the widget is never given a nonzero size, it will never initialize the
column widths.

This layout behaves more like a deferred column initializer than a layout,
causing bug 86329 in the problems view and bug 41800 in the PDE error view. Both
views now contain workarounds, but it would be nice if this extra code was not
necessary.
Comment 1 Douglas Pollock CLA 2005-05-11 12:32:31 EDT

*** This bug has been marked as a duplicate of 94467 ***
Comment 2 Veronika Irvine CLA 2005-05-13 08:29:03 EDT
This is not really a duplicate of bug 94467.   There is a real problem with TableLayout.  There is a 
lengthy discussion of this problem in Bug 13467.
Comment 3 Kim Horne CLA 2005-05-13 10:22:21 EDT
*** Bug 95030 has been marked as a duplicate of this bug. ***
Comment 4 Kim Horne CLA 2005-05-13 10:25:02 EDT
Should this be marked as an enhancement?  This seems like a real issue we should deal with for 3.1.
Comment 5 Stefan Xenos CLA 2005-05-13 11:50:31 EDT
I flagged it as an enhancement to avoid a debate about what is a bug and what is
permissable intended behavior. Boosting severity to minor.
Comment 6 Michael Valenta CLA 2005-05-13 11:55:33 EDT
Upping to normal since my bug was marked as a duplicate although I'm starting 
to think that this is actually fairly major. Getting tables to layout 
shouldn't be as difficult as it is now. We have some overly complicated table 
column code in Team/CVS preference pages all because the table weighting 
doesn't work.
Comment 7 Kim Horne CLA 2005-05-13 11:58:46 EDT
I agree.  I actually logged quite a few bugs this release relating to bogus table layouts... 
Comment 8 Michael Valenta CLA 2005-05-20 13:53:20 EDT
*** Bug 96057 has been marked as a duplicate of this bug. ***
Comment 9 Darin Swanson CLA 2005-05-23 11:33:46 EDT
Can we please get an indication of the plan on this bug for 3.1.

The Ant preference pages were working and then the layout stopped working.

So either this is a breaking change OR a guide should be provided on what we 
were doing wrong and why that no longer works and how to fix it.
Comment 10 Darin Swanson CLA 2005-05-23 11:33:56 EDT
*** Bug 96285 has been marked as a duplicate of this bug. ***
Comment 11 Philippe Ombredanne CLA 2005-05-23 11:50:13 EDT
And just to add my 2c. This small issue makes playing with CVS tagging and
branching quite dangerous, as you may not be able to see the full tag names
(when you have long tage names) and therefore ruin your branching/tagging.
Comment 12 Tod Creasey CLA 2005-05-24 09:35:46 EDT
We haven't made any significant changes to this since 2003 (Nick added some trim
code for Bug 90712). Veronika is there potentially some SWT Table changes
causing this?
Comment 13 Nick Edgar CLA 2005-05-24 11:00:53 EDT
TableLayout has always been used as a deferred column initializer, not a true
layout.  I don't think we should change it for 3.1, since existing clients
expect the initial layout only.

Stefan, since TableLayout has not changed in 3.1 (except for the trim thing),
can you explain what changes led to the regressions in the Error Log and Ant
pref pages?  I understand that bug 75945 explains the marker view cases, but
what about the others?
Comment 14 Nick Edgar CLA 2005-05-24 11:01:34 EDT
It seems like views using TableLayout should not persist the column widths if
they are 0 (i.e. TableLayout hasn't done its thing yet).
Comment 15 Tod Creasey CLA 2005-05-24 11:12:28 EDT
The bugs this was marked as a dup of are different - this is a behavioural
change request rather than a layout error.

The layout error is described in Bug 96440
Comment 16 Veronika Irvine CLA 2005-05-24 11:21:00 EDT
As mentioned in Bug 13467, you can not really use a Layout to get 
proportionally sized columns.  The problem is that the sizing has to occur 
before the parent has changed size.  This is necessary to avoid scrollbars 
appearing then disappearing when the columns are resized.  By the time the 
layout is invoked on the Table it is too late.

As described in Bug 13467, the solution is to add a Resize listener to the 
parent of the Table and resize the columns in the resize listener.  The code 
showing how to do this is in Bug 13467.

SWT is not planning to make any changes to Table that would change this.
Comment 17 Michael Valenta CLA 2005-05-24 12:03:15 EDT
Interesting. Is it possible that the TableLayout in JFace only worked for the 
initial table layout and not for resizes? It turns out that JDT rolled their 
own solution for this (org.eclipse.jdt.internal.ui.util.TableLayoutComposite). 
I've tried it out in a few of the CVS scenarios and it works. The only problem 
is that the class works when used as the parent composite. I'll look into the 
possibility of incorporating the component resize listener into TableViewer so 
exisiting clients will be fixed without writing additional code.
Comment 18 Tod Creasey CLA 2005-05-24 13:07:34 EDT
Yes - that is the gist of the original part of this report.
Comment 19 Tod Creasey CLA 2005-05-24 13:10:15 EDT
BTW Veronika can you explain why the Ant Runtime page was getting an acceptible
size in M6 and aren't now? Was it an SWT change or a change in thier code?
Comment 20 Tod Creasey CLA 2005-05-24 13:19:12 EDT
See Bug 96440 for a description of the sizing issues I am seeing. I have just
checked and there has been no significant change to either the TableLayout or
AntPage since M6.
Comment 21 Michael Valenta CLA 2005-05-24 13:28:43 EDT
Tod, many of the problems we have seen have been with preference pages. Was 
there a change in how preference pages are created? Could it be possible that 
in M6, they were being created at an initial size that made the tables appear 
OK but in M7 they were originally created small and then resized which would 
surface the shortcomings of TableLayout?
Comment 22 Veronika Irvine CLA 2005-05-24 13:41:52 EDT
As discussed in Bug 94467, there was a resize event even though the client 
area was still of size (0,0).  I believe this was introduced after M6 and has 
been fixed for M7.  The TableLayout code does not guard against an initial 
resize event to a width that is too small to be usable - it never has.
Comment 23 Nick Edgar CLA 2005-05-24 14:10:22 EDT
Actually, TableLayout.layout has had the following for quite some time (since
rev 1.1):

        int width = table.getClientArea().width;

        // XXX: Layout is being called with an invalid value the first time
        // it is being called on Linux. This method resets the
        // Layout to null so we make sure we run it only when
        // the value is OK.
        if (width <= 1)
            return;
Comment 24 Michael Valenta CLA 2005-05-24 14:36:02 EDT
Ha!!! I changed that line to this and it works!

        if (width <= 1 || table.getClientArea().height <= 1)
            return;

Not sure how valid it is but it may be something.
Comment 25 Michael Valenta CLA 2005-05-24 14:39:50 EDT
Oops, sorry, ignore my last post. I had a bunch of changes in my workspace so 
it was something else that worked (but not entirely). I'll shut up now and 
stop bombarding people with spam.
Comment 26 Tod Creasey CLA 2006-10-10 10:53:50 EDT
Assigning to Tom and adding myself to the cc. I did an initial pass of this in Bug 13467 which Tom has tidied up.
Comment 27 Thomas Schindl CLA 2006-10-10 10:54:42 EDT
Created attachment 51696 [details]
Implementation from bug #13467
Comment 28 Thomas Schindl CLA 2006-10-10 10:58:53 EDT
Created attachment 51697 [details]
Snippet to test
Comment 29 Thomas Schindl CLA 2006-10-10 11:03:47 EDT
Created attachment 51698 [details]
Fixed copyright
Comment 30 Tod Creasey CLA 2006-10-10 12:49:32 EDT
Patch released for build >20061010. I renamed the class to TableAdapter as it is not really tied to the TableLayout but is a subclass of the ControlAdapter.

I have also added a reference to TableAdapter in the TableLayout class comment.
Comment 31 Benjamin Pasero CLA 2006-10-11 04:58:09 EDT
Thanks!

Is there plans to release a TreeAdapter as well? I assume its just a matter of changing the TableAdapter to work with a Tree and TreeColumns.
Comment 32 Thomas Schindl CLA 2006-10-11 05:01:23 EDT
I'll look into it my feeling is that TableAdapter should be renamed to ColumnAdapter and work for both Table and Tree.
Comment 33 Tod Creasey CLA 2006-10-11 08:07:11 EDT
That would depend on time to work on it (I had already written most of this when Tom finished it up for me). If you wanted to do the Tree version and submit a patch I would be happy to review it (in a seperate Bug).
Comment 34 Benjamin Pasero CLA 2006-10-11 10:20:59 EDT
(In reply to comment #32)
> I'll look into it my feeling is that TableAdapter should be renamed to
> ColumnAdapter and work for both Table and Tree.

Yes, I was looking for something like that. 

Comment 35 Thomas Schindl CLA 2006-10-11 12:30:57 EDT
(In reply to comment #34)
> (In reply to comment #32)
> > I'll look into it my feeling is that TableAdapter should be renamed to
> > ColumnAdapter and work for both Table and Tree.
> 
> Yes, I was looking for something like that. 
> 

Please look in bug #160505 to see a widget independent implementation.
Comment 36 Benjamin Pasero CLA 2006-10-11 12:50:45 EDT
(In reply to comment #35)
> (In reply to comment #34)
> > (In reply to comment #32)
> > > I'll look into it my feeling is that TableAdapter should be renamed to
> > > ColumnAdapter and work for both Table and Tree.
> > 
> > Yes, I was looking for something like that. 
> > 
> 
> Please look in bug #160505 to see a widget independent implementation.
> 

Great! Would be nice to have it added to M3 :)

Comment 37 Boris Bokowski CLA 2006-10-11 23:46:57 EDT
Tom, could you have a look at TableLayoutComposite (part of org.eclipse.jdt.ui)?  It seems JDT/UI already had something like this, but not as API. Their code was written three years ago, so it's probably well tested.  We should at least look at bugs referenced in the revision history of this file, as well as go through their code and comments to see if there is anything we haven't thought of yet.
Comment 38 Thomas Schindl CLA 2006-10-12 10:50:02 EDT
(In reply to comment #37)
> Tom, could you have a look at TableLayoutComposite (part of
> org.eclipse.jdt.ui)?  It seems JDT/UI already had something like this, but not
> as API. Their code was written three years ago, so it's probably well tested. 
> We should at least look at bugs referenced in the revision history of this
> file, as well as go through their code and comments to see if there is anything
> we haven't thought of yet.
> 

I'll look at it and try to find out what's done there.