Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Custom Layout
Custom Layout [message #699351] Thu, 21 July 2011 12:21 Go to next message
Rayleigh Missing name is currently offline Rayleigh Missing nameFriend
Messages: 20
Registered: July 2011
Junior Member
I tried to add our custom STLayout to window builder but it does not render correctly.
I also tried another Layout with simpler constraints which did render correctly in WindowBuilder.

This is what it looks like in window builder:
http://imageshack.us/photo/my-images/15/istq.png

And this is what it should look like.
http://imageshack.us/photo/my-images/26/sollf.png

This is what I've done to add the new Layout:
- create a plugin project with STLayoutInfo and STLayoutEditPolicy. These classes do nothing yet but the other CustomLayout I tried showed up fine with empty Info and Policy.
- create the component description: STLayout.wbp-component.xml

The attachement contains 2 workspaces:
- WindowBuilderSTLayout: Contains the com.shark.eclipse.wb.swing.STLayout Plugin Project and the STLayout
- WindowBuilderSTLayoutEclipseApplication: The Eclipse Run Application workspace with the Layout Test class.
  • Attachment: STLayout.zip
    (Size: 180.21KB, Downloaded 571 times)
Re: Custom Layout [message #699858 is a reply to message #699351] Fri, 22 July 2011 13:51 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
WindowBuilder executes method invocations and field assignments only for know objects, such as components or known layout constraints.
Your FramingSpec is not know for standard WindowBuilder.
You should tell WindowBuilder that this class belongs to Swing toolkit.
Put into wbp-meta, in same package as STLayout.wbp-component.xml, new file FramingSpec.wbp-forced-toolkit.txt, with content "org.eclipse.wb.swing" (i.e. ID of Swing toolkit). After this WindowBuilder will create model for it, execute field assignments and even allow to edit properties.


Konstantin Scheglov,
Google, Inc.
Re: Custom Layout [message #701563 is a reply to message #699351] Mon, 25 July 2011 08:56 Go to previous messageGo to next message
Rayleigh Missing name is currently offline Rayleigh Missing nameFriend
Messages: 20
Registered: July 2011
Junior Member
works.
thank you!
Re: Custom Layout [message #703196 is a reply to message #701563] Wed, 27 July 2011 09:26 Go to previous messageGo to next message
Rayleigh Missing name is currently offline Rayleigh Missing nameFriend
Messages: 20
Registered: July 2011
Junior Member
Looks like I've got everything but the FramingSpecs target properties working now.
http://gebackene-ente.at/shark/constraint_needs_target_components.png
The properties
Component leftTarget;
Component rightTarget;
Component topTarget;
Component bottomTarget;

are missing.
How can I add them with an property editor that shows a list of all components inside the layout?

At first I tried to make an EnumerationValuesPropertyEditor and switch the properties default editor ( in FramingSpecInfo.addConstraintsProperties() ) but the property editor can't be changed.
  • Attachment: STLayout.zip
    (Size: 186.35KB, Downloaded 372 times)
Re: Custom Layout [message #703521 is a reply to message #703196] Wed, 27 July 2011 16:51 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Look into JLabel.wbp-component.xml, how it uses
<property-tag name="labelFor" tag="useObjectEditor" value="true"/>

to allow Component selection editor. If this is still not exactly what you want, look on org.eclipse.wb.internal.swt.model.layout.form.ControlSelectionPropertyEditor - it is for SWT and Control, but it should be easy to adapt for Swing.


Konstantin Scheglov,
Google, Inc.
Re: Custom Layout [message #780206 is a reply to message #703521] Tue, 17 January 2012 11:21 Go to previous messageGo to next message
Rayleigh Missing name is currently offline Rayleigh Missing nameFriend
Messages: 20
Registered: July 2011
Junior Member
I've got a problem with moving components from one Container to another:

This is how the code for a Button in a Container with STLayout and a FramingSpec Constraint looks like:
JButton btnNewButton = new JButton("Button");
FramingSpec framingSpec_4 = new FramingSpec();
framingSpec_4.setBottomEdge(47);
framingSpec_4.setTopEdge(5);
framingSpec_4.setRightEdge(36);
framingSpec_4.setBottomEdgeAttachment(FramingSpec.XmATTACHPOSITION);
framingSpec_4.setTopEdgeAttachment(FramingSpec.XmATTACHPOSITION);
framingSpec_4.setRightEdgeAttachment(FramingSpec.XmATTACHPOSITION);
framingSpec_4.setLeftEdgeAttachment(FramingSpec.XmATTACHPOSITION);
framingSpec_4.setLeftEdge(6);
panel.add(btnNewButton, framingSpec_4);


If that Button is moved into a container with a BorderLayout, the FramingSpec constraint will not be removed from the code:
JButton btnNewButton = new JButton("Button");
panel_2.add(btnNewButton, BorderLayout.CENTER);
FramingSpec framingSpec_4 = new FramingSpec();
framingSpec_4.setBottomEdge(47);
...


If it is moved into another container with STLayout, the association will be generated before the declaration of the constraint:
JButton btnNewButton = new JButton("Button");
panel_1.add(btnNewButton, framingSpec_4);
FramingSpec framingSpec_4 = new FramingSpec();
framingSpec_4.setBottomEdge(33);
...


How can I remove the Constraint during a move and how can I ensure, that the association will be created after declaration of the constraint?
Re: Custom Layout [message #780232 is a reply to message #780206] Tue, 17 January 2012 12:18 Go to previous message
Rayleigh Missing name is currently offline Rayleigh Missing nameFriend
Messages: 20
Registered: July 2011
Junior Member
Looks like
getConstraint(component).delete();
super.removeComponentConstraints(getContainer(), component);

does the job ( thanks, GridBagLayout ), but there is still the issue with the association beeing generated before the declaration of the constraint.
Previous Topic:How to prevent WindowBuilder from making a child components children editable?
Next Topic:Compiler classpath is not being picked up in IvyIDE project
Goto Forum:
  


Current Time: Fri Apr 19 07:15:01 GMT 2024

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

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

Back to the top