Custom Layout [message #699351] |
Thu, 21 July 2011 12:21  |
Eclipse User |
|
|
|
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:

And this is what it should look like.

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 615 times)
|
|
|
Re: Custom Layout [message #699858 is a reply to message #699351] |
Fri, 22 July 2011 13:51   |
Eclipse User |
|
|
|
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.
|
|
|
|
Re: Custom Layout [message #703196 is a reply to message #701563] |
Wed, 27 July 2011 09:26   |
Eclipse User |
|
|
|
Looks like I've got everything but the FramingSpecs target properties working now.

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 408 times)
|
|
|
Re: Custom Layout [message #703521 is a reply to message #703196] |
Wed, 27 July 2011 16:51   |
Eclipse User |
|
|
|
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.
|
|
|
Re: Custom Layout [message #780206 is a reply to message #703521] |
Tue, 17 January 2012 11:21   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.05237 seconds