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 final Cleanup<RuntimeException>
    The clean-up for closing the SWTContext as post-mortem task for this instance.
    protected static final String
    The object descriptor for the clean-up registered for SWTEmbeddedAWTContext instances.
    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
    The SWT element that includes the AWT Frame the AWT component can insert its gui elements.
    protected Frame
    The AWT Frame the AWT component can insert its GUI elements.
    protected 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

    Modifier and Type
    Method
    Description
    void
    Closes the GUI for this context.
    Gets the parent frame of this context to use for the GUI of the application.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CLEANUP_NAME

      protected static final String CLEANUP_NAME
      The object descriptor for the clean-up registered for SWTEmbeddedAWTContext instances.
      See Also:
    • 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 the SWTContext as post-mortem task for this instance.
  • Constructor Details

    • 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:
  • Method Details

    • getParentFrame

      public Frame getParentFrame()
      Description copied from interface: AWTContext
      Gets the parent frame of this context to use for the GUI of the application.
      An InvalidExecutorThreadException will be thrown if the method is not called by the main thread of the corresponding component.
      Specified by:
      getParentFrame in interface AWTContext
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface GUIContext