Bug 78222 [JFace] ModalContext event loop should guard against SWTExceptions
I was generating a patch and clicking Finish on the wizard would not close the wizard even though the patch was created succesfully. It turned out that the problem was that writing to the console caused an error due to word wrap being on. There are two problems here. There was no error message shown to the user and writing to the console should not cause a command to fail.
bundles/org.eclipse.jface/src/org/eclipse/jface/operation/ModalContext.java
*
     * @return the modal nesting level, or <code>0</code> if 
     *  this method is called outside the dynamic scope of any
     *  invocation of <code>ModalContext.run</code>
     */
    public static int getModalLevel() {
        return modalLevel;
    }
    /**
     * Returns whether the given thread is running a modal context.
     * 
     * @param thread The thread to be checked
     * @return <code>true</code> if the given thread is running a modal context, <code>false</code> if not
     */
    public static boolean isModalContextThread(Thread thread) {
        return thread instanceof ModalContextThread;
    }
    /**
     * Runs the given runnable in a modal context, passing it a progress monitor.
     * <p>
     * The modal nesting level is increased by one from the perspective
     * of the given runnable.
     * </p>
     *<p>
     * If the supplied operation implements <code>IThreadListener</code>, it
     * will be notified of any thread changes required to execute the operation.
     * Specifically, the operation will be notified of the thread that will call its 
     * <code>run</code> method before it is called, and will be notified of the
     * change of control back to the thread calling this method when the operation
     * completes.  These thread change notifications give the operation an