/** * Method decorateText. * * @param aText String * @param aElement Object * @return String * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(String, Object) */ public String decorateText(String aText, Object aElement) { if (aElement instanceof R4EUIFileContext) { if (!CommandUtils.useWorkspaceResource( ((R4EUIFileContext) aElement).getTargetFileVersion())) { // File is not in sync with file present in workspace return "> " + aText; } } return null; }
/** * 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); }