public class SWTComponentFactory extends java.lang.Object
TICComponent
.
The following example shows how to create SWT-specific GUI components from a TIC component.
// Create an instance of a TIC component: TICComponent ticComponent = new SomeComponent(); // Use this factory to create a TIC-specific instance from it: Composite swtComponent = SWTComponentFactory.getInstance().getSWTComponent(ticComponent, parentSWTComponent, SWT.NONE);See
#getSWTComponent(TICComponent, Composite, int)
for further details.
Note that it is alternatively possible to create a Swing component using info.bioinfweb.tic.SwingComponentFactory
and embed it into an SWT GUI using info.bioinfweb.commons.swt.SWTUtils.embedAWTComponent()
.
Modifier and Type | Method and Description |
---|---|
static SWTComponentFactory |
getInstance()
Returns the shared instance of this factory
|
org.eclipse.swt.widgets.Composite |
getSWTComponent(TICComponent ticComponent,
org.eclipse.swt.widgets.Composite parent,
int style,
java.lang.Object... additionalParameters)
Creates the SWT component that will be associated with the specified TIC component if it was not
created before.
|
void |
registerEventForwarders(TICComponent ticComponent,
org.eclipse.swt.widgets.Composite toolkitComponent,
ScrollingTICComponent scrollingComponent)
Registers SWT event forwarders to allow TIC components to receive events.
|
public static SWTComponentFactory getInstance()
public void registerEventForwarders(TICComponent ticComponent, org.eclipse.swt.widgets.Composite toolkitComponent, ScrollingTICComponent scrollingComponent)
This method is meant for internal use in TIC. It is usually not necessary to call it in application code directly.
ticComponent
- the TIC component to receive forwarded eventstoolkitComponent
- the SWT component that is the source of the input eventsscrollingComponent
- the TIC component acting as the scroll container or null
if ticComponent
is not contained within a scroll containerpublic org.eclipse.swt.widgets.Composite getSWTComponent(TICComponent ticComponent, org.eclipse.swt.widgets.Composite parent, int style, java.lang.Object... additionalParameters)
#getToolkitComponent()
from now
on.
Subsequent calls of this method will return the same instance again. The parameters specified in additional calls will therefore not be considered.
Note that this method can only be called if no Swing component has been created for the specified TIC component before.
ticComponent
- the TIC component for which an SWT component shall be createdparent
- a widget which will be the parent of the new instance (cannot be null)style
- the style of widget to constructadditionalParameters
- an optional list of parameters to be passed to
ticComponent.getSWTComponentClassName(Object...)
and
ticComponent.getSWTComponentConstructorParameters(Object...)
(Note that these parameters will not be passed to the component constructor. The parameters passed
there are determined by the return value of
TICComponent.getSWTComponentConstructorParameters(Object...)
.)java.lang.IllegalStateException
- if an Swing component has already been created for ticComponent
ToolkitSpecificInstantiationException
- if an error during the creation of the component occurs
(e.g. no constructor matching the necessary parameters was found)