Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Unlogical layouting
Unlogical layouting [message #511169] Sat, 30 January 2010 17:53 Go to next message
Simon L. is currently offline Simon L.
Messages: 22
Registered: January 2010
Junior Member
Hello,
I created a wizardpage with a few containers on it, including a customized composite wich includes a Table (the composite is extended because extending the Table is forbidden).

I create every single object in the createControl of the Wizardpage. Changing some control's selections causes a preview of the changes in the data i described above, by calling a preview() method.

Now, when I start the Wizard, I change a control's selection, and the preview() method happens. Columns and Items populate the Table, everything works out fine. A screenshot is here:
http://screencast.com/t/YTBkYmQz

Now I want the preview happening on startup, so i call it at the very end of the createControl Method. Now, with nothing changed but this, it looks like this:
http://screencast.com/t/NTMxMzJhN

The only thing that changed was that the time the preview method was called. As far as I see, the layout happened before the preview method call in both cases, but in the second case, the table/the composite containing the table resized to how much columns are there, in the first case it just shows a scrollbar. (And I want it to do this).

The code is here:
The WizardPage (TranspTextWizardPage.java): http://pastebin.com/m2ebb178b
The Composite holding the table (TranspositionTable.java): http://pastebin.com/m1e83fdf6

I tried 2 hours to find my mistake, but wasn't lucky :/ Every help very much appreciated!!
Re: Unlogical layouting [message #511437 is a reply to message #511169] Mon, 01 February 2010 15:38 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2151
Registered: July 2009
Senior Member
Hi,

When a control is being laid out it is asked for its preferred size, which
is the size that it would take to fully display its content. In your first
case I think that the Table is empty at layout time, so it answers a
preferred size of 64x64, and is then grown by the layout to fill the page's
available width. However in your second case, the preview() invocation at
the end of TranspTextWizardPage.createControl() gives the Table its initial
content, but the Table is not actually laid out until after
TranspTextWizardPage.createControl() has returned. As a result the Table
answers a much wider preferred size, and the wizard page grows accordingly.
There are two possibilities for fixing this:

1. Specify a widthHint for the Table, similar to the heightHint that is
already being specified.
2. Call preview() a bit later. For instance, is there another wizard page
method that you can override, that is invoked by the framework just after
layout has completed? Or, asyncExec()'ing the preview() call would probably
work, though it's not an ideal approach. This would look something like:

transpositionTable1.getDisplay().asyncExec(new Runnable() {
public void run() {
if (transpositionTable1.isDisposed()) return;
preview();
}
});

HTH,
Grant


"Simon L." <abcba1307@yahoo.de> wrote in message
news:hk1rmj$9on$1@build.eclipse.org...
> Hello,
> I created a wizardpage with a few containers on it, including a customized
composite wich includes a Table (the composite is extended because extending
the Table is forbidden).
>
> I create every single object in the createControl of the Wizardpage.
Changing some control's selections causes a preview of the changes in the
data i described above, by calling a preview() method.
>
> Now, when I start the Wizard, I change a control's selection, and the
preview() method happens. Columns and Items populate the Table, everything
works out fine. A screenshot is here:
> http://screencast.com/t/YTBkYmQz
>
> Now I want the preview happening on startup, so i call it at the very end
of the createControl Method. Now, with nothing changed but this, it looks
like this:
> http://screencast.com/t/NTMxMzJhN
>
> The only thing that changed was that the time the preview method was
called. As far as I see, the layout happened before the preview method call
in both cases, but in the second case, the table/the composite containing
the table resized to how much columns are there, in the first case it just
shows a scrollbar. (And I want it to do this).
>
> The code is here:
> The WizardPage (TranspTextWizardPage.java): http://pastebin.com/m2ebb178b
> The Composite holding the table (TranspositionTable.java):
http://pastebin.com/m1e83fdf6
>
> I tried 2 hours to find my mistake, but wasn't lucky :/ Every help very
much appreciated!!
Re: Unlogical layouting [message #511558 is a reply to message #511437] Tue, 02 February 2010 00:43 Go to previous message
Simon L. is currently offline Simon L.
Messages: 22
Registered: January 2010
Junior Member
Hey, Grant,
thanks for helping me with mey 2nd problem now Smile
I tried to set a widthHint, and it worked. Thanks!
Previous Topic:TrayItem and ToolTip bug on Ubuntu
Next Topic:problem with setSelection() for Graphical view
Goto Forum:
  


Current Time: Sun Oct 26 03:46:25 GMT 2014

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

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