Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Custom factory creates unwanted SWT widgets (I've registered a static custom factory method in SWT designer but it creates 2 widgets rather than 1)
Custom factory creates unwanted SWT widgets [message #792980] Tue, 07 February 2012 11:25 Go to previous message
Phil B is currently offline Phil B
Messages: 3
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 12:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic:Error: Could not find or load main class
Next Topic:Support for Eclipse 4 Parts planned?
Goto Forum:
  


Current Time: Fri May 24 11:57:17 EDT 2013

Powered by FUDForum. Page generated in 0.01795 seconds