1 11 package org.eclipse.ui.internal.editors.text; 12 13 import org.eclipse.core.filebuffers.ISynchronizationContext; 14 15 import org.eclipse.swt.widgets.Display; 16 17 import org.eclipse.ui.IWorkbench; 18 import org.eclipse.ui.IWorkbenchWindow; 19 import org.eclipse.ui.PlatformUI; 20 21 27 public class UISynchronizationContext implements ISynchronizationContext { 28 29 32 public void run(Runnable runnable) { 33 if (Display.getCurrent() != null) { 34 runnable.run(); 35 } else { 36 IWorkbench workbench= PlatformUI.getWorkbench(); 37 IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); 38 if (windows != null && windows.length > 0) { 39 Display display= windows[0].getShell().getDisplay(); 40 display.asyncExec(runnable); 41 } else { 42 runnable.run(); 43 } 44 } 45 } 46 } 47 | Popular Tags |