chrriis.dj.nativeswing.swtimpl
Class NativeInterface

java.lang.Object
  extended by chrriis.dj.nativeswing.swtimpl.NativeInterface

public class NativeInterface
extends Object

The native interface, which establishes the link between the peer VM (native side) and the local side.

Author:
Christopher Deckers

Method Summary
static void addNativeInterfaceListener(NativeInterfaceListener listener)
          Add a native interface listener.
static void close()
          Close the native interface, which destroys the native side (peer VM).
static NativeInterfaceConfiguration getConfiguration()
          Get the configuration, which allows to modify some parameters.
static Display getDisplay()
          Get the SWT display.
static NativeInterfaceListener[] getNativeInterfaceListeners()
          Get all the native interface listeners.
static void initialize()
          Initialize the native interface, but do not open it.
static boolean isUIThread(boolean isNativeSide)
          Indicate if the current thread is the user interface thread.
static void main(String[] args)
          The main method that is called by the native side (peer VM).
static void open()
          Open the native interface, which creates the peer VM that handles the native side of the native integration.
Initialization takes place if the interface was not already initialized.
static void removeNativeInterfaceListener(NativeInterfaceListener listener)
          Remove a native interface listener.
static void runEventPump()
          Run the native event pump.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public static void close()
Close the native interface, which destroys the native side (peer VM). Note that the native interface can be re-opened later.


getConfiguration

public static NativeInterfaceConfiguration getConfiguration()
Get the configuration, which allows to modify some parameters.


initialize

public static void initialize()
Initialize the native interface, but do not open it. This method sets some properties and registers a few listeners to keep track of certain states necessary for the good functioning of the framework.
This method is automatically called if open() is used. It should be called early in the program, the best place being as the first call in the main method.


open

public static void open()
Open the native interface, which creates the peer VM that handles the native side of the native integration.
Initialization takes place if the interface was not already initialized. If initialization was not explicitely performed, this method should be called early in the program, the best place being as the first call in the main method.


getDisplay

public static Display getDisplay()
Get the SWT display. This is only possible when in the native context.

Returns:
the display, or null.

isUIThread

public static boolean isUIThread(boolean isNativeSide)
Indicate if the current thread is the user interface thread.

Returns:
true if the current thread is the user interface thread.
Throws:
IllegalStateException - when the native interface is not alive.

runEventPump

public static void runEventPump()
Run the native event pump. Certain platforms require this method call at the end of the main method to function properly, so it is suggested to always add it.


addNativeInterfaceListener

public static void addNativeInterfaceListener(NativeInterfaceListener listener)
Add a native interface listener.

Parameters:
listener - the native listener to add.

removeNativeInterfaceListener

public static void removeNativeInterfaceListener(NativeInterfaceListener listener)
Remove a native interface listener.

Parameters:
listener - the native listener to remove.

getNativeInterfaceListeners

public static NativeInterfaceListener[] getNativeInterfaceListeners()
Get all the native interface listeners.

Returns:
the native interface listeners.

main

public static void main(String[] args)
                 throws Exception
The main method that is called by the native side (peer VM).

Parameters:
args - the arguments that are passed to the peer VM.
Throws:
Exception