Package org.eclipse.jface.widgets
Class AbstractWidgetFactory<F extends AbstractWidgetFactory<?,?,?>,W extends Widget,P extends Widget>
java.lang.Object
org.eclipse.jface.widgets.AbstractWidgetFactory<F,W,P>
- Type Parameters:
F
- factoryW
- widgetP
- parent
- Direct Known Subclasses:
AbstractControlFactory
,AbstractItemFactory
@NoExtend
public abstract class AbstractWidgetFactory<F extends AbstractWidgetFactory<?,?,?>,W extends Widget,P extends Widget>
extends Object
Abstract factory for widgets. Factories for widgets that inherit from Widget
should extend this factory to handle creation of widgets and setting all the
properties.
- Since:
- 3.18
-
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addProperty
(Property<W> property) Adds a property like image, text, enabled, listeners, ... to the widget.protected final F
cast
(AbstractWidgetFactory<F, W, P> factory) Casts to the concrete instance of factory class.final W
Sets the application defined widget data associated with the receiver to be the argument.Sets the application defined property of the receiver with the specified name to the given value.
-
Method Details
-
cast
Casts to the concrete instance of factory class. Needs to be called by abstract factory classes.- Parameters:
factory
- extending WidgetFactory, usually "this"- Returns:
- casted factory
-
create
- Returns:
- this
-
addProperty
Adds a property like image, text, enabled, listeners, ... to the widget.
Example:public LabelFactory text(String text) { addProperty(l -> l.setText(text)); return this; }
- Parameters:
property
- usually a lambda
-
data
Sets the application defined widget data associated with the receiver to be the argument. The widget data is a single, unnamed field that is stored with every widget.- Parameters:
data
- the widget data- Returns:
- this
- Since:
- 3.21
- See Also:
-
data
Sets the application defined property of the receiver with the specified name to the given value.- Parameters:
key
- the name of the propertyvalue
- the new value for the property- Returns:
- this
- Since:
- 3.33
- See Also:
-