Custom factory creates unwanted SWT widgets [message #792980] |
Tue, 07 February 2012 16:25 |
Phil B Messages: 7 Registered: February 2012 |
Junior Member |
|
|
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] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03684 seconds