Package de.aristaflow.adept2.ui.awtgui
Class SWTEmbeddedAWTContext
java.lang.Object
de.aristaflow.adept2.ui.awtgui.SWTEmbeddedAWTContext
- All Implemented Interfaces:
GUIContext,AWTContext,Closeable,AutoCloseable
This class makes it possible to integrate an application component with an
AWT-GUI into a SWT environment. It uses the AWT-SWT-bridge provided by the
eclipse foundation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Cleanup<RuntimeException>The clean-up for closing theSWTContextas post-mortem task for this instance.protected static final StringThe object descriptor for the clean-up registered forSWTEmbeddedAWTContextinstances.protected WeakReference<Thread>The thread which executes the application using this context.
To avoid memory leaks this is just a weak reference.protected org.eclipse.swt.widgets.CompositeThe SWT element that includes the AWT Frame the AWT component can insert its gui elements.protected FrameThe AWT Frame the AWT component can insert its GUI elements.protected SWTContextThe SWT context the AWT GUI could be integrated into -
Constructor Summary
ConstructorsConstructorDescriptionSWTEmbeddedAWTContext(Thread controlThread, SWTContext swtContext) Constructs an graphical context for an AWT based application component up on an existing swt graphical context. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the GUI for this context.Gets the parent frame of this context to use for the GUI of the application.
-
Field Details
-
CLEANUP_NAME
The object descriptor for the clean-up registered forSWTEmbeddedAWTContextinstances.- See Also:
-
swtContext
The SWT context the AWT GUI could be integrated into -
parentComposite
protected org.eclipse.swt.widgets.Composite parentCompositeThe SWT element that includes the AWT Frame the AWT component can insert its gui elements. -
parentFrame
The AWT Frame the AWT component can insert its GUI elements. -
controlThread
The thread which executes the application using this context.
To avoid memory leaks this is just a weak reference. The reference will be valid while the thread is running. Afterwards this GUI context becomes irrelevant. -
cleanup
The clean-up for closing theSWTContextas post-mortem task for this instance.
-
-
Constructor Details
-
SWTEmbeddedAWTContext
Constructs an graphical context for an AWT based application component up on an existing swt graphical context.- Parameters:
controlThread- The thread which executes the application using this context.
We must not keep a strong reference to this thread! Otherwise memory leaks may occur.swtContext- The existing SWT context.- See Also:
-
-
Method Details
-
getParentFrame
Description copied from interface:AWTContextGets the parent frame of this context to use for the GUI of the application.
AnInvalidExecutorThreadExceptionwill be thrown if the method is not called by the main thread of the corresponding component.- Specified by:
getParentFramein interfaceAWTContext- Returns:
- Returns the parent composite which should be used by the Component to draw its GUI.
-
close
public void close()Description copied from interface:GUIContextCloses the GUI for this context. This method has to be called by the runtime manager whenever an application has terminated (finished, failed, aborted, killed,...).
It must be possible to call this method more than once, even if the GUIContext has already shut down. This especially applies to the disposal of SWT-widgets, that is, it is allowed to call this method after the disposal of the corresponding widgets.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceGUIContext
-