Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TableLayout layouts too early
TableLayout layouts too early [message #895804] Mon, 16 July 2012 06:28 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
I suspect that most users of TableLayout applied to an SWT Table that is
used as the main control of an Eclipse view must have experienced the
following problem:

If the view containing the table is presented on initial startup of the
RCP client, the first-time layout of TableLayout often happens *before*
the view has reached its final size. The effect is that the widths of
all table columns look too small relative to the room left.

Since TableLayout is only applied a single time (and I don't want to
have a change of this behaviour), it looks like we need to catch an
appropriate UI event that should be used as a trigger of our code to
apply TableLayout to such a table.

Is anyone aware of such an event - presumably part of the
view/perspective lifecycle - that could be used for such a delayed layout?

Let me emphasize that I consider the actual layout behaviour of
TableLayout as correct and I don't want to have another Layout (unless
this has a better internal trigger for what "first time" is considered).

Thanks & Greetings from Bremen,

Daniel Krügler
Re: TableLayout layouts too early [message #895871 is a reply to message #895804] Mon, 16 July 2012 11:59 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
What about layout the table's parent composite like this
table creation...
Display.getDefault().asyncExec(new Runnable() {

    public void run() {
        if (!parent.isDisposed()) {
            parent.layout();  
        }
    }

});

But it means you apply the layout twice Confused
Re: TableLayout layouts too early [message #895900 is a reply to message #895871] Mon, 16 July 2012 13:08 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 2012-07-16 13:59, Jan Krakora wrote:
> What about layout the table's parent composite like this
>
> table creation...
> Display.getDefault().asyncExec(new Runnable() {
>
> public void run() {
> if (!parent.isDisposed()) {
> parent.layout(); }
> }
>
> });

This won't work, because at the point of the call of layout the first
layout has already happened and the "firstTime" flag will have been set
preventing a second one.

> But it means you apply the layout twice :?

Actually it is impossible to apply a TableLayout a second time (behaves
like a no-op). But your idea provides a possible approach: Just apply
the *initial* layout during the asyncExec call like so:

Display.getDefault().asyncExec(new Runnable() {

@Override
public void run() {
table.setLayout(tlayout);
table.layout();
}

});

Thanks for you help,

- Daniel
Re: TableLayout layouts too early [message #895967 is a reply to message #895900] Mon, 16 July 2012 16:44 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Ok, by the way I thought we are talking about the TableColumnLayout.

I haven't used the TableLayout yet. Embarrassed
Previous Topic:TreeViewer update specific column of element
Next Topic:CNF, Project explorer customization.
Goto Forum:
  


Current Time: Tue Mar 19 05:14:09 GMT 2024

Powered by FUDForum. Page generated in 0.02868 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top