if (parentComment.getAuthor() != null) {
replyPromptMessage = "Reply To: " + parentComment.getAuthor().getUsername();
} else if (!StringUtils.isEmpty(parentComment.getEmail())) {
replyPromptMessage = "Reply To: " + parentComment.getEmail();
}
PromptDialogBox dialog = new PromptDialogBox(replyPromptMessage, "Submit", null, "Cancel", false, true);
dialog.setAllowKeyboardEvents(false);
VerticalPanel replyPanel = new VerticalPanel();
final TextArea textArea = new TextArea();
textArea.setCharacterWidth(60);
textArea.setVisibleLines(4);
final TextBox emailTextBox = new TextBox();
if (AuthenticationHandler.getInstance().getUser() == null) {
replyPanel.add(new Label("Email:"));
replyPanel.add(emailTextBox);
}
replyPanel.add(textArea);
dialog.setFocusWidget(textArea);
dialog.setContent(replyPanel);
dialog.setValidatorCallback(new IDialogValidatorCallback() {
public boolean validate() {
if (textArea.getText() == null || "".equals(textArea.getText())) {
MessageDialogBox dialog = new MessageDialogBox("Error", "Comment is blank.", false, true, true);
dialog.center();
return false;
}
return true;
}
});
dialog.setCallback(new IDialogCallback() {
public void okPressed() {
Comment newComment = new Comment();
newComment.setGlobalRead(true);
newComment.setOwner(permissibleObject.getOwner());
newComment.setAuthor(AuthenticationHandler.getInstance().getUser());
newComment.setComment(textArea.getText());
newComment.setParent(permissibleObject);
newComment.setParentComment(parentComment);
newComment.setEmail(emailTextBox.getText());
submitComment(newComment);
}
public void cancelPressed() {
}
});
dialog.center();
}