comparison org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.d @ 19:52184e4b815c

no more direct tango.core.Thread. Rename JThread to java.lang.Thread.
author Frank Benoit <benoit@tionex.de>
date Wed, 18 Mar 2009 10:55:25 +0100
parents 735224fcc45f
children
comparison
equal deleted inserted replaced
18:735224fcc45f 19:52184e4b815c
26 import org.eclipse.jface.operation.AccumulatingProgressMonitor; 26 import org.eclipse.jface.operation.AccumulatingProgressMonitor;
27 27
28 import java.lang.all; 28 import java.lang.all;
29 import java.lang.reflect.InvocationTargetException; 29 import java.lang.reflect.InvocationTargetException;
30 import java.util.Set; 30 import java.util.Set;
31 import java.lang.JThread; 31 import java.lang.Thread;
32 32
33 /** 33 /**
34 * Utility class for supporting modal operations. The runnable passed to the 34 * Utility class for supporting modal operations. The runnable passed to the
35 * <code>run</code> method is executed in a separate thread, depending on the 35 * <code>run</code> method is executed in a separate thread, depending on the
36 * value of the passed fork argument. If the runnable is executed in a separate 36 * value of the passed fork argument. If the runnable is executed in a separate
65 private static bool runInSeparateThread = true; 65 private static bool runInSeparateThread = true;
66 66
67 /** 67 /**
68 * Thread which runs the modal context. 68 * Thread which runs the modal context.
69 */ 69 */
70 private static class ModalContextThread : JThread { 70 private static class ModalContextThread : Thread {
71 /** 71 /**
72 * The operation to be run. 72 * The operation to be run.
73 */ 73 */
74 private IRunnableWithProgress runnable; 74 private IRunnableWithProgress runnable;
75 75
96 /** 96 /**
97 * The thread that forked this modal context thread. 97 * The thread that forked this modal context thread.
98 * 98 *
99 * @since 3.1 99 * @since 3.1
100 */ 100 */
101 private JThread callingThread; 101 private Thread callingThread;
102 102
103 /** 103 /**
104 * Creates a new modal context. 104 * Creates a new modal context.
105 * 105 *
106 * @param operation 106 * @param operation
116 super(); //$NON-NLS-1$ 116 super(); //$NON-NLS-1$
117 Assert.isTrue(monitor !is null && display !is null); 117 Assert.isTrue(monitor !is null && display !is null);
118 runnable = operation; 118 runnable = operation;
119 progressMonitor = new AccumulatingProgressMonitor(monitor, display); 119 progressMonitor = new AccumulatingProgressMonitor(monitor, display);
120 this.display = display; 120 this.display = display;
121 this.callingThread = JThread.currentThread(); 121 this.callingThread = Thread.currentThread();
122 } 122 }
123 123
124 /* 124 /*
125 * (non-Javadoc) Method declared on Thread. 125 * (non-Javadoc) Method declared on Thread.
126 */ 126 */
272 /** 272 /**
273 * Returns the currently active modal context thread, or null if no modal 273 * Returns the currently active modal context thread, or null if no modal
274 * context is active. 274 * context is active.
275 */ 275 */
276 private static ModalContextThread getCurrentModalContextThread() { 276 private static ModalContextThread getCurrentModalContextThread() {
277 JThread t = JThread.currentThread(); 277 Thread t = Thread.currentThread();
278 if ( auto r = cast(ModalContextThread)t ) { 278 if ( auto r = cast(ModalContextThread)t ) {
279 return r; 279 return r;
280 } 280 }
281 return null; 281 return null;
282 } 282 }
303 * @param thread 303 * @param thread
304 * The thread to be checked 304 * The thread to be checked
305 * @return <code>true</code> if the given thread is running a modal 305 * @return <code>true</code> if the given thread is running a modal
306 * context, <code>false</code> if not 306 * context, <code>false</code> if not
307 */ 307 */
308 public static bool isModalContextThread(JThread thread) { 308 public static bool isModalContextThread(Thread thread) {
309 return (cast(ModalContextThread)thread) !is null; 309 return (cast(ModalContextThread)thread) !is null;
310 } 310 }
311 311
312 /** 312 /**
313 * Runs the given runnable in a modal context, passing it a progress 313 * Runs the given runnable in a modal context, passing it a progress
424 * @param listener 424 * @param listener
425 * @param switchingThread 425 * @param switchingThread
426 * the {@link Thread} being switched to 426 * the {@link Thread} being switched to
427 */ 427 */
428 static Exception invokeThreadListener(IThreadListener listener, 428 static Exception invokeThreadListener(IThreadListener listener,
429 JThread switchingThread) { 429 Thread switchingThread) {
430 try { 430 try {
431 listener.threadChange(switchingThread); 431 listener.threadChange(switchingThread);
432 // } catch (ThreadDeath e) { 432 // } catch (ThreadDeath e) {
433 // Make sure to propagate ThreadDeath, or threads will never 433 // Make sure to propagate ThreadDeath, or threads will never
434 // fully terminate 434 // fully terminate