/**
   * Creates the sole wizard page contributed by this base implementation; the standard Eclipse
   * WizardNewProjectCreationPage.
   *
   * @see WizardNewProjectCreationPage#WizardNewProjectCreationPage(String)
   */
  public void init(IWorkbench workbench, IStructuredSelection selection) {
    // Set default image for all wizard pages
    IPath path =
        new Path(
            org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIResourceBundle
                .NEW_PROJECT_WIZARD_PAGE_ICON);
    Bundle bundle =
        org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIPlugin.getDefault().getBundle();
    URL url = FileLocator.find(bundle, path, null);
    ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
    setDefaultPageImageDescriptor(descriptor);

    wizardNewProjectCreationPage = new WizardNewProjectCreationPage(pageName);
    wizardNewProjectCreationPage.setTitle(pageTitle);
    wizardNewProjectCreationPage.setDescription(pageDescription);
    wizardNewProjectCreationPage.setInitialProjectName(pageProjectName);

    this.addPage(wizardNewProjectCreationPage);
    setWindowTitle(
        org.emftext.sdk.concretesyntax.resource.cs.ui.CsUIResourceBundle
            .NEW_PROJECT_WIZARD_WINDOW_TITLE);
  }
  @Override
  protected IStatus run(IProgressMonitor monitor) {

    try {
      final CsResource csResource = new CsEclipseProxy().getResource(csFile);
      // remove all generation problems
      new CsMarkerHelper().unmark(csResource, CsEProblemType.BUILDER_ERROR);
      // create problem collector
      IProblemCollector problemCollector =
          new IProblemCollector() {
            public void addProblem(GenerationProblem problem) {
              addGenerationProblem(csResource, problem);
            }
          };
      final ConcreteSyntax concreteSyntax = (ConcreteSyntax) csResource.getContents().get(0);
      GenerationContext context =
          new UIGenerationContext(new WorkspaceConnector(), problemCollector, concreteSyntax);

      Result result = new UICreateResourcePluginsJob().run(context, new WorkspaceMarker(), monitor);
      switch (result) {
        case ERROR_ABSTRACT_SYNTAX:
          {
            // show error message, because we can not generate plug-ins for
            // abstract syntaxes
            CsUIPlugin.showErrorDialog(
                "Abstract syntax",
                "Can't generate resource plug-ins for abstract syntax definition.");
            break;
          }
        case ERROR_SYNTAX_HAS_ERRORS:
          {
            // show error message, because we can not generate plug-ins for
            // syntaxes with errors
            CsUIPlugin.showErrorDialog(
                "Errors in syntax",
                "Can't generate resource plug-ins, because the syntax definition contains errors.");
            break;
          }
        case ERROR_FOUND_UNRESOLVED_PROXIES:
          {
            // show error message, because we can not generate plug-ins for
            // syntaxes dangling references
            CsUIPlugin.showErrorDialog(
                "Errors in syntax",
                "Can't generate resource plug-ins, because the syntax definition contains references that can not be resolved.");
            break;
          }
        case ERROR_GEN_PACKAGE_NOT_FOUND:
          {
            // show error message, because we can not generate plug-ins for
            // syntaxes with missing generator packages
            CsUIPlugin.showErrorDialog(
                "Errors in syntax",
                "Can't generate resource plug-ins. A generator package was not found.");
            break;
          }
        case SUCCESS:
          {
            return Status.OK_STATUS;
          }
      }
    } catch (Exception e) {
      EMFTextSDKPlugin.logError("Exception while generating resource plug-ins.", e);
      String message = e.getMessage();
      if (message == null) {
        message = CoreException.class.getSimpleName();
      }
      return new Status(
          Status.ERROR, EMFTextSDKUIPlugin.PLUGIN_ID, message, new InvocationTargetException(e));
    }
    return Status.OK_STATUS;
  }