/* (non-Javadoc)
   * @see org.eclipse.jface.wizard.Wizard#addPages()
   */
  public void addPages() {
    WizardElement templateWizardElement = getTemplateWizard();
    if (templateWizardElement == null) {
      MessageDialog.openError(
          getShell(),
          PDEUIMessages.NewPluginProjectFromTemplateWizard_1,
          NLS.bind(PDEUIMessages.NewPluginProjectFromTemplateWizard_0, getTemplateID()));
      return;
    }

    fProjectPage =
        new NewProjectCreationFromTemplatePage(
            "main", fPluginData, getSelection(), templateWizardElement); // $NON-NLS-1$
    fProjectPage.setTitle(PDEUIMessages.NewProjectWizard_MainPage_title);
    fProjectPage.setDescription(PDEUIMessages.NewProjectWizard_MainPage_desc);

    String projectName = getDefaultValue(DEF_PROJECT_NAME);
    if (projectName != null) fProjectPage.setInitialProjectName(projectName);
    addPage(fProjectPage);

    fProjectProvider =
        new IProjectProvider() {
          public String getProjectName() {
            return fProjectPage.getProjectName();
          }

          public IProject getProject() {
            return fProjectPage.getProjectHandle();
          }

          public IPath getLocationPath() {
            return fProjectPage.getLocationPath();
          }
        };

    fContentPage =
        new PluginContentPage("page2", fProjectProvider, fProjectPage, fPluginData); // $NON-NLS-1$
    addPage(fContentPage);

    try {
      fTemplateWizard = (IPluginContentWizard) templateWizardElement.createExecutableExtension();
      fTemplateWizard.init(fPluginData);
      fTemplateWizard.addPages();
      IWizardPage[] pages = fTemplateWizard.getPages();
      for (int i = 0; i < pages.length; i++) {
        addPage(pages[i]);
      }
    } catch (CoreException e) {
      MessageDialog.openError(
          getShell(),
          PDEUIMessages.NewPluginProjectFromTemplateWizard_1,
          NLS.bind(PDEUIMessages.NewPluginProjectFromTemplateWizard_0, getTemplateID()));
    }
  }
 /* (non-Javadoc)
  * @see org.eclipse.jface.wizard.Wizard#canFinish()
  */
 public boolean canFinish() {
   if (super.canFinish() && !getContainer().getCurrentPage().equals(fProjectPage)) {
     if (fTemplateWizard == null || fTemplateWizard.canFinish()) {
       return true;
     }
   }
   return false;
 }