Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Parker2014-12-26 17:45:03 -0500
committerGerrit Code Review @ Eclipse.org2015-01-08 14:26:09 -0500
commit45794769f2173636770727e1c11596f251cae708 (patch)
treef3c2a615646421964fecd649cd1d22bbe375efaf /org.eclipse.mylyn.reviews.ui/src
parentd3b9a5f66ea5bac954812aa3e7d5ffd066a173fa (diff)
downloadorg.eclipse.mylyn.reviews-45794769f2173636770727e1c11596f251cae708.tar.gz
org.eclipse.mylyn.reviews-45794769f2173636770727e1c11596f251cae708.tar.xz
org.eclipse.mylyn.reviews-45794769f2173636770727e1c11596f251cae708.zip
444500: select last comment in comment input dialog
Change-Id: I8ca411dd95217423e3e517467a7a859233d1c914 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=444500
Diffstat (limited to 'org.eclipse.mylyn.reviews.ui/src')
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java17
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java81
2 files changed, 54 insertions, 44 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java
index 77bf6c1d..bb5c3ebf 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java
@@ -24,10 +24,10 @@ import org.eclipse.mylyn.commons.workbench.forms.CommonFormUtil;
import org.eclipse.mylyn.internal.reviews.ui.IReviewActionListener;
import org.eclipse.mylyn.internal.reviews.ui.dialogs.CommentInputDialog;
import org.eclipse.mylyn.internal.reviews.ui.editors.parts.CommentPart;
+import org.eclipse.mylyn.reviews.core.model.IComment;
import org.eclipse.mylyn.reviews.core.model.ILineLocation;
import org.eclipse.mylyn.reviews.core.model.ILocation;
import org.eclipse.mylyn.reviews.core.model.IReviewItem;
-import org.eclipse.mylyn.reviews.internal.core.model.Comment;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
@@ -49,7 +49,7 @@ import org.eclipse.ui.forms.widgets.Hyperlink;
/**
* Popup to show the information about the annotation in
- *
+ *
* @author Shawn Minto
* @author Guy Perron
*/
@@ -79,7 +79,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
public final boolean openDialogOnHover;
- private List<Comment> commentList;
+ private List<IComment> commentList;
public CommentPopupDialog(Shell parent, int shellStyle) {
this(parent, shellStyle, false, null, null);
@@ -208,7 +208,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
currentPopupDialog = this;
- commentList = new ArrayList<Comment>();
+ commentList = new ArrayList<IComment>();
for (CommentAnnotation annotation : annotationInput.getAnnotations()) {
if (reviewitem == null) {
if (annotation.getComment().getItem() instanceof IReviewItem) {
@@ -225,17 +225,16 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
}
}
- if ((reviewitem != null)
- && reviewitem.getReview() != null
+ if ((reviewitem != null) && reviewitem.getReview() != null
&& reviewitem.getReview().getRepository() != null
&& reviewitem.getReview().getRepository().getAccount() != null
- && reviewitem.getReview().getRepository().getAccount() != ((Comment) annotation.getComment()).getAuthor()
- && ((Comment) annotation.getComment()).isDraft()) {
+ && reviewitem.getReview().getRepository().getAccount() != annotation.getComment().getAuthor()
+ && annotation.getComment().isDraft()) {
continue;
}
CommentPart part = new CommentPart(annotation.getComment(), annotationInput.getBehavior());
- commentList.add((Comment) annotation.getComment());
+ commentList.add(annotation.getComment());
part.hookCustomActionRunListener(this);
Control control = part.createControl(composite, toolkit);
toolkit.adapt(control, true, true);
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java
index 19cd07f4..2ad3d1e6 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java
@@ -13,6 +13,7 @@
package org.eclipse.mylyn.internal.reviews.ui.dialogs;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -38,12 +39,11 @@ import org.eclipse.mylyn.reviews.core.model.ILineLocation;
import org.eclipse.mylyn.reviews.core.model.ILineRange;
import org.eclipse.mylyn.reviews.core.model.IReviewItem;
import org.eclipse.mylyn.reviews.core.model.IReviewItemSet;
+import org.eclipse.mylyn.reviews.core.model.IReviewsFactory;
import org.eclipse.mylyn.reviews.core.model.IUser;
import org.eclipse.mylyn.reviews.core.spi.ReviewsConnector;
import org.eclipse.mylyn.reviews.core.spi.remote.emf.RemoteEmfConsumer;
import org.eclipse.mylyn.reviews.core.spi.remote.review.IReviewRemoteFactoryProvider;
-import org.eclipse.mylyn.reviews.internal.core.model.Comment;
-import org.eclipse.mylyn.reviews.internal.core.model.ReviewsFactory;
import org.eclipse.mylyn.reviews.ui.ReviewBehavior;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
@@ -67,7 +67,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm;
/**
* This class implements the dialog used to fill-in the Comment element details.
- *
+ *
* @author Guy Perron
*/
public class CommentInputDialog extends FormDialog {
@@ -92,7 +92,9 @@ public class CommentInputDialog extends FormDialog {
private final LineRange range;
- private List<Comment> commentList;
+ private List<IComment> commentList;
+
+ private List<Button> commentButtons;
private boolean isUpdate = false;
@@ -139,7 +141,7 @@ public class CommentInputDialog extends FormDialog {
return;
}
- IComment comment = ReviewsFactory.eINSTANCE.createComment();
+ IComment comment = IReviewsFactory.INSTANCE.createComment();
comment.setDescription(fCommentInputTextField.getText().trim());
switch (buttonId) {
case BUTTON_EDIT_ID:
@@ -190,8 +192,8 @@ public class CommentInputDialog extends FormDialog {
}
private ILineLocation getSelectedLineLocation() {
- ILineLocation location = ReviewsFactory.eINSTANCE.createLineLocation();
- ILineRange lineRange = ReviewsFactory.eINSTANCE.createLineRange();
+ ILineLocation location = IReviewsFactory.INSTANCE.createLineLocation();
+ ILineRange lineRange = IReviewsFactory.INSTANCE.createLineRange();
lineRange.setStart(range.getStartLine());
lineRange.setEnd(range.getStartLine() + range.getNumberOfLines());
location.getRanges().add(lineRange);
@@ -277,7 +279,7 @@ public class CommentInputDialog extends FormDialog {
file = ((IFileVersion) item).getFile();
}
if (file != null && file.getReview() != null) {
- // Update any review item set observers IFF we belong to a review. (The set might represent a compare,
+ // Update any review item set observers IFF we belong to a review. (The set might represent a compare,
// in which case we won't have a relevant model object.)
updateConsumer(file);
@@ -310,6 +312,14 @@ public class CommentInputDialog extends FormDialog {
}
@Override
+ protected Control createContents(Composite parent) {
+ Control contents = super.createContents(parent);
+ selectComment(commentList.get(commentList.size() - 1));
+ commentButtons.get(commentButtons.size() - 1).setSelection(true);
+ return contents;
+ }
+
+ @Override
protected void createFormContent(final IManagedForm mform) {
final ScrolledForm scrolledform = mform.getForm();
scrolledform.setExpandVertical(true);
@@ -323,16 +333,13 @@ public class CommentInputDialog extends FormDialog {
composite.setLayout(layout);
GridData textGridData = null;
- for (Comment comment : commentList) {
- final Button button = new Button(composite, SWT.RADIO);
- button.setBackground(composite.getBackground());
+ commentButtons = new ArrayList<Button>();
+ for (final IComment comment : commentList) {
+ final Button commentSelectionButton = new Button(composite, SWT.RADIO);
+ commentSelectionButton.setBackground(composite.getBackground());
- final String uuid = comment.getId();
- final boolean isDraft = comment.isDraft();
- final String commentText = comment.getDescription();
final String authorAndDate;
- IUser author = comment.getAuthor();
- if (author != null) {
+ if (comment.getAuthor() != null) {
authorAndDate = comment.getAuthor().getDisplayName() + " " //$NON-NLS-1$
+ comment.getCreationDate().toString();
} else {
@@ -341,27 +348,20 @@ public class CommentInputDialog extends FormDialog {
}
String commentPrefix = StringUtils.abbreviate(comment.getDescription(), 50);
- if (isDraft) {
- button.setText(NLS.bind(Messages.CommentInputDialog_Draft, authorAndDate, commentPrefix));
+ if (comment.isDraft()) {
+ commentSelectionButton.setText(NLS.bind(Messages.CommentInputDialog_Draft, authorAndDate, commentPrefix));
} else {
- button.setText(authorAndDate + " " + commentPrefix); //$NON-NLS-1$
+ commentSelectionButton.setText(authorAndDate + " " + commentPrefix); //$NON-NLS-1$
}
- button.addSelectionListener(new SelectionAdapter() {
+ commentSelectionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- disposeButtons();
- if (isDraft) {
- createEdit();
- } else {
- createReplyReplyDone();
- }
- currentUuid = uuid;
- fCommentInputTextField.setText(commentText);
- isUpdate = true;
+ selectComment(comment);
}
});
- GridDataFactory.fillDefaults().span(2, 1).applyTo(button);
+ GridDataFactory.fillDefaults().span(2, 1).applyTo(commentSelectionButton);
+ commentButtons.add(commentSelectionButton);
}
fCommentInputTextField = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP);
@@ -377,7 +377,6 @@ public class CommentInputDialog extends FormDialog {
fCommentInputTextField.setFocus();
this.setHelpAvailable(false);
-
}
@Override
@@ -412,10 +411,22 @@ public class CommentInputDialog extends FormDialog {
return true;
}
- public void setComments(List<Comment> commentList) {
+ public void setComments(List<IComment> commentList) {
this.commentList = commentList;
}
+ private void selectComment(final IComment comment) {
+ disposeButtons();
+ if (comment.isDraft()) {
+ createEdit();
+ } else {
+ createReplyReplyDone();
+ }
+ currentUuid = comment.getId();
+ fCommentInputTextField.setText(comment.getDescription());
+ isUpdate = true;
+ }
+
private void disposeButtons() {
for (int buttonId : new int[] { BUTTON_REPLY_ID, BUTTON_REPLY_DONE_ID, BUTTON_DISCARD_ID, BUTTON_EDIT_ID,
BUTTON_SAVE_ID }) {
@@ -424,8 +435,9 @@ public class CommentInputDialog extends FormDialog {
button.dispose();
}
}
- fCommentInputTextField.setEnabled(false);
-
+ if (fCommentInputTextField != null) {
+ fCommentInputTextField.setEnabled(false);
+ }
}
private void createEdit() {
@@ -453,5 +465,4 @@ public class CommentInputDialog extends FormDialog {
buttonBar.pack();
}
-
}

Back to the top