/**
  * Set correctly the invoked object, by creating it if needed. Then, notifies that the ok button
  * of this dialog has been pressed.
  *
  * @see org.eclipse.jface.dialogs.Dialog#okPressed()
  */
 @Override
 protected void okPressed() {
   // create element
   createdParameter = UMLFactory.eINSTANCE.createParameter();
   createdParameter.setName(selectedName);
   createdParameter.setType((Type) selectedType);
   createdParameter.setDirection(selectedDirection);
   addParameter(createdParameter);
   super.okPressed();
 }
 /**
  * Adds buttons to this dialog's button bar.
  *
  * @param parent the button bar composite
  */
 @Override
 protected void createButtonsForButtonBar(Composite parent) {
   super.createButtonsForButtonBar(parent);
   refreshOkButton();
 }
 /**
  * Method configureShell.
  *
  * @param shell Shell
  * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
  */
 @Override
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   shell.setText(ADD_PARTICIPANT_DIALOG_TITLE);
   shell.setMinimumSize(R4EUIConstants.DIALOG_DEFAULT_WIDTH, R4EUIConstants.DIALOG_DEFAULT_HEIGHT);
 }
 /**
  * Method open.
  *
  * @see org.eclipse.ui.forms.FormDialog#open()
  */
 @Override
 public void create() {
   fParticipantsDetailsValues.clear();
   fParticipants.clear();
   super.create();
 }
  /**
   * Method buttonPressed.
   *
   * @param buttonId int
   * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
   */
  @Override
  protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
      final List<R4EParticipant> validatedParticipants = new ArrayList<R4EParticipant>();

      for (R4EParticipant newParticipant : fParticipants) {
        // Validate Participant Id
        String validateResult = validateEmptyInput(newParticipant.getId());
        if (null != validateResult) {
          // Validation of input failed
          final ErrorDialog dialog =
              new ErrorDialog(
                  null,
                  R4EUIConstants.DIALOG_TITLE_ERROR,
                  "No input given for Participant Id",
                  new Status(IStatus.ERROR, R4EUIPlugin.PLUGIN_ID, 0, validateResult, null),
                  IStatus.ERROR);
          dialog.open();
          return;
        }

        // Validate Participant Email
        validateResult = validateEmptyInput(newParticipant.getEmail());
        if (null != validateResult) {
          // Validation of input failed
          final ErrorDialog dialog =
              new ErrorDialog(
                  null,
                  R4EUIConstants.DIALOG_TITLE_ERROR,
                  "No Email given for Participant " + newParticipant.getId(),
                  new Status(IStatus.ERROR, R4EUIPlugin.PLUGIN_ID, 0, validateResult, null),
                  IStatus.ERROR);
          dialog.open();
          return;
        }
        if (!CommandUtils.isEmailValid(newParticipant.getEmail())) {
          return;
        }

        // Check if participant already exists (if so ignore but continue)
        R4EParticipant currentParticipant = null;
        if (null
            != R4EUIModelController.getActiveReview()) { // do not do this for participants lists
          try {
            currentParticipant =
                R4EUIModelController.getActiveReview()
                    .getParticipant(newParticipant.getId(), false);
          } catch (ResourceHandlingException e) {
            // ignore
          }
          if (fReviewSource
              && R4EUIModelController.getActiveReview().isParticipant(newParticipant.getId())
              && null != currentParticipant
              && currentParticipant.isEnabled()) {
            final ErrorDialog dialog =
                new ErrorDialog(
                    null,
                    R4EUIConstants.DIALOG_TITLE_ERROR,
                    "Cannot Add Participant " + newParticipant.getId(),
                    new Status(
                        IStatus.ERROR,
                        R4EUIPlugin.PLUGIN_ID,
                        0,
                        "Participant already part of this Review",
                        null),
                    IStatus.ERROR);
            dialog.open();
            continue;
          }

          // Validate Roles (optional)
          if (0 == newParticipant.getRoles().size()) {
            // If there is no roles defined, put one as default depending on the review type
            if (R4EUIModelController.getActiveReview()
                .getReview()
                .getType()
                .equals(R4EReviewType.BASIC)) {
              newParticipant.getRoles().add(R4EUserRole.LEAD);
            } else {
              newParticipant.getRoles().add(R4EUserRole.REVIEWER);
            }
          }
        }
        validatedParticipants.add(newParticipant);
      }
      // Set the participant list to include only the validated participants
      fParticipants = validatedParticipants;
    }
    super.buttonPressed(buttonId);
  }