HPCViewer.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.viewer.framework;
00002 
00003 import org.eclipse.equinox.app.IApplication;
00004 import org.eclipse.equinox.app.IApplicationContext;
00005 import org.eclipse.swt.widgets.Display;
00006 import org.eclipse.ui.IWorkbench;
00007 import org.eclipse.ui.PlatformUI;
00008 
00012 public class HPCViewer implements IApplication {
00013 
00014     private String[] checkArguments(IApplicationContext context) {
00015         String[] args = (String[])context.getArguments().get("application.args");
00016         return args;
00017     }
00018 
00019     /* (non-Javadoc)
00020      * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
00021      */
00022     public Object start(IApplicationContext context) {
00023         Display display = PlatformUI.createDisplay();
00024         String []args = this.checkArguments(context);
00025         try {       
00026             int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor(args));
00027             if (returnCode == PlatformUI.RETURN_RESTART) {
00028                 return IApplication.EXIT_RESTART;
00029             }
00030             return IApplication.EXIT_OK;
00031         } finally {
00032             display.dispose();
00033         }
00034     }
00035 
00036     /* (non-Javadoc)
00037      * @see org.eclipse.equinox.app.IApplication#stop()
00038      */
00039     public void stop() {
00040         final IWorkbench workbench = PlatformUI.getWorkbench();
00041         if (workbench == null)
00042             return;
00043         final Display display = workbench.getDisplay();
00044         display.syncExec(new Runnable() {
00045             public void run() {
00046                 if (!display.isDisposed())
00047                     workbench.close();
00048             }
00049         });
00050     }
00051 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1