@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();
    }
  }