01: package org.wings;
02:
03: import org.wings.session.SessionManager;
04: import org.wings.session.Session;
05:
06: import java.lang.reflect.InvocationTargetException;
07:
08: /**
09: * Created by IntelliJ IDEA.
10: * User: hengels
11: * Date: Aug 27, 2006
12: * Time: 9:13:59 PM
13: * To change this template use File | Settings | File Templates.
14: */
15: public class WingSUtilities {
16: /**
17: * Enqueues the runnable to be called within the next browser request right after
18: * events have been dispatched.
19: *
20: * <code>javax.swing.SwingUtilities.invokeLater()</code>.
21: */
22: public static void invokeLater(Session session, Runnable doRun) {
23: session.getDispatcher().invokeLater(doRun);
24: }
25:
26: /**
27: * Waits for the next browser request and calls the runnable right after
28: * events have been dispatched.
29: *
30: * <code>javax.swing.SwingUtilities.invokeAndWait()</code>.
31: public static void invokeAndWait(Session session, final Runnable doRun)
32: throws InterruptedException, InvocationTargetException
33: {
34: }
35: TODO: this is quite complex. wait until either the next request arrives
36: or until the session terminates
37: */
38:
39: /**
40: * Returns true if the current thread is a wingS event dispatching thread.
41: * <code>javax.swing.SwingUtilities.isDispatchThread()</code>.
42: *
43: * @return true if the current thread is a wingS event dispatching thread
44: */
45: public static boolean isEventDispatchThread() {
46: return SessionManager.getSession() != null;
47: }
48: }
|