/**
  * This method gets called when wizard's finish button is clicked.
  *
  * @return True, if project gets created successfully; else false.
  */
 @Override
 public boolean performFinish() {
   final String projName = waProjWizPage.getTextProjName();
   final String projLocation = waProjWizPage.getTextLocation();
   final boolean isDefault = waProjWizPage.isDefaultLocation();
   final WorkingSetGroup workingSetGroup = waProjWizPage.getWorkingSetGroup();
   final IWorkingSet[] selWorkingSets = workingSetGroup.getSelectedWorkingSets();
   final IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
   final Map<String, String> depParams = getDeployPageValues();
   final Map<String, Boolean> keyFtr = getKeyFtrPageValues();
   final IProject proj = getSelectProject();
   boolean retVal = true;
   IRunnableWithProgress runnable =
       new IRunnableWithProgress() {
         public void run(IProgressMonitor monitor) throws InvocationTargetException {
           try {
             doFinish(
                 projName,
                 projLocation,
                 isDefault,
                 selWorkingSets,
                 workingSetManager,
                 depParams,
                 keyFtr,
                 proj);
           } finally {
             monitor.done();
           }
         }
       };
   try {
     /*
      * Check if third party JDK and server is selected
      * then license is accepted or not.
      */
     boolean tempAccepted = true;
     if (WATabPage.isThirdPartyJdkChecked() && !WATabPage.isAccepted()) {
       tempAccepted = JdkSrvConfig.createAccLicenseAggDlg(getShell(), true);
     }
     if (WATabPage.isThirdPartySrvChecked() && !WATabPage.isServerAccepted()) {
       tempAccepted = JdkSrvConfig.createAccLicenseAggDlg(getShell(), false);
     }
     if (tempAccepted) {
       getContainer().run(true, false, runnable);
     } else {
       return false;
     }
   } catch (InterruptedException e) {
     PluginUtil.displayErrorDialog(this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg);
     retVal = false;
   } catch (InvocationTargetException e) {
     PluginUtil.displayErrorDialogAndLog(
         this.getShell(), Messages.pWizErrTitle, Messages.pWizErrMsg, e);
     retVal = false;
   }
   // re-initializing context menu to default option : false
   Activator.getDefault().setContextMenu(false);
   return retVal;
 }
  @Override
  protected void okPressed() {
    boolean isValid = true;
    if ((fileRadioBtn.getSelection() && !fileTxt.getText().isEmpty())) {
      File file = new File(fileTxt.getText());
      if (!file.exists()) {
        isValid = false;
        PluginUtil.displayErrorDialog(
            this.getShell(), Messages.appDlgInvFileTtl, Messages.appDlgInvFileMsg);
      }
    } else if (projRadioBtn.getSelection()
        && !asNameTxt.getText().isEmpty()
        && !projCombo.getText().isEmpty()) {
      boolean isValidName = true;
      try {
        isValidName = windowsAzureRole.isValidDeployName(asNameTxt.getText());
      } catch (Exception e) {
        isValidName = false;
      }
      if (!isValidName) {
        isValid = false;
        PluginUtil.displayErrorDialog(
            this.getShell(), Messages.appDlgInvNmeTtl, Messages.appDlgInvNmeMsg);
      }
    }
    if (isValid) {
      ArrayList<String> cmpList = null;
      if (depPage == null) {
        cmpList = serverConf.getAppsAsNames();
      } else {
        cmpList = depPage.getAppsAsNames();
      }

      if (fileRadioBtn.getSelection()) {
        if (cmpList.contains(new File(fileTxt.getText()).getName())) {
          PluginUtil.displayErrorDialog(
              this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg);
          return;
        }
        try {
          List<WindowsAzureRoleComponent> components = windowsAzureRole.getComponents();
          for (int i = 0; i < components.size(); i++) {
            if (components
                .get(i)
                .getDeployName()
                .equalsIgnoreCase(new File(fileTxt.getText()).getName())) {
              PluginUtil.displayErrorDialog(
                  this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg);
              return;
            }
          }
        } catch (WindowsAzureInvalidProjectOperationException e) {
          PluginUtil.displayErrorDialogAndLog(
              this.getShell(), Messages.addAppErrTtl, Messages.addAppErrMsg, e);
        }

        if (depPage == null) {
          serverConf.addToAppList(
              fileTxt.getText(), new File(fileTxt.getText()).getName(), Messages.methodCopy);
        } else {
          depPage.addToAppList(
              fileTxt.getText(), new File(fileTxt.getText()).getName(), Messages.methodCopy);
        }

      } else if (projRadioBtn.getSelection()) {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot root = workspace.getRoot();
        IProject proj = root.getProject(projCombo.getText());
        if (cmpList.contains(new File(asNameTxt.getText()).getName())) {
          PluginUtil.displayErrorDialog(
              this.getShell(), Messages.appDlgDupNmeTtl, Messages.appDlgDupNmeMsg);
          return;
        }
        if (depPage == null) {
          serverConf.addToAppList(
              proj.getLocation().toOSString(), asNameTxt.getText(), Messages.methodAuto);
        } else {
          depPage.addToAppList(
              proj.getLocation().toOSString(), asNameTxt.getText(), Messages.methodAuto);
        }
      }
      super.okPressed();
    }
  }