Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/frontend/Application.java

Go to the documentation of this file.
00001 
00020 package m2m.frontend;
00021 
00022 import m2m.backend.processing.ProcessWatcher;
00023 
00024 import org.eclipse.equinox.app.IApplication;
00025 import org.eclipse.equinox.app.IApplicationContext;
00026 import org.eclipse.swt.widgets.Display;
00027 import org.eclipse.ui.IWorkbench;
00028 import org.eclipse.ui.PlatformUI;
00029 
00033 public class Application implements IApplication {
00034 
00035         /* (non-Javadoc)
00036          * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
00037          */
00038         public Object start(IApplicationContext context) {
00039 
00040                 Display display = PlatformUI.createDisplay();
00041                 
00042                 try {
00043                         int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
00044                         ProcessWatcher.getInstance().deleteProcesses();
00045                         if (returnCode == PlatformUI.RETURN_RESTART) {
00046                                 return IApplication.EXIT_RESTART;
00047                         }
00048                         return IApplication.EXIT_OK;
00049                 } finally {
00050                         display.dispose();
00051                 }
00052         }
00053 
00054         /* (non-Javadoc)
00055          * @see org.eclipse.equinox.app.IApplication#stop()
00056          */
00057         public void stop() {
00058                 final IWorkbench workbench = PlatformUI.getWorkbench();
00059                 if (workbench == null)
00060                         return;
00061                 final Display display = workbench.getDisplay();
00062                 display.syncExec(new Runnable() {
00063                         public void run() {
00064                                 if (!display.isDisposed())
00065                                         workbench.close();
00066                         }
00067                 });
00068         }
00069 }
 All Classes Namespaces Files Functions Variables Enumerations