public interface ControlWrapper
Control
to encapsulate its API.
The traditional way to make a custom class is this: class CustomControl extends
Composite
This has three main problems:
Composite
interface.Composite
interface.Widget.addListener
to intercept them is a very dangerous plan.ControlWrapper fixes this by providing an low-overhead skeleton which encapsulates the SWT Control that you're using as the base of your custom control, which allows you to only expose the APIs that are appropriate.
Modifier and Type | Interface and Description |
---|---|
static class |
ControlWrapper.AroundControl<T extends Control>
Default implementation of a
ControlWrapper which wraps a Control . |
static class |
ControlWrapper.AroundWrapper<T extends ControlWrapper>
Default implementation of a
ControlWrapper which wraps some other form of `ControlWrapper` with a new interface. |
Modifier and Type | Method and Description |
---|---|
default Object |
getLayoutData()
Returns the LayoutData for this control.
|
default Composite |
getParent()
Returns the parent of this Control.
|
Control |
getRootControl()
Returns the wrapped
Control (only appropriate for limited purposes!). |
default Shell |
getShell()
Returns the parent Shell of this Control.
|
default void |
setLayoutData(Object layoutData)
Sets the LayoutData for this control.
|
default void setLayoutData(Object layoutData)
default Object getLayoutData()
default Composite getParent()
default Shell getShell()
Control getRootControl()
Control
(only appropriate for limited purposes!).
The implementor of this ControlWrapper is free to change the wrapped Control as she sees fit, and she doesn't have to tell you about it! You shouldn't rely on this control being anything in particular.
You can rely on this Control for:
But that's all. If you use it for something else, it's on you when it breaks.