Custom factory creates unwanted SWT widgets [message #792980] |
Tue, 07 February 2012 16:25  |
Eclipse User |
|
|
|
I've created a static widget factory and have added the factory method to the palette in SWT Designer.
When I try to use it to add a widget to a SectionPart, by dragging the factoryMethod icon from the palette to the GUI design pane then overtyping the name of the widget, I get 2 widgets, 1 correctly formed one created using the factory method and a 2nd anonymous one created with default arguments.
I've noticed that if I don't change the name of the widget I just get the factory created widget, but of course it has the wrong name.
Can anyone tell me what I'm doing wrong?
I've just installed the latest windowbuilder and it still happens.
The code I get looks like this:
...
Label lblNewlabel = PhilsLabelFactory.createLabel(container, Messages.MultiColumnEditorSectionPart_lblNewlabel_text);
new Label(container, SWT.NONE);
...
the factory looks like this:
...
package phil.example.layout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
public final class PhilsLabelFactory {
/**
* @wbp.factory
* @wbp.factory.parameter.source text "default"
*/
public static Label createLabel(Composite parent, String text) {
Label label = new Label(parent, SWT.NONE);
label.setText(text);
return label;
}
/**
* @wbp.factory
*/
public static Button createButton(Composite parent) {
Button button = new Button(parent, SWT.CHECK);
return button;
}
}
...
Thanks
Phil
[Updated on: Tue, 07 February 2012 17:55] by Moderator Report message to a moderator
|
|
|
Re: Custom factory creates unwanted SWT widgets [message #793051 is a reply to message #792980] |
Tue, 07 February 2012 18:06   |
Eclipse User |
|
|
|
It would useful to see a complete test case. Depending on the layout manager you are using and where you dropped the widget, those results could be entirely expected. The second, blank Label looks like a simple spacer widget used in a GridLayout.
If you create a panel using absolute layout, do you see the same thing happen (e.g., two widgets created)?
|
|
|
|
Powered by
FUDForum. Page generated in 0.05761 seconds