Java Code Examples for org.eclipse.swt.widgets.Display.disposeExec()

The following are Jave code examples for showing how to use disposeExec() of the org.eclipse.swt.widgets.Display class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: neoscada   File: KeyInstanceManager.java   Source Code and License Vote up 5 votes
public static KeyInstanceManager getInstance ( final Display display )
{
    if ( display == null )
    {
        SWT.error ( SWT.ERROR_NULL_ARGUMENT );
    }

    if ( Display.getCurrent () != display )
    {
        SWT.error ( SWT.ERROR_THREAD_INVALID_ACCESS );
    }

    if ( display.isDisposed () )
    {
        SWT.error ( SWT.ERROR_DEVICE_DISPOSED );
    }

    KeyInstanceManager mgr = instanceMap.get ( display );
    if ( mgr != null )
    {
        return mgr;
    }

    mgr = new KeyInstanceManager ( display );
    instanceMap.put ( display, mgr );

    display.disposeExec ( new Runnable () {

        @Override
        public void run ()
        {
            disposeDisplay ( display );
        }
    } );

    return mgr;
}