Updated to 7.0, get "This Composite can not have Layout."

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Updated to 7.0, get "This Composite can not have Layout."

Postby vladdu » Thu Apr 09, 2009 2:44 am

Hi!

I upgraded to 7.0 and noticed that not everything can be opened anymore in the designer view. It complains about things similar to the following:

This Composite can not have Layout.
You attempt to set Layout for {new: org.eclipse.swt.custom.SashForm} ... {}, however by its design you should not do this or setLayout() method just implemented to do nothing. Please clean up your source and remove setLayout() invocation.


The same applies for example to the parent Composite received in createPartControl.

The code however works fine, so I wonder why is this happening. If it's not a bug, could you please point me to the place where these things are documented? Can something be done to disable these checks?

best regards,
Vlad
vladdu
 
Posts: 4
Joined: Thu Apr 09, 2009 2:31 am

Re: Updated to 7.0, get "This Composite can not have Layout."

Postby Eric Clayberg » Thu Apr 09, 2009 3:49 am

That is the correct error message. Allowing he user to set the layout on a SashForm was a bug in earlier versions because SashForms already have an implicit layout and will not accept a new one (see the source for SashForm setLayout() below). v7.0 adds a strong check to prevent this. Commenting out or removing the call to setLayout() will suppress the error message.

SashForm.png
SashForm.png (95.58 KiB) Viewed 517 times
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Updated to 7.0, get "This Composite can not have Layout."

Postby vladdu » Thu Apr 09, 2009 4:36 am

Thanks for the reply!

Does a similar explanation apply for the layout on the parent Composite received as argument to createPartControl? If yes, you might consider adding a QuickFix that wraps the existing widgets inside a Composite and set the layout on that one instead.

best regards,
Vlad
vladdu
 
Posts: 4
Joined: Thu Apr 09, 2009 2:31 am

Re: Updated to 7.0, get "This Composite can not have Layout."

Postby Eric Clayberg » Fri Apr 10, 2009 12:16 pm

vladdu wrote:Does a similar explanation apply for the layout on the parent Composite received as argument to createPartControl?

Yes. Both ViewPart and EditorPart set that composite to use a FillLayout.

vladdu wrote:If yes, you might consider adding a QuickFix that wraps the existing widgets inside a Composite and set the layout on that one instead.

Our ViewPart and EditorPart wizards both place a Composite within the one passed via the createPartControl() method.

Rather than a QuickFix, we have decided to remove the restriction in the latest buold and allow you to override the layout on that passed in Composite (which should be safe).
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests