/**
  * Method itemsUpdated.
  *
  * @param aItems Item[]
  * @param aInstanceId int
  * @see org.eclipse.mylyn.reviews.r4e.ui.internal.utils.IEditableListListener#itemsUpdated(Item[],
  *     int)
  */
 public void itemsUpdated(Item[] aItems, int aInstanceId) {
   if (fSelectedParticipantIndex >= 0) {
     final R4EParticipant participant = fParticipants.get(fSelectedParticipantIndex);
     if (0 == aInstanceId) {
       // Update roles
       participant.getRoles().clear();
       for (Item item : aItems) {
         R4EUserRole role = R4EUIParticipant.mapStringToRole(item.getText());
         if (null != role) {
           participant.getRoles().add(role);
         }
       }
     }
   }
 }
  /**
   * 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);
  }