W
- base class of widgets that this Layout lays outC
- base class of container widgets. Many UI frameworks make a
distinction between 'container widgets' (ie. Panels) and widgets
that cannot contain child controls (ie. TextBox). For frameworks
that don't make such a distinction, W and C can be the sameM
- Metawidget that supports this Layoutpublic interface Layout<W,C extends W,M extends C> extends Immutable
Layouts must be immutable (or, at least, appear that way to clients. They can have caches or configuration settings internally, as long as they are threadsafe). If they need to store state, they should use the Metawidget passed to each method.
Don't be put off by having so many parameterized types! Metawidget needs them so that it can present a consistent API across many architectures. However this complication doesn't impact your own custom plugins because you're able to substitute concrete, platform-specific values for each parameter (i.e. Control, Composite, SwtMetawidget ).
Modifier and Type | Method and Description |
---|---|
void |
layoutWidget(W widget,
String elementName,
Map<String,String> attributes,
C container,
M metawidget)
Layout the given widget within the given container, using the given
elementName and attributes as a guide and the given Metawidget to access
additional services if needed (such as state saving)
|
void layoutWidget(W widget, String elementName, Map<String,String> attributes, C container, M metawidget)
layoutWidget is called immediately after WidgetBuilder.buildWidget and WidgetProcessor.processWidget, and before the next widget is generated. An alternate design would be to 'collect' all widgets generated by buildWidget and processWidget, then iterate over them separately for the layout. If you prefer this approach, you can simulate it by having layoutWidget do nothing but 'remember' each widget, then iterate over them in endContainerLayout (see the AdvancedLayout interface). However not all UI frameworks allow this approach, because they do not suport widgets being instantiated independent of a layout, nor moved between layouts (e.g. SWT)
widget
- the widget to layout. Never nullelementName
- XML node name of the business field. Typically 'entity',
'property' or 'action'. Never nullattributes
- attributes of the widget to layout. Never null. This Map is
modifiable - changes will be passed to subsequent
WidgetProcessors and Layoutscontainer
- the container to add to. This is often the same as the given
Metawidgetmetawidget
- the Metawidget to use to access additional services. Never
nullCopyright © 2015. All Rights Reserved.