Package de.aristaflow.adept2.ui.awtgui
Class SWTEmbeddedAWTContext
- java.lang.Object
-
- de.aristaflow.adept2.ui.awtgui.SWTEmbeddedAWTContext
-
- All Implemented Interfaces:
GUIContext
,AWTContext
,Closeable
,AutoCloseable
public class SWTEmbeddedAWTContext extends Object implements AWTContext
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
Fields Modifier and Type Field Description protected Cleanup<RuntimeException>
cleanup
The clean-up for closing theSWTContext
as post-mortem task for this instance.protected static String
CLEANUP_NAME
The object descriptor for the clean-up registered forSWTEmbeddedAWTContext
instances.protected WeakReference<Thread>
controlThread
The thread which executes the application using this context.
To avoid memory leaks this is just a weak reference.protected org.eclipse.swt.widgets.Composite
parentComposite
The SWT element that includes the AWT Frame the AWT component can insert its gui elements.protected Frame
parentFrame
The AWT Frame the AWT component can insert its GUI elements.protected SWTContext
swtContext
The SWT context the AWT GUI could be integrated into
-
Constructor Summary
Constructors Constructor Description SWTEmbeddedAWTContext(Thread controlThread, SWTContext swtContext)
Constructs an graphical context for an AWT based application component up on an existing swt graphical context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the GUI for this context.Frame
getParentFrame()
Gets the parent frame of this context to use for the GUI of the application.
-
-
-
Field Detail
-
CLEANUP_NAME
protected static final String CLEANUP_NAME
The object descriptor for the clean-up registered forSWTEmbeddedAWTContext
instances.- See Also:
- Constant Field Values
-
swtContext
protected SWTContext swtContext
The SWT context the AWT GUI could be integrated into
-
parentComposite
protected org.eclipse.swt.widgets.Composite parentComposite
The SWT element that includes the AWT Frame the AWT component can insert its gui elements.
-
parentFrame
protected Frame parentFrame
The AWT Frame the AWT component can insert its GUI elements.
-
controlThread
protected WeakReference<Thread> 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
protected final Cleanup<RuntimeException> cleanup
The clean-up for closing theSWTContext
as post-mortem task for this instance.
-
-
Constructor Detail
-
SWTEmbeddedAWTContext
public SWTEmbeddedAWTContext(Thread controlThread, SWTContext swtContext)
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:
SWTContext
-
-
Method Detail
-
getParentFrame
public Frame getParentFrame()
Description copied from interface:AWTContext
Gets the parent frame of this context to use for the GUI of the application.
AnInvalidExecutorThreadException
will be thrown if the method is not called by the main thread of the corresponding component.- Specified by:
getParentFrame
in 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:GUIContext
Closes 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceGUIContext
-
-