Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchris.poon2015-06-10 13:14:35 -0400
committerSam Davis2015-08-21 14:32:11 -0400
commitcbc486fc22891bd2b5c8ab27bd2c9e3874f69e1b (patch)
tree867a267e2d7c18eebf900c0eeacfbe22c9f38db5 /org.eclipse.mylyn.reviews.ui/src
parent5a7cf080ebd4fbd915ef4881d814c9777ffae73c (diff)
downloadorg.eclipse.mylyn.reviews-cbc486fc22891bd2b5c8ab27bd2c9e3874f69e1b.tar.gz
org.eclipse.mylyn.reviews-cbc486fc22891bd2b5c8ab27bd2c9e3874f69e1b.tar.xz
org.eclipse.mylyn.reviews-cbc486fc22891bd2b5c8ab27bd2c9e3874f69e1b.zip
468560: improve inline comment dialog
Change-Id: Id914fec09789f1ac75d0b0e4217f7d5bb8cbf9b1 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=468560 Signed-off-by: chris.poon <chris.poon@tasktop.com>
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/CommentInformationControl.java14
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java439
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentEditor.java346
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentSubmitter.java275
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/Messages.java18
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/messages.properties14
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java16
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java468
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/Messages.java51
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/messages.properties21
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java1
11 files changed, 1022 insertions, 641 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentInformationControl.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentInformationControl.java
index 4a9cd46f..d0c255a2 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentInformationControl.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentInformationControl.java
@@ -51,7 +51,7 @@ public class CommentInformationControl extends DefaultInformationControl impleme
public CommentInformationControl(Shell parent, CommentInformationControlCreator crucibleInformationControlCreator) {
super(parent, new HTMLTextPresenter(true));
this.informationControlCreator = crucibleInformationControlCreator;
- commentPopupDialog = new CommentPopupDialog(parent, SWT.NO_FOCUS | SWT.ON_TOP);
+ commentPopupDialog = new CommentPopupDialog(parent, SWT.NO_FOCUS | SWT.ON_TOP, null, null, false);
// Force create early so that listeners can be added at all times with API.
commentPopupDialog.create();
commentPopupDialog.setInformationControl(this);
@@ -117,7 +117,6 @@ public class CommentInformationControl extends DefaultInformationControl impleme
@Override
public void setVisible(boolean visible) {
cancelMarkCommentAsReadJob();
-
if (input instanceof String) {
setInformation((String) input);
super.setVisible(visible);
@@ -125,6 +124,8 @@ public class CommentInformationControl extends DefaultInformationControl impleme
if (visible) {
commentPopupDialog.open();
runMarkCommentAsReadJob((CommentAnnotationHoverInput) input);
+ } else if (commentPopupDialog.hasEdits()) {
+ return;
} else {
commentPopupDialog.getShell().setVisible(false);
}
@@ -135,10 +136,12 @@ public class CommentInformationControl extends DefaultInformationControl impleme
@Override
public void dispose() {
- cancelMarkCommentAsReadJob();
+ if (!commentPopupDialog.hasEdits()) {
+ cancelMarkCommentAsReadJob();
- commentPopupDialog.dispose();
- commentPopupDialog = null;
+ commentPopupDialog.dispose(false);
+ commentPopupDialog = null;
+ }
}
@Override
@@ -220,7 +223,6 @@ public class CommentInformationControl extends DefaultInformationControl impleme
@Override
public void setFocus() {
-
if (input instanceof String) {
super.setFocus();
} else if (input instanceof CommentAnnotationHoverInput) {
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 bc5060ac..ca81d2a4 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
@@ -13,43 +13,44 @@
package org.eclipse.mylyn.internal.reviews.ui.annotations;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.PopupDialog;
-import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.text.source.LineRange;
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.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseTrackAdapter;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.Section;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
/**
* Popup to show the information about the annotation in
- *
+ *
* @author Shawn Minto
* @author Guy Perron
*/
@@ -57,6 +58,12 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
private static final int MAX_WIDTH = 500;
+ private static final int MIN_HEIGHT = 70;
+
+ private static final int ICON_BUFFER = 16;
+
+ private Text helpText;
+
private int maxWidth;
private CommentAnnotationHoverInput annotationInput;
@@ -69,37 +76,56 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
private CommentInformationControl informationControl;
- private IReviewItem reviewitem;
+ private IReviewItem reviewItem;
private LineRange range;
private static CommentPopupDialog currentPopupDialog;
- private CommentInputDialog currentCommentInputDialog = null;
+ private boolean editable;
- public final boolean openDialogOnHover;
+ private final boolean isCommentNavigator;
private List<IComment> commentList;
- public CommentPopupDialog(Shell parent, int shellStyle) {
- this(parent, shellStyle, false, null, null);
- }
-
- public CommentPopupDialog(Shell parent, int shellStyle, boolean openDialogOnHover, IReviewItem reviewitm,
- LineRange range) {
+ private InlineCommentEditor commentEditor;
+
+ /**
+ * Creates a dialog that displays review comments associated to a line in a given file
+ *
+ * @param parent
+ * the parent shell of the dialog
+ * @param shellStyle
+ * the SWT styles that will be applied to the dialog
+ * @param reviewitm
+ * the item/file that is being viewed
+ * @param range
+ * the line(s) that the comments are associated with
+ * @param isCommentNavigator
+ * true if the dialog is being created via the Previous/Next comment action (and not via hover)
+ */
+ public CommentPopupDialog(Shell parent, int shellStyle, IReviewItem reviewitm, LineRange range,
+ boolean isCommentNavigator) {
super(parent, shellStyle, false, false, false, false, false, null, null);
- this.openDialogOnHover = openDialogOnHover;
- this.reviewitem = reviewitm;
+ this.reviewItem = reviewitm;
this.range = range;
+ this.editable = true;
+ this.isCommentNavigator = isCommentNavigator;
}
+ /**
+ * Creates the scrolled composite and inner composite for the dialog
+ */
@Override
protected Control createDialogArea(Composite parent) {
toolkit = new FormToolkit(CommonFormUtil.getSharedColors());
scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL);
+ GridLayoutFactory.fillDefaults().applyTo(scrolledComposite);
+ GridDataFactory.fillDefaults().grab(false, false).applyTo(scrolledComposite);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
+ scrolledComposite.getVerticalBar().setPageIncrement(4);
toolkit.adapt(scrolledComposite);
composite = toolkit.createComposite(scrolledComposite, SWT.NONE);
@@ -109,13 +135,60 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
return scrolledComposite;
}
- public void dispose() {
- currentPopupDialog = null;
+ /**
+ * The default close action for the dialog (not force close)
+ */
+ @Override
+ public boolean close() {
+ return close(false);
+ }
- close();
- toolkit.dispose();
+ /**
+ * Closes the dialog
+ *
+ * @param force
+ * true if the dialog should close under all conditions, false if the dialog should check for edited text
+ * in the editor
+ * @return true if the dialog has been closed, false otherwise
+ */
+ protected boolean close(boolean force) {
+ if (!force && hasEdits()) {
+ return false;
+ }
+ if (editable) {
+ InlineCommentEditor.removeFromEditMap(reviewItem.getId(), range.getStartLine());
+ }
+ return super.close();
}
+ /**
+ * Disposes the dialog
+ *
+ * @param force
+ * true if the dialog should be disposed under all conditions, false if the dialog should check for
+ * edited text in the editor
+ */
+ public void dispose(boolean force) {
+ if (force || !hasEdits()) {
+ currentPopupDialog = null;
+
+ close(true);
+ toolkit.dispose();
+ }
+ }
+
+ /**
+ * Checks if there are any changes in the comment editor text
+ *
+ * @return true if there is a change with the editor text, false otherwise
+ */
+ public boolean hasEdits() {
+ return commentEditor != null && commentEditor.hasEdits();
+ }
+
+ /**
+ * Sets the focus of the dialog and adjusts the size of the inner composite
+ */
public void setFocus() {
getShell().forceFocus();
@@ -125,11 +198,16 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
Point computeSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (computeSize.y > scrolledComposite.getSize().y) {
- scrolledComposite.setExpandVertical(false);
+ scrolledComposite.setExpandVertical(true);
composite.setSize(computeSize);
}
}
+ /**
+ * Computes the maximum width of the dialog
+ *
+ * @return a {@link Point} containing the max width of the dialog and its default height
+ */
public Point computeSizeHint() {
int widthHint = MAX_WIDTH;
if (maxWidth < widthHint) {
@@ -140,26 +218,64 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
}
public void removeFocusListener(FocusListener listener) {
- currentCommentInputDialog = null;
composite.removeFocusListener(listener);
}
public void addFocusListener(FocusListener listener) {
composite.addFocusListener(listener);
+ }
+ public void removeDisposeListener(DisposeListener listener) {
+ getShell().removeDisposeListener(listener);
+ }
+
+ public void addDisposeListener(DisposeListener listener) {
+ getShell().addDisposeListener(listener);
}
+ /**
+ * Checks to see if the active shell is the shell of this dialog
+ *
+ * @return true if the active shell is the dialog's shell, false otherwise
+ */
public boolean isFocusControl() {
return getShell().getDisplay().getActiveShell() == getShell();
}
- public void removeDisposeListener(DisposeListener listener) {
- getShell().removeDisposeListener(listener);
+ protected Composite getScrolledComposite() {
+ return scrolledComposite;
+ }
+ protected Composite getComposite() {
+ return composite;
}
- public void addDisposeListener(DisposeListener listener) {
- getShell().addDisposeListener(listener);
+ protected InlineCommentEditor getCommentEditor() {
+ return commentEditor;
+ }
+
+ protected IReviewItem getReviewItem() {
+ return reviewItem;
+ }
+
+ protected LineRange getRange() {
+ return range;
+ }
+
+ protected CommentAnnotationHoverInput getAnnotationInput() {
+ return annotationInput;
+ }
+
+ protected Text getHelpText() {
+ return helpText;
+ }
+
+ protected boolean getEditable() {
+ return editable;
+ }
+
+ protected FormToolkit getToolkit() {
+ return toolkit;
}
public Rectangle getBounds() {
@@ -174,29 +290,86 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
this.maxWidth = newMaxWidth;
}
+ /**
+ * Sets the dialog's shell to a position in the monitor (constrained by the size of the user's monitor)
+ *
+ * @param location
+ * the desired location to place the dialog
+ */
public void setLocation(Point location) {
Rectangle bounds = getShell().getBounds();
Rectangle monitorBounds = getShell().getMonitor().getClientArea();
// ensure the popup fits on the shell's monitor
- bounds.x = contrain(location.x, monitorBounds.x, monitorBounds.x + monitorBounds.width - bounds.width);
- bounds.y = contrain(location.y, monitorBounds.y, monitorBounds.y + monitorBounds.height - bounds.height);
+ bounds.x = constrain(location.x, monitorBounds.x, monitorBounds.x + monitorBounds.width - bounds.width);
+ bounds.y = constrain(location.y, monitorBounds.y, monitorBounds.y + monitorBounds.height - bounds.height);
getShell().setLocation(new Point(bounds.x, bounds.y));
}
- private int contrain(int value, int min, int max) {
+ private int constrain(int value, int min, int max) {
return Math.max(min, Math.min(max, value));
}
+ /**
+ * Recomputes and sets the size of the dialog (and its shell and composites) to fit its contents
+ */
+ protected void recomputeSize() {
+ Rectangle bounds = getShell().getBounds();
+ Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+
+ scrolledComposite.setMinSize(size);
+ int height = constrain(size.y, MIN_HEIGHT, getShell().getMonitor().getClientArea().height);
+ getShell().setSize(size.x, height);
+ scrolledComposite.setSize(size.x, height);
+ setLocation(new Point(bounds.x, bounds.y));
+
+ if (commentEditor != null) {
+ Composite editorComposite = commentEditor.getEditorComposite();
+
+ if (scrolledComposite.getVerticalBar().isVisible() && editorComposite != null) {
+ Point commentEditorSize = editorComposite.getSize();
+ editorComposite.setSize(commentEditorSize.x - scrolledComposite.getVerticalBar().getSize().x,
+ commentEditorSize.y);
+ }
+
+ if (editorComposite != null) {
+ scrolledComposite.setOrigin(0, Integer.MAX_VALUE);
+ }
+ }
+ }
+
+ public void setHeightBasedOnMouse(int mouseY) {
+ int mouseYFromBottom = getShell().getMonitor().getClientArea().height - mouseY;
+ recomputeSize();
+ setSize(MAX_WIDTH, constrain(mouseYFromBottom - ICON_BUFFER, MIN_HEIGHT, getShell().getSize().y));
+ }
+
+ /**
+ * Sets the size of the dialog's shell and scrolled composite. The height must be at least minimum height.
+ *
+ * @param width
+ * the width in pixels
+ * @param height
+ * the height in pixels
+ */
public void setSize(int width, int height) {
Point computeSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
if (computeSize.x > width) {
width = computeSize.x;
}
+ height = Math.max(height, MIN_HEIGHT);
+
getShell().setSize(width, height);
scrolledComposite.setSize(width, height);
}
+ /**
+ * Initializes the comment dialog with the comments (and review item/line range if it wasn't provided on
+ * construction) from the {@link CommentAnnotationHoverInput} provided
+ *
+ * @param input
+ * the input of the comment dialog
+ */
public void setInput(Object input) {
if (input instanceof CommentAnnotationHoverInput) {
this.annotationInput = (CommentAnnotationHoverInput) input;
@@ -210,9 +383,9 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
commentList = new ArrayList<IComment>();
for (CommentAnnotation annotation : annotationInput.getAnnotations()) {
- if (reviewitem == null) {
+ if (reviewItem == null) {
if (annotation.getComment().getItem() instanceof IReviewItem) {
- reviewitem = (IReviewItem) annotation.getComment().getItem();
+ reviewItem = (IReviewItem) annotation.getComment().getItem();
}
}
if (range == null) {
@@ -225,10 +398,10 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
}
}
- if ((reviewitem != null) && reviewitem.getReview() != null
- && reviewitem.getReview().getRepository() != null
- && reviewitem.getReview().getRepository().getAccount() != null
- && reviewitem.getReview().getRepository().getAccount() != annotation.getComment().getAuthor()
+ if ((reviewItem != null) && reviewItem.getReview() != null
+ && reviewItem.getReview().getRepository() != null
+ && reviewItem.getReview().getRepository().getAccount() != null
+ && reviewItem.getReview().getRepository().getAccount() != annotation.getComment().getAuthor()
&& annotation.getComment().isDraft()) {
continue;
}
@@ -240,67 +413,168 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
toolkit.adapt(control, true, true);
}
- if (openDialogOnHover) {
- composite.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- openCommentDialog();
- }
- });
- } else {
- Hyperlink hyperlink = toolkit.createHyperlink(composite,
- Messages.CommentPopupDialog_Edit_discard_or_reply, SWT.NONE);
- hyperlink.addHyperlinkListener(new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- openCommentDialog();
- }
- });
- }
-
composite.setBackground(toolkit.getColors().getBackground());
scrolledComposite.layout(true, true);
scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- } else {
- input = null;
+
+ if (InlineCommentEditor.canAddCommentEditor(reviewItem.getId(), range.getStartLine())) {
+ commentEditor = new InlineCommentEditor(this);
+ scrolledComposite.addMouseListener(createRemoveCommentEditorListener());
+ List<Section> sections = getScrolledCompositeSections();
+ for (Section s : sections) {
+ recursivelyAddCommentEditorListener(s, createAddCommentEditorListener());
+ }
+
+ if (!commentList.isEmpty()) {
+ helpText = new Text(composite, SWT.NONE);
+ helpText.setText(Messages.CommentPopupDialog_HelpText);
+ }
+ } else {
+ this.editable = false;
+ }
+
+ if (isCommentNavigator) {
+ InlineCommentEditor.addToEditMap(reviewItem.getId(), range.getStartLine());
+ }
+ }
+ }
+
+ /**
+ * Helper method to return all of the {@link Section} in the dialog's scrolled composite
+ *
+ * @return the list of {@link Section} that are children of the dialog's scrolled composite
+ */
+ protected List<Section> getScrolledCompositeSections() {
+ List<Section> sections = new ArrayList<Section>();
+ if (scrolledComposite.getChildren().length != 0 && scrolledComposite.getChildren()[0] instanceof Composite) {
+ Composite sectionContainer = (Composite) scrolledComposite.getChildren()[0];
+ sections = FluentIterable.from(Arrays.asList(sectionContainer.getChildren()))
+ .filter(Section.class)
+ .toList();
+ }
+ return sections;
+ }
+
+ /**
+ * Adds a mouse listener to the {@link Control} provided and its children
+ *
+ * @param c
+ * the {@link Control} and its {@link Control} children that you want to add mouse listeners to
+ * @param listener
+ * the mouse listener that will be added to the provided {@link Control}
+ */
+ private void recursivelyAddCommentEditorListener(Control c, MouseListener listener) {
+ c.addMouseListener(listener);
+
+ if (c instanceof Composite) {
+ Control[] controls = ((Composite) c).getChildren();
+ for (Control control : controls) {
+ recursivelyAddCommentEditorListener(control, listener);
+ }
}
}
- private void openCommentDialog() {
- PixelConverter Pc = new PixelConverter(composite.getFont());
- final int lineHeight = Pc.convertHeightInCharsToPixels(1);
- if (range != null && reviewitem != null && currentCommentInputDialog == null) {
- dispose();
- Shell ashell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ /**
+ * Given a {@link Control}, it attempts to find parent {@link Section} recursively
+ *
+ * @param c
+ * the {@link Control} that you want to find the parent {@link Section} of
+ * @return the parent {@link Section} or null if it can't be found
+ */
+ private Section findParentSection(Control c) {
+ if (c == null) {
+ return null;
+ } else if (c instanceof Section) {
+ return (Section) c;
+ } else {
+ return findParentSection(c.getParent());
+ }
+ }
- currentCommentInputDialog = new CommentInputDialog(ashell, annotationInput.getBehavior(), reviewitem, range);
+ /**
+ * Creates a mouse down {@link MouseAdapter} to add the comment editor to the dialog. It will attempt to get the
+ * comment associated with the {@link Control} you clicked on.
+ *
+ * @return the {@link MouseAdapter} that can invoke the comment editor on mouse down events
+ */
+ private MouseAdapter createAddCommentEditorListener() {
+ return new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ getShell().setVisible(true);
+
+ IComment comment = null;
+ if (e.getSource() instanceof Control) {
+ Section section;
+ if (isCommentNavigator) {
+ section = getScrolledCompositeSections().get(0);
+ } else {
+ section = findParentSection((Control) e.getSource());
+ }
+ if (section != null && section.getData() != null && section.getData() instanceof IComment) {
+ comment = (IComment) section.getData();
+ }
+ }
- currentCommentInputDialog.setComments(commentList);
- currentCommentInputDialog.create();
- currentCommentInputDialog.getShell().setText(
- NLS.bind(Messages.CommentInputDialog_LineNumber, range.getStartLine(),
- new Path(reviewitem.getName()).lastSegment()));
+ if (comment != null && editable) {
+ commentEditor.createControl(composite, comment);
+ }
+ }
+ };
+ }
- // adjust size to display maximum of 15 lines, which means 5 comments
- Point size = new Point(550, 150);
- if (annotationInput.getAnnotations().size() < 5) {
- size.y = size.y + (annotationInput.getAnnotations().size() * 3 * lineHeight);
- } else {
- size.y = size.y + (15 * lineHeight);
+ /**
+ * Creates a mouse down {@link MouseAdapter} to remove the comment editor
+ *
+ * @return the {@link MouseAdapter} that can remove the comment editor on mouse down events
+ */
+ private MouseAdapter createRemoveCommentEditorListener() {
+ return new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (commentEditor != null) {
+ commentEditor.removeControl();
+ }
}
- currentCommentInputDialog.getShell().setSize(size);
- currentCommentInputDialog.open();
+ };
+ }
+
+ /**
+ * Helper method to get the last comment draft in the dialog's comment list
+ *
+ * @return the last {@link IComment} in the comment list if there is at least one draft in the comment list or null
+ * otherwise
+ */
+ protected IComment getLastCommentDraft() {
+ return FluentIterable.from(commentList).filter(new Predicate<IComment>() {
+ @Override
+ public boolean apply(IComment input) {
+ return input.isDraft();
+ }
+ }).last().orNull();
+ }
+
+ protected void hideHelpText() {
+ if (helpText != null) {
+ helpText.dispose();
+ helpText = null;
}
}
+ /**
+ * Force closes the dialog when an action is about to run
+ */
public void actionAboutToRun(Action action) {
- close();
+ close(true);
}
+ /**
+ * Force close the dialog when an action ran
+ */
public void actionRan(Action action) {
- close();
+ close(true);
}
public static CommentPopupDialog getCurrentPopupDialog() {
@@ -314,5 +588,4 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
public CommentInformationControl getInformationControl() {
return informationControl;
}
-
}
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentEditor.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentEditor.java
new file mode 100644
index 00000000..0cf34237
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentEditor.java
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.reviews.ui.annotations;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.mylyn.reviews.core.model.IComment;
+import org.eclipse.mylyn.reviews.core.model.IReviewItem;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
+public class InlineCommentEditor {
+
+ public enum CommentEditorState {
+ VIEW, REPLY, EDIT, DISCARD;
+ }
+
+ private static final int MIN_COMMENT_EDITOR_HEIGHT = 100;
+
+ private static Multimap<String, Integer> editMap = HashMultimap.create();
+
+ private final CommentPopupDialog dialog;
+
+ private final String reviewItemId;
+
+ private final int startLine;
+
+ private CommentEditorState state;
+
+ private Composite editorComposite;
+
+ private Text commentEditorText;
+
+ private IComment currentComment;
+
+ private Button saveButton;
+
+ private Button discardOrDoneButton;
+
+ private Button cancelButton;
+
+ private String originalComment;
+
+ /**
+ * Creates a comment editor for the provided dialog and sets its reviewItemId and startLine. Also initializes the
+ * state of the editor to VIEW.
+ *
+ * @param dialog
+ * the {@link CommentPopupDialog} that the editor is adding to
+ */
+ protected InlineCommentEditor(CommentPopupDialog dialog) {
+ this.dialog = dialog;
+ this.reviewItemId = dialog.getReviewItem().getId();
+ this.startLine = dialog.getRange().getStartLine();
+ this.state = CommentEditorState.VIEW;
+ }
+
+ /**
+ * Creates the UI for the comment editor
+ *
+ * @param parent
+ * the parent {@link Composite} of the comment editor
+ * @param clickedComment
+ * the comment that was clicked on in the dialog
+ */
+ protected void createControl(Composite parent, final IComment clickedComment) {
+ dialog.hideHelpText();
+ addToEditMap(reviewItemId, startLine);
+
+ if (editorComposite == null) {
+ editorComposite = new Composite(parent, SWT.NONE);
+ editorComposite.setSize(editorComposite.getSize().x, MIN_COMMENT_EDITOR_HEIGHT);
+ editorComposite.setBackground(dialog.getToolkit().getColors().getBackground());
+
+ GridData textGridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ commentEditorText = new Text(editorComposite, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
+ commentEditorText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ if (saveButton != null) {
+ if (StringUtils.isEmpty(((Text) e.widget).getText())) {
+ saveButton.setEnabled(false);
+ discardOrDoneButton.setEnabled(true);
+ } else {
+ discardOrDoneButton.setEnabled(currentComment == null || currentComment.isDraft());
+ saveButton.setEnabled(true);
+ }
+ }
+ }
+ });
+ commentEditorText.addKeyListener(createAddSaveKeyListener());
+ textGridData.minimumHeight = commentEditorText.getLineHeight() * 4;
+ textGridData.verticalSpan = 4;
+ commentEditorText.setLayoutData(textGridData);
+
+ Composite buttonContainer = new Composite(editorComposite, SWT.NONE);
+ buttonContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ GridData buttonGridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ buttonGridData.verticalSpan = 1;
+ GridLayoutFactory.fillDefaults().spacing(1, 1).numColumns(3).applyTo(buttonContainer);
+
+ saveButton = createButton(buttonContainer, Messages.CommentPopupDialog_Save, buttonGridData,
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ saveCommentAction();
+ }
+ });
+ discardOrDoneButton = createButton(buttonContainer, null, buttonGridData, new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (currentComment.isDraft()) {
+ setState(CommentEditorState.DISCARD);
+ } else {
+ commentEditorText.setText(Messages.CommentPopupDialog_Done);
+ setState(CommentEditorState.REPLY);
+ }
+ saveComment();
+ }
+ });
+ cancelButton = createButton(buttonContainer, Messages.CommentPopupDialog_Cancel, buttonGridData,
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ removeControl();
+ }
+ });
+
+ editorComposite.setLayout(new GridLayout(1, false));
+ editorComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+
+ dialog.recomputeSize();
+ }
+
+ if (clickedComment != null && currentComment == null) {
+ IComment lastDraft = dialog.getLastCommentDraft();
+ if (!clickedComment.isDraft() && lastDraft != null) {
+ currentComment = lastDraft;
+ } else {
+ currentComment = clickedComment;
+ }
+
+ if (currentComment.isDraft()) {
+ commentEditorText.setText(currentComment.getDescription());
+ discardOrDoneButton.setText(Messages.CommentPopupDialog_Discard);
+ } else {
+ commentEditorText.setText(""); //$NON-NLS-1$
+ discardOrDoneButton.setText(Messages.CommentPopupDialog_ReplyDone);
+ }
+
+ if (originalComment == null) {
+ originalComment = commentEditorText.getText();
+ }
+ commentEditorText.setFocus();
+ }
+ }
+
+ /**
+ * Removes the comment editor from the UI
+ */
+ protected void removeControl() {
+ if (commentEditorText != null && StringUtils.isNotEmpty(commentEditorText.getText())) {
+ addToEditMap(reviewItemId, startLine);
+ originalComment = null;
+ }
+ if (editorComposite != null) {
+ editorComposite.dispose();
+ }
+ editorComposite = null;
+ commentEditorText = null;
+ currentComment = null;
+
+ setState(CommentEditorState.VIEW);
+ dialog.recomputeSize();
+ }
+
+ /**
+ * Force disposes the comment dialog (which will also dispose the comment editor)
+ */
+ protected void forceDispose() {
+ dialog.dispose(true);
+ }
+
+ /**
+ * Checks if the text in the comment editor has changed from the original comment
+ *
+ * @return true if the text in the editor is different than the original comment text, false otherwise
+ */
+ protected boolean hasEdits() {
+ return editorComposite != null && !editorComposite.isDisposed() && commentEditorText != null
+ && !commentEditorText.getText().equals(originalComment);
+ }
+
+ protected Composite getEditorComposite() {
+ return editorComposite;
+ }
+
+ protected Text getCommentEditorText() {
+ return commentEditorText;
+ }
+
+ protected Button getSaveButton() {
+ return saveButton;
+ }
+
+ protected Button getDiscardOrDoneButton() {
+ return discardOrDoneButton;
+ }
+
+ protected Button getCancelButton() {
+ return cancelButton;
+ }
+
+ protected IComment getCurrentComment() {
+ return currentComment;
+ }
+
+ protected CommentEditorState getState() {
+ return state;
+ }
+
+ protected void setState(CommentEditorState state) {
+ this.state = state;
+ }
+
+ /**
+ * Adds an entry to the static edit map for a particular review item and start line
+ *
+ * @param reviewItemId
+ * the id of a {@link IReviewItem}
+ * @param startLine
+ * the start line number of a {@link LineRange}
+ */
+ protected static void addToEditMap(String reviewItemId, int startLine) {
+ editMap.put(reviewItemId, startLine);
+ }
+
+ /**
+ * Removes an entry from the static edit map for a particular review item and start line
+ *
+ * @param reviewItemId
+ * the id of a {@link IReviewItem}
+ * @param startLine
+ * the start line number of a {@link LineRange}
+ */
+ protected static void removeFromEditMap(String reviewItemId, int startLine) {
+ editMap.remove(reviewItemId, startLine);
+ }
+
+ /**
+ * Checks the edit map for an entry for a particular review item and start line
+ *
+ * @param reviewItemId
+ * the id of a {@link IReviewItem}
+ * @param startLine
+ * the start line number of a {@link LineRange}
+ * @return true if there is an entry in the edit map, false otherwise
+ */
+ protected static boolean canAddCommentEditor(String reviewItemId, int startLine) {
+ return !editMap.containsEntry(reviewItemId, startLine);
+ }
+
+ /**
+ * Helper method to add a {@link Button} to the UI
+ *
+ * @param parent
+ * the parent {@link Composite} that we want to add the button to
+ * @param text
+ * the button's text
+ * @param gridData
+ * the button's layout grid data
+ * @param listener
+ * the {@link SelectionListener} that will be added to the button
+ * @return a {@link Button} with properties provided by the method's parameters
+ */
+ private Button createButton(Composite parent, String text, GridData gridData, SelectionListener listener) {
+ Button button = new Button(parent, SWT.PUSH);
+ if (text != null) {
+ button.setText(text);
+ }
+ button.setLayoutData(gridData);
+ button.addSelectionListener(listener);
+ return button;
+ }
+
+ /**
+ * Add a key listener for Ctrl/Cmd+Enter/Return to save the comment
+ *
+ * @return the {@link KeyAdapater} that will save the comment on Ctrl/Cmd+Enter/Return
+ */
+ private KeyAdapter createAddSaveKeyListener() {
+ return new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if ((e.stateMask & SWT.CTRL) != 0 && (e.keyCode == SWT.CR || e.keyCode == SWT.LF)) {
+ saveCommentAction();
+ }
+ }
+ };
+ }
+
+ /**
+ * Sets the state of the editor based on the current comment's draft status (true if the submitted comment is a
+ * comment edit, false if it is a new comment draft) and invokes a save comment action
+ */
+ private void saveCommentAction() {
+ if (currentComment.isDraft()) {
+ setState(CommentEditorState.EDIT);
+ } else {
+ setState(CommentEditorState.REPLY);
+ }
+ saveComment();
+ }
+
+ /**
+ * Creates a {@link InlineCommentSubmitter} to submit a comment
+ */
+ private void saveComment() {
+ InlineCommentSubmitter submitter = new InlineCommentSubmitter(dialog.getReviewItem(), dialog.getRange(),
+ dialog.getAnnotationInput(), this);
+ submitter.saveComment();
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentSubmitter.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentSubmitter.java
new file mode 100644
index 00000000..69b3c67c
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/InlineCommentSubmitter.java
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2014, 2015 Ericsson AB and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Guy Perron - original version
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.internal.reviews.ui.annotations;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.source.LineRange;
+import org.eclipse.mylyn.internal.reviews.ui.annotations.InlineCommentEditor.CommentEditorState;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.reviews.core.model.IComment;
+import org.eclipse.mylyn.reviews.core.model.IFileItem;
+import org.eclipse.mylyn.reviews.core.model.IFileVersion;
+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.ui.ReviewBehavior;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.swt.widgets.Display;
+
+public class InlineCommentSubmitter {
+
+ public static final String JOB_FAMILY = "CommentPopupDialogJobFamily"; // For Testing purposes //$NON-NLS-1$
+
+ private final IReviewItem reviewitem;
+
+ private final LineRange range;
+
+ private final CommentAnnotationHoverInput annotationInput;
+
+ private final InlineCommentEditor commentEditor;
+
+ /**
+ * Creates a comment submitter
+ *
+ * @param reviewitem
+ * the submitted comment's review item
+ * @param range
+ * the submitted comment's line range
+ * @param annotationInput
+ * the {@link CommentAnnotationHoverInput} associated with the dialog
+ * @param commentEditor
+ * the comment editor that this submitter is dependent on
+ */
+ public InlineCommentSubmitter(IReviewItem reviewitem, LineRange range, CommentAnnotationHoverInput annotationInput,
+ InlineCommentEditor commentEditor) {
+ this.reviewitem = reviewitem;
+ this.range = range;
+ this.annotationInput = annotationInput;
+ this.commentEditor = commentEditor;
+ }
+
+ /**
+ * Creates a new comment, sets the comment's parameters based on the editor's current comment and text, and submits
+ * the comment
+ */
+ public void saveComment() {
+ if (!commentEditor.getState().equals(CommentEditorState.VIEW)
+ && (commentEditor.getState().equals(CommentEditorState.DISCARD) || StringUtils.isNotEmpty(commentEditor.getCommentEditorText()
+ .getText()
+ .trim()))) {
+ IComment comment = IReviewsFactory.INSTANCE.createComment();
+ comment.setDescription(commentEditor.getCommentEditorText().getText().trim());
+
+ if (commentEditor.getCurrentComment().isDraft()) {
+ comment.setId(commentEditor.getCurrentComment().getId());
+ }
+
+ comment.setDraft(true);
+ comment.setAuthor(getCurrentUser());
+ comment.setCreationDate(new Date());
+
+ ILineLocation location = getSelectedLineLocation();
+ if (location != null) {
+ comment.getLocations().add(location);
+ }
+ performOperation(comment);
+
+ commentEditor.forceDispose();
+ }
+ }
+
+ /**
+ * Performs a save or discard action
+ *
+ * @param comment
+ * the comment draft that will be added, edited or discarded from the comment thread
+ */
+ private void performOperation(final IComment comment) {
+ final IReviewItem item = reviewitem;
+ final AtomicReference<IStatus> result = new AtomicReference<IStatus>();
+ final ReviewBehavior reviewBehavior = annotationInput.getBehavior();
+
+ if (!commentEditor.getState().equals(CommentEditorState.VIEW)) {
+ final Job job = new Job(Messages.CommandServerOperation) {
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return family.equals(JOB_FAMILY);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ IStatus status = null;
+
+ switch (commentEditor.getState()) {
+ case REPLY:
+ case EDIT:
+ status = reviewBehavior.addComment(item, comment, monitor);
+ if (status.isOK()) {
+ result.set(status);
+ updateClient(comment, item);
+ return Status.OK_STATUS;
+ }
+ break;
+ case DISCARD:
+ status = reviewBehavior.discardComment(item, comment, monitor);
+ if (status.isOK()) {
+ result.set(status);
+ updateClient(comment, item);
+ return Status.OK_STATUS;
+ }
+ break;
+ default:
+ Assert.isTrue(false, "Unknown state " + commentEditor.getState()); //$NON-NLS-1$
+ }
+ processServerError(status.getMessage());
+
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ }
+
+ /**
+ * Updates the UI with the result of the comment operation (either a new comment draft, draft comment edit or
+ * discard comment action)
+ *
+ * @param comment
+ * the comment that the operation was done on
+ * @param item
+ * the item that will be updated
+ */
+ private void updateClient(final IComment comment, final IReviewItem item) {
+ comment.setAuthor(getCurrentUser());
+
+ if (commentEditor.getState().equals(CommentEditorState.REPLY)) {
+ item.getComments().add(comment);
+ } else if (commentEditor.getState().equals(CommentEditorState.DISCARD)) {
+ List<IComment> commentlist = item.getComments();
+ for (Iterator<IComment> iter = commentlist.iterator(); iter.hasNext();) {
+ IComment element = iter.next();
+ if (element.getId() != null && element.getId().equals(commentEditor.getCurrentComment().getId())) {
+ iter.remove();
+ break;
+ }
+ }
+ } else {
+ List<IComment> commentlist = item.getComments();
+ for (int i = 0; i < commentlist.size(); i++) {
+ if (commentlist.get(i).getId() != null
+ && commentlist.get(i).getId().equals(commentEditor.getCurrentComment().getId())) {
+ item.getComments().set(i, comment);
+ break;
+ }
+ }
+
+ }
+
+ IFileItem file = null;
+ if (item instanceof IFileItem) {
+ file = (IFileItem) item;
+ } else if (item instanceof IFileVersion) {
+ 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,
+ // in which case we won't have a relevant model object.)
+ updateConsumer(file);
+
+ }
+ }
+
+ /**
+ * Creates an error dialog for unsuccessful comment actions
+ *
+ * @param message
+ * the message that will be displayed to the user
+ */
+ private void processServerError(final String message) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ final MessageDialog dialog = new MessageDialog(null, Messages.CommentPopupDialog_ServerError, null,
+ message, MessageDialog.ERROR, new String[] { IDialogConstants.CANCEL_LABEL }, 0);
+ dialog.open();
+ }
+ });
+ }
+
+ /**
+ * Updates the file with the new changes
+ *
+ * @param file
+ * the file that will be updated
+ */
+ private void updateConsumer(IFileItem file) {
+ final ReviewBehavior reviewBehavior = annotationInput.getBehavior();
+ TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(
+ reviewBehavior.getTask().getConnectorKind(), reviewBehavior.getTask().getRepositoryUrl());
+ @SuppressWarnings("restriction")
+ ReviewsConnector connector = (ReviewsConnector) TasksUiPlugin.getConnector(reviewBehavior.getTask()
+ .getConnectorKind());
+ IReviewRemoteFactoryProvider factoryProvider = (IReviewRemoteFactoryProvider) connector.getReviewClient(
+ taskRepository).getFactoryProvider();
+
+ RemoteEmfConsumer<IReviewItemSet, List<IFileItem>, String, ?, ?, Long> consumer = factoryProvider.getReviewItemSetContentFactory()
+ .getConsumerForLocalKey(file.getSet(), file.getSet().getId());
+ consumer.updateObservers();
+ consumer.release();
+ }
+
+ /**
+ * @return the current {@link IUser} for this repository
+ */
+ private IUser getCurrentUser() {
+ if (reviewitem != null && reviewitem.getReview() != null && reviewitem.getReview().getRepository() != null) {
+ return reviewitem.getReview().getRepository().getAccount();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return a {@ILineLocation} created from the {@link ILineRange} provided in the constructor
+ */
+ protected ILineLocation getSelectedLineLocation() {
+ ILineLocation location = IReviewsFactory.INSTANCE.createLineLocation();
+ ILineRange lineRange = IReviewsFactory.INSTANCE.createLineRange();
+ lineRange.setStart(range.getStartLine());
+ lineRange.setEnd(range.getStartLine() + range.getNumberOfLines());
+ location.getRanges().add(lineRange);
+ return location;
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/Messages.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/Messages.java
index 98b44325..e2eaa261 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/Messages.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/Messages.java
@@ -20,9 +20,23 @@ public class Messages extends NLS {
public static String CommentAnnotationHover_Multiple_comments;
- public static String CommentInputDialog_LineNumber;
+ public static String CommentPopupDialog_LineNumber;
- public static String CommentPopupDialog_Edit_discard_or_reply;
+ public static String CommandServerOperation;
+
+ public static String CommentPopupDialog_ServerError;
+
+ public static String CommentPopupDialog_ReplyDone;
+
+ public static String CommentPopupDialog_Discard;
+
+ public static String CommentPopupDialog_Cancel;
+
+ public static String CommentPopupDialog_Save;
+
+ public static String CommentPopupDialog_Done;
+
+ public static String CommentPopupDialog_HelpText;
static {
// initialize resource bundle
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/messages.properties b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/messages.properties
index dc6ef242..f0c57f0a 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/messages.properties
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/messages.properties
@@ -10,6 +10,16 @@
###############################################################################
CommentAnnotation_X_dash_Y={0} - {1}
CommentAnnotationHover_Multiple_comments=There are multiple comments on this line
-CommentInputDialog_LineNumber=Comments for line {0} of {1}
+CommentPopupDialog_LineNumber=Comments for line {0} of {1}
-CommentPopupDialog_Edit_discard_or_reply=Edit, discard, or reply
+CommentPopupDialog_ReplyDone=Reply 'Done'
+CommentPopupDialog_Discard=Discard
+CommentPopupDialog_Cancel=Cancel
+CommentPopupDialog_Save=Save
+
+CommentPopupDialog_Done=Done
+
+CommandServerOperation=Updating inline comments
+CommentPopupDialog_ServerError=Server Connection Error
+
+CommentPopupDialog_HelpText=Click on a comment to reply/edit \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java
index 0b23f61d..8c22e5eb 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java
@@ -56,7 +56,7 @@ import org.eclipse.ui.texteditor.AbstractTextEditor;
/**
* Manages annotation models for compare viewers.
- *
+ *
* @author Thomas Ehrnhoefer
* @author Steffen Pingel
* @author Guy Perron
@@ -178,7 +178,7 @@ public class ReviewCompareAnnotationSupport {
/**
* Jumps to the next annotation according to the given direction.
- *
+ *
* @param direction
* the search direction
* @return the selected annotation or <code>null</code> if none
@@ -326,19 +326,19 @@ public class ReviewCompareAnnotationSupport {
LineRange range = new LineRange(p.x + 1, p.y);
if (commentPopupDialog != null) {
- commentPopupDialog.dispose();
+ commentPopupDialog.dispose(false);
commentPopupDialog = null;
}
-
commentPopupDialog = new CommentPopupDialog(ReviewsUiPlugin.getDefault()
.getWorkbench()
.getActiveWorkbenchWindow()
- .getShell(), SWT.NO_FOCUS | SWT.ON_TOP, true, reviewitem, range);
+ .getShell(), SWT.NO_FOCUS | SWT.ON_TOP, reviewitem, range, true);
CommentAnnotationHoverInput input = new CommentAnnotationHoverInput(comments,
((ReviewAnnotationModel) srcViewer.getAnnotationModel()).getBehavior());
commentPopupDialog.create();
commentPopupDialog.setInput(input);
- commentPopupDialog.setSize(50, 150);
+
+ commentPopupDialog.setHeightBasedOnMouse(Display.getCurrent().getCursorLocation().y);
Point location = sourceViewer.getSourceViewer().getControl().getLocation();
location = Display.getCurrent().getCursorLocation();
@@ -461,7 +461,7 @@ public class ReviewCompareAnnotationSupport {
/**
* Returns the annotation closest to the given range respecting the given direction. If an annotation is found, the
* annotations current position is copied into the provided annotation position.
- *
+ *
* @param viewer
* the viewer
* @param direction
@@ -510,7 +510,7 @@ public class ReviewCompareAnnotationSupport {
&& p.offset + p.getLength() == offset + length) {// || p.includes(offset)) {
if (containingAnnotation == null
|| (direction == Direction.FORWARDS && p.length >= containingAnnotationPosition.length || direction == Direction.BACKWARDS
- && p.length >= containingAnnotationPosition.length)) {
+ && p.length >= containingAnnotationPosition.length)) {
containingAnnotation = a;
containingAnnotationPosition = p;
currentAnnotation = p.length == length;
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
deleted file mode 100644
index 653f479e..00000000
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/CommentInputDialog.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014, 2015 Ericsson AB and others.
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Guy Perron - original version
- *
- ******************************************************************************/
-
-package org.eclipse.mylyn.internal.reviews.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.commons.lang.StringUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.text.source.LineRange;
-import org.eclipse.mylyn.internal.reviews.ui.ReviewsUiPlugin;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.mylyn.reviews.core.model.IComment;
-import org.eclipse.mylyn.reviews.core.model.IFileItem;
-import org.eclipse.mylyn.reviews.core.model.IFileVersion;
-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.ui.ReviewBehavior;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.FormDialog;
-import org.eclipse.ui.forms.IManagedForm;
-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 {
-
- private Text fCommentInputTextField;
-
- private static final int BUTTON_REPLY_ID = 2;
-
- private static final int BUTTON_REPLY_DONE_ID = 3;
-
- private static final int BUTTON_DISCARD_ID = 4;
-
- private static final int BUTTON_EDIT_ID = 5;
-
- private static final int BUTTON_SAVE_ID = 6;
-
- private static final String RESIZABLE_DIALOG_SETTINGS = "MyResizableDialogSettings"; //$NON-NLS-1$
-
- private final ReviewBehavior reviewBehavior;
-
- private final IReviewItem reviewitem;
-
- private final LineRange range;
-
- private List<IComment> commentList;
-
- private List<Button> commentButtons;
-
- private boolean isUpdate = false;
-
- private boolean isDiscard = false;
-
- private boolean isSave = false;
-
- private boolean isDone = false;
-
- private boolean isReply = false;
-
- private String currentUuid;
-
- private Composite buttonparent;
-
- private final Shell parent;
-
- public CommentInputDialog(Shell aParentShell, ReviewBehavior reviewBehavior, IReviewItem reviewitm, LineRange range) {
- super(aParentShell);
- setShellStyle(SWT.CLOSE | SWT.TITLE | SWT.RESIZE | SWT.MODELESS);
- this.reviewBehavior = reviewBehavior;
- this.reviewitem = reviewitm;
- this.range = range;
- this.parent = aParentShell;
-
- }
-
- @Override
- protected IDialogSettings getDialogBoundsSettings() {
- IDialogSettings settings = ReviewsUiPlugin.getDefault().getDialogSettings();
-
- IDialogSettings section = settings.getSection(RESIZABLE_DIALOG_SETTINGS);
- if (section == null) {
- return settings.addNewSection(RESIZABLE_DIALOG_SETTINGS);
- }
- return section;
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.CANCEL_ID) {
- super.buttonPressed(IDialogConstants.OK_ID);
- parent.setFocus();
- return;
- }
-
- IComment comment = IReviewsFactory.INSTANCE.createComment();
- comment.setDescription(fCommentInputTextField.getText().trim());
- switch (buttonId) {
- case BUTTON_EDIT_ID:
- comment.setId(currentUuid);
- disposeButtons();
- createSaveDiscard();
- return;
- case BUTTON_DISCARD_ID:
- comment.setId(currentUuid);
- isDiscard = true;
- break;
- case BUTTON_REPLY_ID:
- comment.setId(currentUuid);
- isSave = true;
- isReply = true;
- disposeButtons();
- createSave();
- fCommentInputTextField.setText(""); //$NON-NLS-1$
- break;
- case BUTTON_REPLY_DONE_ID:
- isSave = true;
- isDone = true;
- comment.setDescription(Messages.CommentInputDialog_Done);
- comment.setId(""); //$NON-NLS-1$
- break;
- case BUTTON_SAVE_ID:
- comment.setId(currentUuid);
- isSave = true;
- if (isReply) {
- isDone = true;
- comment.setId(""); //$NON-NLS-1$
- isReply = false;
- }
- }
- comment.setDraft(true);
- comment.setAuthor(getCurrentUser());
- comment.setCreationDate(new Date());
-
- ILineLocation location = getSelectedLineLocation();
- if (location != null) {
- comment.getLocations().add(location);
- }
- if (buttonId != BUTTON_REPLY_ID) {
- performOperation(comment);
- super.buttonPressed(0);
- }
-
- }
-
- private ILineLocation getSelectedLineLocation() {
- ILineLocation location = IReviewsFactory.INSTANCE.createLineLocation();
- ILineRange lineRange = IReviewsFactory.INSTANCE.createLineRange();
- lineRange.setStart(range.getStartLine());
- lineRange.setEnd(range.getStartLine() + range.getNumberOfLines());
- location.getRanges().add(lineRange);
- return location;
- }
-
- private IUser getCurrentUser() {
- if (reviewitem != null && reviewitem.getReview() != null && reviewitem.getReview().getRepository() != null) {
- return reviewitem.getReview().getRepository().getAccount();
- } else {
- return null;
- }
- }
-
- private boolean performOperation(final IComment comment) {
- final IReviewItem item = reviewitem;
- final AtomicReference<IStatus> result = new AtomicReference<IStatus>();
-
- if (isSave || isDiscard) {
- final Job job = new Job(Messages.CommandServerOperation) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = null;
- if (isSave) {
- status = reviewBehavior.addComment(item, comment, monitor);
- if (status.isOK()) {
- result.set(status);
- updateClient(comment, item);
- return Status.OK_STATUS;
- }
- } else {
- status = reviewBehavior.discardComment(item, comment, monitor);
- if (status.isOK()) {
- result.set(status);
- updateClient(comment, item);
- return Status.OK_STATUS;
- }
- }
- processServerError(status.getMessage());
-
- return Status.OK_STATUS;
- }
-
- };
- job.setUser(true);
- job.schedule();
- }
-
- return true;
-
- }
-
- private void updateClient(final IComment comment, final IReviewItem item) {
- comment.setAuthor(getCurrentUser());
-
- if (!isUpdate || isDone) {
- item.getComments().add(comment);
- } else if (isDiscard) {
- List<IComment> commentlist = item.getComments();
- for (Iterator<IComment> iter = commentlist.iterator(); iter.hasNext();) {
- IComment element = iter.next();
- if (element.getId() != null && element.getId().equals(currentUuid)) {
- iter.remove();
- break;
- }
- }
- } else {
- List<IComment> commentlist = item.getComments();
- for (int i = 0; i < commentlist.size(); i++) {
- if (commentlist.get(i).getId() != null && commentlist.get(i).getId().equals(currentUuid)) {
- item.getComments().set(i, comment);
- break;
- }
- }
-
- }
-
- IFileItem file = null;
- if (item instanceof IFileItem) {
- file = (IFileItem) item;
- } else if (item instanceof IFileVersion) {
- 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,
- // in which case we won't have a relevant model object.)
- updateConsumer(file);
-
- }
- }
-
- private void processServerError(final String message) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- final MessageDialog dialog = new MessageDialog(null, Messages.CommentInputDialog_ServerError, null,
- message, MessageDialog.ERROR, new String[] { IDialogConstants.CANCEL_LABEL }, 0);
- dialog.open();
- }
- });
- }
-
- private void updateConsumer(IFileItem file) {
- TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(
- reviewBehavior.getTask().getConnectorKind(), reviewBehavior.getTask().getRepositoryUrl());
- @SuppressWarnings("restriction")
- ReviewsConnector connector = (ReviewsConnector) TasksUiPlugin.getConnector(reviewBehavior.getTask()
- .getConnectorKind());
- IReviewRemoteFactoryProvider factoryProvider = (IReviewRemoteFactoryProvider) connector.getReviewClient(
- taskRepository).getFactoryProvider();
-
- RemoteEmfConsumer<IReviewItemSet, List<IFileItem>, String, ?, ?, Long> consumer = factoryProvider.getReviewItemSetContentFactory()
- .getConsumerForLocalKey(file.getSet(), file.getSet().getId());
- consumer.updateObservers();
- consumer.release();
- }
-
- @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);
- scrolledform.setExpandHorizontal(true);
- final Composite composite = scrolledform.getBody();
-
- scrolledform.setContent(composite);
-
- final GridLayout layout = new GridLayout(1, false);
-
- composite.setLayout(layout);
- GridData textGridData = null;
-
- commentButtons = new ArrayList<Button>();
- for (final IComment comment : commentList) {
- final Button commentSelectionButton = new Button(composite, SWT.RADIO);
- commentSelectionButton.setBackground(composite.getBackground());
-
- final String authorAndDate;
- if (comment.getAuthor() != null) {
- authorAndDate = comment.getAuthor().getDisplayName() + " " //$NON-NLS-1$
- + comment.getCreationDate().toString();
- } else {
- authorAndDate = Messages.CommentInputDialog_No_author + " " //$NON-NLS-1$
- + comment.getCreationDate().toString();
- }
-
- String commentPrefix = StringUtils.abbreviate(comment.getDescription(), 50);
- if (comment.isDraft()) {
- commentSelectionButton.setText(NLS.bind(Messages.CommentInputDialog_Draft, authorAndDate, commentPrefix));
- } else {
- commentSelectionButton.setText(authorAndDate + " " + commentPrefix); //$NON-NLS-1$
- }
-
- commentSelectionButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectComment(comment);
- }
- });
- GridDataFactory.fillDefaults().span(2, 1).applyTo(commentSelectionButton);
- commentButtons.add(commentSelectionButton);
- }
-
- fCommentInputTextField = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP);
-
- textGridData = new GridData(GridData.FILL, GridData.FILL, true, true);
- textGridData.horizontalSpan = 2;
- textGridData.minimumHeight = fCommentInputTextField.getLineHeight() * 4;
- fCommentInputTextField.setToolTipText(Messages.ReviewsCommentToolTip);
- fCommentInputTextField.setLayoutData(textGridData);
- fCommentInputTextField.setEnabled(false);
-
- //Set default focus
- fCommentInputTextField.setFocus();
-
- this.setHelpAvailable(false);
- }
-
- @Override
- protected Control createButtonBar(final Composite parent) {
- final Composite composite = new Composite(parent, SWT.NONE);
- GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(composite);
- composite.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false));
- composite.setFont(parent.getFont());
-
- final Control buttonSection = super.createButtonBar(composite);
- ((GridData) buttonSection.getLayoutData()).grabExcessHorizontalSpace = true;
- ((GridData) buttonSection.getLayoutData()).grabExcessVerticalSpace = false;
- buttonSection.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- buttonBar.pack();
- }
- });
-
- return composite;
-
- }
-
- @Override
- public void createButtonsForButtonBar(Composite parent) {
- buttonparent = parent;
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- 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 }) {
- Button button = getButton(buttonId);
- if (button != null) {
- button.dispose();
- }
- }
- if (fCommentInputTextField != null) {
- fCommentInputTextField.setEnabled(false);
- }
- }
-
- private void createEdit() {
- createButton(buttonparent, BUTTON_EDIT_ID, Messages.CommentInputDialog_Edit, true);
- buttonBar.pack();
- }
-
- private void createReplyReplyDone() {
- createButton(buttonparent, BUTTON_REPLY_ID, Messages.CommentInputDialog_Reply, true);
- createButton(buttonparent, BUTTON_REPLY_DONE_ID, Messages.CommentInputDialog_ReplyDone, true);
- buttonBar.pack();
- }
-
- private void createSaveDiscard() {
- createButton(buttonparent, BUTTON_SAVE_ID, Messages.CommentInputDialog_Save, true);
- createButton(buttonparent, BUTTON_DISCARD_ID, Messages.CommentInputDialog_Discard, true);
- fCommentInputTextField.setEnabled(true);
- buttonBar.pack();
-
- }
-
- private void createSave() {
- createButton(buttonparent, BUTTON_SAVE_ID, Messages.CommentInputDialog_Save, true);
- fCommentInputTextField.setEnabled(true);
- buttonBar.pack();
-
- }
-}
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/Messages.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/Messages.java
deleted file mode 100644
index e8d10691..00000000
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/Messages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 Ericsson AB and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ericsson AB - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.reviews.ui.dialogs;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Guy Perron
- */
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.reviews.ui.dialogs.messages"; //$NON-NLS-1$
-
- public static String ReviewsCommentToolTip;
-
- public static String CommentInputDialog_Draft;
-
- public static String CommentInputDialog_Done;
-
- public static String CommentInputDialog_Reply;
-
- public static String CommentInputDialog_ReplyDone;
-
- public static String CommentInputDialog_Discard;
-
- public static String CommentInputDialog_Edit;
-
- public static String CommentInputDialog_Save;
-
- public static String CommandServerOperation;
-
- public static String CommentInputDialog_ServerError;
-
- public static String CommentInputDialog_No_author;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/messages.properties b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/messages.properties
deleted file mode 100644
index 4d9af145..00000000
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/dialogs/messages.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2014 Ericsson Communications
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Ericsson Communications - initial API and implementation
-###############################################################################
-CommentInputDialog_Draft={0} DRAFT {1}
-CommentInputDialog_Done=Done
-CommentInputDialog_Reply=Reply ...
-CommentInputDialog_ReplyDone=Reply 'Done'
-CommentInputDialog_Discard=Discard
-CommentInputDialog_Edit=Edit
-CommentInputDialog_Save=Save
-ReviewsCommentToolTip=The Comment Description
-CommandServerOperation=Performing server operation...
-CommentInputDialog_ServerError=Server Connection Error
-CommentInputDialog_No_author=(no author)
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java
index 65129515..513137c3 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/parts/AbstractCommentPart.java
@@ -136,6 +136,7 @@ public abstract class AbstractCommentPart<V extends ExpandablePart<IComment, V>>
protected Composite createSectionContents(Section section, FormToolkit toolkit) {
// CHECKSTYLE:MAGIC:OFF
section.clientVerticalSpacing = 0;
+ section.setData(comment);
sectionClient = new SizeCachingComposite(section, SWT.NONE);
toolkit.adapt(sectionClient);

Back to the top