1 package $packageName$; 2 3 import org.eclipse.equinox.app.IApplication; 4 import org.eclipse.equinox.app.IApplicationContext; 5 import org.eclipse.swt.widgets.Display; 6 import org.eclipse.ui.IWorkbench; 7 import org.eclipse.ui.PlatformUI; 8 9 12 public class Application implements IApplication { 13 14 17 public Object start(IApplicationContext context) { 18 Display display = PlatformUI.createDisplay(); 19 try { 20 int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); 21 if (returnCode == PlatformUI.RETURN_RESTART) { 22 return IApplication.EXIT_RESTART; 23 } 24 return IApplication.EXIT_OK; 25 } finally { 26 display.dispose(); 27 } 28 } 29 30 33 public void stop() { 34 final IWorkbench workbench = PlatformUI.getWorkbench(); 35 if (workbench == null) 36 return; 37 final Display display = workbench.getDisplay(); 38 display.syncExec(new Runnable () { 39 public void run() { 40 if (!display.isDisposed()) 41 workbench.close(); 42 } 43 }); 44 } 45 } 46 | Popular Tags |