Eclipse Remote Application Platform

## org.eclipse.rap.rwt.lifecycle
Class UICallBack

    java.lang.Object
      org.eclipse.rap.rwt.lifecycle.UICallBack

Deprecated. This class will be removed in a future release. Use `ServerPushSession` instead to enable/disable server push.

    @Deprecated
    public final class UICallBack

extends java.lang.Object

A utility class that provides methods to perform tasks related to UI updates from background threads.

Since:
  2.0

Method Summary
`static void` `activate(java.lang.String id)` Deprecated. Use `ServerPushSession.start()` instead.
`static void` `deactivate(java.lang.String id)` Deprecated. Use `ServerPushSession.stop()` instead.
`static void` `runNonUIThreadWithFakeContext(Display display, java.lang.Runnable runnable)` Deprecated. Use `UISession.exec(Runnable)` instead. You can obtain a reference to the UI session for a display by `RWT.getUISession(Display)`. Example: `RWT.getUISession( display ).exec( runnable )`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### runNonUIThreadWithFakeContext

    @Deprecated
    public static void runNonUIThreadWithFakeContext(Display display,
                                                                java.lang.Runnable runnable)

  Deprecated. Use `UISession.exec(Runnable)` instead. You can obtain a reference to the UI session for a display by `RWT.getUISession(Display)`. Example: `RWT.getUISession( display ).exec( runnable )`.

  Executes a given runnable in the context of the UI session that is associated with the given display. This allows background threads to access values that are stored in the UI session, including session singletons.

  Parameters:
    `display` - the display that is bound to the UI session which the runnable needs to access
    `runnable` - the runnable to execute in the UI session context of the given display
  See Also:
    `SingletonUtil`

### activate

    @Deprecated
    public static void activate(java.lang.String id)

  Deprecated. Use `ServerPushSession.start()` instead.

  Call this method to enable UI updates from background threads (e.g. via `Display.asyncExec()`}. The UI callback must be activated from the UI thread before the background thread starts. Each activation is given a session-unique id to allow reference-counting activation and deactivation.

  If not deactivated explicitly, any active UI callbacks are released when the session terminates.

  Note: this method must only be called from the UI-Thread of an RWT application.

  Example code:

       final String callbackId = "callback id";
       Runnable bgRunnable = new Runnable() {
         public void run() {
         // do some work...
         // schedule the UI update
         display.asyncExec( new Runnable() {
           public void run() {
             if( !widget.isDisposed() ) {
               // update the UI
             }
           }
         } );
         // Deactivate the UI call-back
         UICallBack.runNonUIThreadWithFakeContext( display, new Runnable() {
           public void run() {
             UICallBack.deactivate( callbackId );
           }
         } );
         }
       };
       UICallBack.activate( callbackId );
       Thread bgThread = new Thread( bgRunnable );
       bgThread.setDaemon( true );
       bgThread.start();

  Parameters:
    `id` - a session unique identifier to trace the activation and deactivation. Must not be `null`.
  Throws:
    `SWTException` -
    - ERROR_NULL_ARGUMENT - if the id is `null`
    - ERROR_THREAD_INVALID_ACCESS - if not called from the UI thread
  See Also:
    `Display.syncExec(java.lang.Runnable)`, `Display.asyncExec(java.lang.Runnable)`, `Display.getThread()`, `Display.wake()`

### deactivate

    @Deprecated
    public static void deactivate(java.lang.String id)

  Deprecated. Use `ServerPushSession.stop()` instead.

  This method deactivates a previously `activated` UI callback with the same `id`. Calling this method with an id that wasn't activated before has no effect.

  For each id, the system maintains a reference counter so that multiple activations of the same id must be followed by the same number deactivations in oder to actually stop the UI callback.

  Note: this method must only be called from code that is associated with a session. That is, either code running in the UI thread or executed via `runNonUIThreadWithFakeContext(Display, Runnable)`

  Parameters:
    `id` - A session unique identifier to trace the activation and deactivation. Must not be `null`
  Throws:
    `SWTException` -
    - ERROR_NULL_ARGUMENT - if the id is `null`
    - ERROR_THREAD_INVALID_ACCESS - if not called from session code
  See Also:
    `Display.syncExec(java.lang.Runnable)`, `Display.asyncExec(java.lang.Runnable)`, `Display.getThread()`, `Display.wake()`

Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2014. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0