/** Default constructor. */
  public WAProjectWizard() {
    setWindowTitle(Messages.pWizWindowTitle);
    String zipFile = "";
    try {
      zipFile =
          String.format(
              "%s%s%s%s%s",
              PluginUtil.pluginFolder,
              File.separator,
              Messages.pluginId,
              File.separator,
              Messages.starterKitFileName);

      // Extract the WAStarterKitForJava.zip to temp dir
      waProjMgr = WindowsAzureProjectManager.create(zipFile);
      //	By deafult - disabling remote access
      //  when creating new project
      waProjMgr.setRemoteAccessAllRoles(false);
      waProjMgr.setClassPathInPackage("azure.lib.dir", PluginUtil.getAzureLibLocation());
      waRole = waProjMgr.getRoles().get(0);
      // remove http endpoint
      WindowsAzureEndpoint endpoint = waRole.getEndpoint(Messages.httpEp);
      if (endpoint != null) {
        endpoint.delete();
      }
    } catch (IOException e) {
      PluginUtil.displayErrorDialogAndLog(
          this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg, e);
    } catch (Exception e) {
      errorTitle = Messages.adRolErrTitle;
      errorMessage = Messages.pWizErrMsgBox1 + Messages.pWizErrMsgBox2;
      PluginUtil.displayErrorDialogAndLog(this.getShell(), errorTitle, errorMessage, e);
    }
  }
  /**
   * Move the project structure to the location provided by user. Also configure JDK, server, server
   * application and key features like session affinity, caching, debugging if user wants to do so.
   *
   * @param projName : Name of the project
   * @param projLocation : Location of the project
   * @param isDefault : whether location of project is default
   * @param selWorkingSets
   * @param workingSetManager
   * @param depMap : stores configurations done on WATagPage
   * @param ftrMap : stores configurations done on WAKeyFeaturesPage
   * @param selProj
   */
  private void doFinish(
      String projName,
      String projLocation,
      boolean isDefault,
      IWorkingSet[] selWorkingSets,
      IWorkingSetManager workingSetManager,
      Map<String, String> depMap,
      Map<String, Boolean> ftrMap,
      IProject selProj) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject project = null;
    try {
      WindowsAzureRole role = waProjMgr.getRoles().get(0);
      // logic for handling deploy page components and their values.
      if (!depMap.isEmpty()) {
        File templateFile = new File(depMap.get("tempFile"));
        role = WizardUtilMethods.configureJDKServer(role, depMap);
        /*
         * Handling adding server application
         * without configuring server/JDK.
         * Always add cloud attributes as
         * approot directory is not created yet
         * hence all applications are
         * imported from outside of the Azure project
         */
        if (!tabPg.getAppsAsNames().isEmpty()) {
          for (int i = 0; i < tabPg.getAppsList().size(); i++) {
            AppCmpntParam app = tabPg.getAppsList().get(i);
            if (!app.getImpAs().equalsIgnoreCase(Messages.helloWorld)) {
              role.addServerApplication(
                  app.getImpSrc(), app.getImpAs(), app.getImpMethod(), templateFile, true);
            }
          }
        }
      }

      /** Handling for HelloWorld application in plug-in */
      if (tabPg != null) {
        if (!tabPg.getAppsAsNames().contains(Messages.helloWorld)) {
          List<WindowsAzureRoleComponent> waCompList =
              waProjMgr.getRoles().get(0).getServerApplications();
          for (WindowsAzureRoleComponent waComp : waCompList) {
            if (waComp.getDeployName().equalsIgnoreCase(Messages.helloWorld)
                && waComp.getImportPath().isEmpty()) {
              waComp.delete();
            }
          }
        }
      }
      role = WizardUtilMethods.configureKeyFeatures(role, ftrMap);

      waProjMgr.save();
      WindowsAzureProjectManager.moveProjFromTemp(projName, projLocation);
      String launchFilePath = projLocation + File.separator + projName + LAUNCH_FILE_PATH;
      ParseXML.setProjectNameinLaunch(launchFilePath, Messages.pWizWinAzureProj, projName);

      root.touch(null);
      project = root.getProject(projName);
      IProjectDescription projDescription = workspace.newProjectDescription(projName);

      Path path = new Path(projLocation + File.separator + projName);
      projDescription.setLocation(path);
      projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID});

      if (!project.exists()) {
        if (isDefault) {
          project.create(null);
        } else {
          project.create(projDescription, null);
        }
      }
      project.open(null);

      projDescription = project.getDescription();
      projDescription.setName(projName);
      projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID});

      project.move(projDescription, IResource.FORCE, null);

      workingSetManager.addToWorkingSets(project, selWorkingSets);

      root.touch(null);
      if (project != null) {
        WADependencyBuilder builder = new WADependencyBuilder();
        builder.addBuilder(project, "com.persistent.winazure.eclipseplugin.Builder");
      }
    } catch (Exception e) {
      Display.getDefault()
          .syncExec(
              new Runnable() {
                public void run() {
                  MessageDialog.openError(null, Messages.pWizErrTitle, Messages.pWizErrMsg);
                }
              });
      Activator.getDefault().log(Messages.pWizErrMsg, e);
    }
  }