@Override
  public boolean performFinish() {
    newProject = mainPage.getProjectHandle();
    destPath = mainPage.getLocationPath();
    location = null;
    if (!mainPage.useDefaults()) {
      location = mainPage.getLocationURI();
    } else {
      destPath = destPath.append(newProject.getName());
    }

    if (templatesPage != null) {
      selectedTemplate = templatesPage.getSelectedTemplate();
    }

    if (referencePage != null) {
      refProjects = referencePage.getReferencedProjects();
    }

    if (!deferCreatingProject()) {
      IStatus projectStatus = createAndRefreshProject(true, true, new NullProgressMonitor());
      return projectStatus.isOK();
    }
    return true;
  }
  /**
   * Add pages to the wizard.<br>
   * By default, we don't add the reference page to the base Web Project (subclasses may override).
   *
   * @see org.eclipse.jface.wizard.Wizard#addPages()
   */
  @Override
  public void addPages() {
    super.addPages();

    TemplateType[] templateTypes = getProjectTemplateTypes();
    validateProjectTemplate(templateTypes);

    LinkedHashMap<String, IStepIndicatorWizardPage> stepPages =
        new LinkedHashMap<String, IStepIndicatorWizardPage>();

    // Add the template selection page
    List<IProjectTemplate> templates =
        ProjectsPlugin.getDefault().getTemplatesManager().getTemplates(templateTypes);
    if (hasNonDefaultTemplates(templates) && selectedTemplate == null) {
      addPage(
          templatesPage =
              new ProjectTemplateSelectionPage(TEMPLATE_SELECTION_PAGE_NAME, templates));
      stepPages.put(templatesPage.getStepName(), templatesPage);
    }

    // Add the main page where we set up the project name/location
    addPage(mainPage = createMainPage());
    if (mainPage instanceof IStepIndicatorWizardPage) {
      stepPages.put(
          ((IStepIndicatorWizardPage) mainPage).getStepName(), (IStepIndicatorWizardPage) mainPage);
    }

    // Add contributed pages
    ProjectWizardContributionManager projectWizardContributionManager =
        ProjectsPlugin.getDefault().getProjectWizardContributionManager();
    IWizardPage[] extraPages =
        projectWizardContributionManager.createPages(data, getProjectNatures());
    if (!ArrayUtil.isEmpty(extraPages)) {
      for (IWizardPage page : extraPages) {
        addPage(page);
        if (page instanceof IStepIndicatorWizardPage) {
          stepPages.put(
              ((IStepIndicatorWizardPage) page).getStepName(), (IStepIndicatorWizardPage) page);
        }
      }
    }

    // Set up the steps
    stepNames = stepPages.keySet().toArray(new String[stepPages.size()]);
    if (stepNames.length > 1) {
      for (IStepIndicatorWizardPage page : stepPages.values()) {
        page.initStepIndicator(stepNames);
      }
    }

    // Finalize pages using contributors
    projectWizardContributionManager.finalizeWizardPages(getPages(), getProjectNatures());
  }