Java 类org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor 实例源码

项目:limpet    文件:Application.java   
@SuppressWarnings("deprecation")
public Object start(IApplicationContext appContext) throws Exception
{
  Display display = createDisplay();
  // processor must be created before we start event loop
  DelayedEventsProcessor processor = new DelayedEventsProcessor(display);

  try
  {

    // look and see if there's a splash shell we can parent off of
    Shell shell = WorkbenchPlugin.getSplashShell(display);
    if (shell != null)
    {
      // should should set the icon and message for this shell to be the
      // same as the chooser dialog - this will be the guy that lives in
      // the task bar and without these calls you'd have the default icon
      // with no message.
      shell.setText(ChooseWorkspaceDialog.getWindowTitle());
      shell.setImages(Dialog.getDefaultImages());
    } 

    Object instanceLocationCheck =
        checkInstanceLocation(shell, appContext.getArguments());
    if (instanceLocationCheck != null)
    {
      WorkbenchPlugin.unsetSplashShell(display);
      Platform.endSplash();
      return instanceLocationCheck;
    }

    // create the workbench with this advisor and run it until it exits
    // N.B. createWorkbench remembers the advisor, and also registers
    // the workbench globally so that all UI plug-ins can find it using
    // PlatformUI.getWorkbench() or AbstractUIPlugin.getWorkbench()
    int returnCode =
        PlatformUI.createAndRunWorkbench(display, new IDEWorkbenchAdvisor(
            processor));

    // the workbench doesn't support relaunch yet (bug 61809) so
    // for now restart is used, and exit data properties are checked
    // here to substitute in the relaunch return code if needed
    if (returnCode != PlatformUI.RETURN_RESTART)
    {
      return EXIT_OK;
    }

    // if the exit code property has been set to the relaunch code, then
    // return that code now, otherwise this is a normal restart
    return EXIT_RELAUNCH.equals(Integer.getInteger(PROP_EXIT_CODE))
        ? EXIT_RELAUNCH : EXIT_RESTART;
  }
  finally
  {
    if (display != null)
    {
      display.dispose();
    }
    Location instanceLoc = Platform.getInstanceLocation();
    if (instanceLoc != null)
    {
      instanceLoc.release();
    }
  }
}