public static void runInUI(@Nullable Shell shell, @NotNull Runnable runnable) { final Display display = shell == null || shell.isDisposed() ? Display.getDefault() : shell.getDisplay(); if (display.getThread() != Thread.currentThread()) { display.syncExec(runnable); } else { runnable.run(); } }
public static void runInDetachedUI(@Nullable Shell shell, @NotNull Runnable runnable) { if (shell == null) { Display.getDefault().asyncExec(runnable); } else { try { shell.getDisplay().asyncExec(runnable); } catch (SWTException e) { // DF: Widget has been disposed, too late for some processing then.. } } }