Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2016-01-07 16:15:39 -0500
committerGerrit Code Review @ Eclipse.org2016-01-14 12:53:47 -0500
commitabc094afe6ea58a45e1ebdeee09c13a2a79ec38a (patch)
tree2522ab8c286f1cb8137276f16548f115809cd0c7 /org.eclipse.mylyn.reviews.ui/src
parent43b0a1d218872d346e2304145d92556e794d475f (diff)
downloadorg.eclipse.mylyn.reviews-abc094afe6ea58a45e1ebdeee09c13a2a79ec38a.tar.gz
org.eclipse.mylyn.reviews-abc094afe6ea58a45e1ebdeee09c13a2a79ec38a.tar.xz
org.eclipse.mylyn.reviews-abc094afe6ea58a45e1ebdeee09c13a2a79ec38a.zip
484709: Neon M4: Java Problem: The return type is incompatible with
IAnnotationModel.getAnnotationIterator() Change-Id: I72d8867c0ad7b5d0e577ce74cca6f9618cf28d8f Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=484709 Signed-off-by: Frank Becker <eclipse@frank-becker.de>
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/CommentAnnotationHover.java60
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHoverInput.java2
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentInformationControl.java6
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentPopupDialog.java33
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/ReviewAnnotationModel.java44
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareAnnotationSupport.java46
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareInputListener.java49
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerColumn.java3
-rw-r--r--org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerHover.java22
9 files changed, 144 insertions, 121 deletions
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHover.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHover.java
index 0cc7363f..a6e3de39 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHover.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHover.java
@@ -56,7 +56,7 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
/**
* Class to determine the annotations to show the hover for. This class delegates to a parent hover if it exists.
- *
+ *
* @author Shawn Minto
*/
public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension, IAnnotationHoverExtension2 {
@@ -83,7 +83,7 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
if (commentAnnotations.size() > 0) {
if (commentAnnotations.size() == 1) {
- CommentAnnotation annotation = commentAnnotations.get(0);
+ Annotation annotation = commentAnnotations.get(0);
String message = annotation.getText();
if (message != null && message.trim().length() > 0) {
return formatSingleMessage(message);
@@ -92,7 +92,7 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
} else {
List<String> messages = new ArrayList<String>();
- for (CommentAnnotation annotation : commentAnnotations) {
+ for (Annotation annotation : commentAnnotations) {
String message = annotation.getText();
if (message != null && message.trim().length() > 0) {
messages.add(message.trim());
@@ -145,26 +145,25 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
IDocument document = viewer.getDocument();
int lowestStart = Integer.MAX_VALUE;
int highestEnd = 0;
- for (Annotation a : commentAnnotations) {
- if (a instanceof CommentAnnotation) {
- Position p = ((CommentAnnotation) a).getPosition();
- try {
-
- int start = document.getLineOfOffset(p.offset);
- int end = document.getLineOfOffset(p.offset + p.length);
-
- if (start < lowestStart) {
- lowestStart = start;
- }
-
- if (end > highestEnd) {
- highestEnd = end;
- }
- } catch (BadLocationException e) {
- // ignore
+ for (CommentAnnotation a : commentAnnotations) {
+ Position p = a.getPosition();
+ try {
+
+ int start = document.getLineOfOffset(p.offset);
+ int end = document.getLineOfOffset(p.offset + p.length);
+
+ if (start < lowestStart) {
+ lowestStart = start;
}
+
+ if (end > highestEnd) {
+ highestEnd = end;
+ }
+ } catch (BadLocationException e) {
+ // ignore
}
}
+
if (lowestStart != Integer.MAX_VALUE) {
return new LineRange(lowestStart, highestEnd - lowestStart);
} else {
@@ -188,7 +187,8 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
protected String formatMultipleMessages(List<String> messages) {
StringBuffer buffer = new StringBuffer();
HTMLPrinter.addPageProlog(buffer);
- HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(Messages.CommentAnnotationHover_Multiple_comments));
+ HTMLPrinter.addParagraph(buffer,
+ HTMLPrinter.convertToHTMLContent(Messages.CommentAnnotationHover_Multiple_comments));
HTMLPrinter.startBulletList(buffer);
for (String message : messages) {
@@ -262,7 +262,8 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
continue;
}
- if (includeAnnotation(annotation, position, commentAnnotations) && annotation instanceof CommentAnnotation) {
+ if (includeAnnotation(annotation, position, commentAnnotations)
+ && annotation instanceof CommentAnnotation) {
commentAnnotations.add((CommentAnnotation) annotation);
}
}
@@ -272,7 +273,7 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
/**
* Tries to make an annotation hover focusable (or "sticky").
- *
+ *
* @return <code>true</code> if successful, <code>false</code> otherwise
*/
public static boolean makeAnnotationHoverFocusable() {
@@ -320,7 +321,8 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
// hover region: the beginning of the concerned line to place the control right over the line
IDocument document = currentSourceViewer.getDocument();
int offset = document.getLineOffset(line);
- String partitioning = new TextSourceViewerConfiguration().getConfiguredDocumentPartitioning(currentSourceViewer);
+ String partitioning = new TextSourceViewerConfiguration()
+ .getConfiguredDocumentPartitioning(currentSourceViewer);
String contentType = TextUtilities.getContentType(document, partitioning, offset, true);
IInformationControlCreator controlCreator = null;
@@ -348,8 +350,8 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
fInformationPresenter.showInformation();
// remove our own handler as F2 focus handler
- ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(
- ICommandService.class);
+ ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
Command showInfoCommand = commandService.getCommand(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
showInfoCommand.setHandler(null);
@@ -364,11 +366,11 @@ public class CommentAnnotationHover implements IAnnotationHover, IAnnotationHove
/**
* Information provider used to present focusable information shells.
- *
+ *
* @since 3.3
*/
- private static final class InformationProvider implements IInformationProvider, IInformationProviderExtension,
- IInformationProviderExtension2 {
+ private static final class InformationProvider
+ implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
private final IRegion fHoverRegion;
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHoverInput.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHoverInput.java
index 5c3337c9..38c8d023 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHoverInput.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/CommentAnnotationHoverInput.java
@@ -17,7 +17,7 @@ import org.eclipse.mylyn.reviews.ui.ReviewBehavior;
/**
* Data model to represent the annotations that we need to display in the hover.
- *
+ *
* @author Shawn Minto
*/
public class CommentAnnotationHoverInput {
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 ca8cee8f..886640a7 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
@@ -31,10 +31,12 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;
+import com.google.common.collect.Iterables;
+
/**
* A custom control to display on hover, or delegates to the default control to display if we aren't dealing with a
* CrucibleCommentAnnotation.
- *
+ *
* @author sminto
*/
public class CommentInformationControl extends DefaultInformationControl implements IInformationControlExtension2 {
@@ -85,7 +87,7 @@ public class CommentInformationControl extends DefaultInformationControl impleme
}
Set<IComment> comments = new HashSet<IComment>();
- for (CommentAnnotation annotation : annotations) {
+ for (CommentAnnotation annotation : Iterables.filter(annotations, CommentAnnotation.class)) {
comments.addAll(getUnreadComments(annotation.getComment()));
}
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 d6332f9b..edb0e413 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
@@ -51,7 +51,7 @@ import com.google.common.collect.FluentIterable;
/**
* Popup to show the information about the annotation in
- *
+ *
* @author Shawn Minto
* @author Guy Perron
*/
@@ -92,7 +92,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -146,7 +146,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -164,7 +164,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -180,7 +180,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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() {
@@ -206,7 +206,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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() {
@@ -236,7 +236,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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() {
@@ -297,7 +297,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
*/
@@ -351,7 +351,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -371,7 +371,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
*/
@@ -442,12 +442,13 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
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() {
@@ -463,7 +464,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -483,7 +484,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
@@ -501,7 +502,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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() {
@@ -532,7 +533,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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() {
@@ -548,7 +549,7 @@ public class CommentPopupDialog extends PopupDialog implements IReviewActionList
/**
* 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
*/
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/ReviewAnnotationModel.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/ReviewAnnotationModel.java
index b9e54224..c87e747f 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/ReviewAnnotationModel.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/annotations/ReviewAnnotationModel.java
@@ -43,9 +43,11 @@ import org.eclipse.mylyn.reviews.core.model.ILocation;
import org.eclipse.mylyn.reviews.core.model.IReviewItem;
import org.eclipse.mylyn.reviews.ui.ReviewBehavior;
+import com.google.common.collect.Iterables;
+
/**
* A model for review annotations.
- *
+ *
* @author Shawn Minto
* @author Steffen Pingel
* @author Guy Perron
@@ -54,7 +56,7 @@ public class ReviewAnnotationModel implements IAnnotationModel {
private final Set<IAnnotationModelListener> annotationModelListeners = new HashSet<IAnnotationModelListener>(2);
- private final Set<CommentAnnotation> annotations = new LinkedHashSet<CommentAnnotation>();
+ private final Set<Annotation> annotations = new LinkedHashSet<Annotation>();
private ReviewBehavior behavior;
@@ -122,9 +124,11 @@ public class ReviewAnnotationModel implements IAnnotationModel {
this.document = document;
connectItem();
- for (CommentAnnotation commentAnnotation : annotations) {
+ for (Annotation commentAnnotation : annotations) {
try {
- document.addPosition(commentAnnotation.getPosition());
+ if (commentAnnotation instanceof CommentAnnotation) {
+ document.addPosition(((CommentAnnotation) commentAnnotation).getPosition());
+ }
} catch (BadLocationException e) {
StatusHandler.log(new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID, e.getMessage(), e));
}
@@ -135,8 +139,10 @@ public class ReviewAnnotationModel implements IAnnotationModel {
}
public void disconnect(IDocument document) {
- for (CommentAnnotation commentAnnotation : annotations) {
- document.removePosition(commentAnnotation.getPosition());
+ for (Annotation commentAnnotation : annotations) {
+ if (commentAnnotation instanceof CommentAnnotation) {
+ document.removePosition(((CommentAnnotation) commentAnnotation).getPosition());
+ }
}
document.removeDocumentListener(documentListener);
@@ -151,7 +157,7 @@ public class ReviewAnnotationModel implements IAnnotationModel {
clear();
}
- public Iterator<CommentAnnotation> getAnnotationIterator() {
+ public Iterator<Annotation> getAnnotationIterator() {
return annotations.iterator();
}
@@ -160,7 +166,7 @@ public class ReviewAnnotationModel implements IAnnotationModel {
*/
public List<CommentAnnotation> getAnnotationsForOffset(int offset) {
List<CommentAnnotation> result = new ArrayList<CommentAnnotation>();
- for (CommentAnnotation annotation : this.annotations) {
+ for (CommentAnnotation annotation : Iterables.filter(this.annotations, CommentAnnotation.class)) {
if (annotation.getPosition().offset <= offset
&& (annotation.getPosition().length + annotation.getPosition().offset) >= offset) {
result.add(annotation);
@@ -180,8 +186,8 @@ public class ReviewAnnotationModel implements IAnnotationModel {
/**
* Returns the first annotation that this knows about for the given offset in the document
*/
- public CommentAnnotation getFirstAnnotationForOffset(int offset) {
- for (CommentAnnotation annotation : annotations) {
+ public Annotation getFirstAnnotationForOffset(int offset) {
+ for (CommentAnnotation annotation : Iterables.filter(annotations, CommentAnnotation.class)) {
if (annotation.getPosition().offset <= offset
&& (annotation.getPosition().length + annotation.getPosition().offset) >= offset) {
return annotation;
@@ -253,8 +259,8 @@ public class ReviewAnnotationModel implements IAnnotationModel {
event.annotationRemoved(ca);
} catch (BadLocationException e) {
- StatusHandler.log(new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID,
- "Unable to remove annotation.", e)); //$NON-NLS-1$
+ StatusHandler.log(
+ new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID, "Unable to remove annotation.", e)); //$NON-NLS-1$
}
}
}
@@ -266,16 +272,16 @@ public class ReviewAnnotationModel implements IAnnotationModel {
if (location instanceof ILineLocation) {
try {
CommentAnnotation oldCa = createCommentAnnotation(document, oldcomment, (ILineLocation) location);
- CommentAnnotation ca = new CommentAnnotation(oldCa.getPosition().offset,
- oldCa.getPosition().length, comment);
+ CommentAnnotation ca = new CommentAnnotation(oldCa.getPosition().offset, oldCa.getPosition().length,
+ comment);
annotations.remove(oldCa);
annotations.add(ca);
event.annotationRemoved(oldCa);
event.annotationChanged(ca);
} catch (BadLocationException e) {
- StatusHandler.log(new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID,
- "Unable to modify annotation.", e)); //$NON-NLS-1$
+ StatusHandler.log(
+ new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID, "Unable to modify annotation.", e)); //$NON-NLS-1$
}
}
}
@@ -304,8 +310,10 @@ public class ReviewAnnotationModel implements IAnnotationModel {
}
protected void clear(AnnotationModelEvent event) {
- for (CommentAnnotation commentAnnotation : annotations) {
- event.annotationRemoved(commentAnnotation, commentAnnotation.getPosition());
+ for (Annotation commentAnnotation : annotations) {
+ if (commentAnnotation instanceof CommentAnnotation) {
+ event.annotationRemoved(commentAnnotation, ((CommentAnnotation) commentAnnotation).getPosition());
+ }
}
annotations.clear();
}
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 ff6c066f..05d43a96 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
@@ -72,7 +72,8 @@ public class ReviewCompareAnnotationSupport {
private CommentPopupDialog commentPopupDialog = null;
public static ReviewCompareAnnotationSupport getAnnotationSupport(Viewer contentViewer) {
- ReviewCompareAnnotationSupport support = (ReviewCompareAnnotationSupport) contentViewer.getData(KEY_ANNOTAION_SUPPORT);
+ ReviewCompareAnnotationSupport support = (ReviewCompareAnnotationSupport) contentViewer
+ .getData(KEY_ANNOTAION_SUPPORT);
if (support == null) {
support = new ReviewCompareAnnotationSupport(contentViewer);
contentViewer.setData(KEY_ANNOTAION_SUPPORT, support);
@@ -178,7 +179,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
@@ -207,7 +208,8 @@ public class ReviewCompareAnnotationSupport {
nextRightPosition.length = 1;
currentLeftOffset = getLineOffset(leftAnnotationModel, currentLeftOffset);
- if (calculateNextAnnotation(direction, nextLeftPosition, nextRightPosition, currentLeftOffset) == LEFT_SIDE) {
+ if (calculateNextAnnotation(direction, nextLeftPosition, nextRightPosition,
+ currentLeftOffset) == LEFT_SIDE) {
return leftAnnotation;
} else {
return rightAnnotation;
@@ -303,7 +305,8 @@ public class ReviewCompareAnnotationSupport {
return RIGHT_SIDE;
}
- public void moveToAnnotation(MergeSourceViewer adjacentViewer, MergeSourceViewer annotationViewer, Position position) {
+ public void moveToAnnotation(MergeSourceViewer adjacentViewer, MergeSourceViewer annotationViewer,
+ Position position) {
adjacentViewer.getSourceViewer().revealRange(position.offset, position.length);
adjacentViewer.getSourceViewer().setSelectedRange(position.offset, position.length);
selectAndReveal(annotationViewer, position);
@@ -329,10 +332,9 @@ public class ReviewCompareAnnotationSupport {
commentPopupDialog.dispose(false);
commentPopupDialog = null;
}
- commentPopupDialog = new CommentPopupDialog(ReviewsUiPlugin.getDefault()
- .getWorkbench()
- .getActiveWorkbenchWindow()
- .getShell(), SWT.NO_FOCUS | SWT.ON_TOP, reviewitem, range, true);
+ commentPopupDialog = new CommentPopupDialog(
+ ReviewsUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ SWT.NO_FOCUS | SWT.ON_TOP, reviewitem, range, true);
CommentAnnotationHoverInput input = new CommentAnnotationHoverInput(comments,
((ReviewAnnotationModel) srcViewer.getAnnotationModel()).getBehavior());
commentPopupDialog.create();
@@ -461,7 +463,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
@@ -497,20 +499,20 @@ public class ReviewCompareAnnotationSupport {
int endOfDocument = document.getLength();
int distance = Integer.MAX_VALUE;
- Iterator<CommentAnnotation> e = annotationModel.getAnnotationIterator();
+ Iterator<Annotation> e = annotationModel.getAnnotationIterator();
while (e.hasNext()) {
- CommentAnnotation a = e.next();
+ Annotation a = e.next();
- Position p = a.getPosition();
+ Position p = a instanceof CommentAnnotation ? ((CommentAnnotation) a).getPosition() : null;
if (p == null) {
continue;
}
- if (direction == Direction.FORWARDS && p.offset == offset || direction == Direction.BACKWARDS
- && 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)) {
+ if (direction == Direction.FORWARDS && p.offset == offset
+ || direction == Direction.BACKWARDS && 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)) {
containingAnnotation = a;
containingAnnotationPosition = p;
currentAnnotation = p.length == length;
@@ -524,8 +526,8 @@ public class ReviewCompareAnnotationSupport {
currentDistance = endOfDocument + currentDistance;
}
- if (currentDistance < distance || currentDistance == distance
- && p.length < nextAnnotationPosition.length) {
+ if (currentDistance < distance
+ || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance = currentDistance;
nextAnnotation = a;
nextAnnotationPosition = p;
@@ -536,8 +538,8 @@ public class ReviewCompareAnnotationSupport {
currentDistance = endOfDocument + currentDistance;
}
- if (currentDistance < distance || currentDistance == distance
- && p.length < nextAnnotationPosition.length) {
+ if (currentDistance < distance
+ || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance = currentDistance;
nextAnnotation = a;
nextAnnotationPosition = p;
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareInputListener.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareInputListener.java
index dfbf9a23..3a19d19f 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareInputListener.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewCompareInputListener.java
@@ -26,6 +26,7 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationBarHoverManager;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationAccess;
@@ -90,23 +91,26 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
public void lineGetBackground(LineBackgroundEvent event) {
int lineNr = styledText.getLineAtOffset(event.lineOffset) + 1;
- Iterator<CommentAnnotation> it = annotationModel.getAnnotationIterator();
+ Iterator<Annotation> it = annotationModel.getAnnotationIterator();
while (it.hasNext()) {
- CommentAnnotation annotation = it.next();
+ Annotation annotation = it.next();
int startLine;
int endLine;
- IComment comment = annotation.getComment();
- //TODO This code assumes that we have one comment per annotation. That won't work for r4E.
- if (comment.getLocations().size() == 1) {
- ILocation location = comment.getLocations().get(0);
- if (location instanceof ILineLocation) {
- ILineLocation lineLocation = (ILineLocation) location;
- startLine = lineLocation.getRangeMin();
- endLine = lineLocation.getRangeMax();
- if (lineNr >= startLine && lineNr <= endLine) {
- AnnotationPreference pref = new AnnotationPreferenceLookup().getAnnotationPreference(annotation);
- if (pref.getHighlightPreferenceValue()) {
- event.lineBackground = colorCommented;
+ if (annotation instanceof CommentAnnotation) {
+ IComment comment = ((CommentAnnotation) annotation).getComment();
+ //TODO This code assumes that we have one comment per annotation. That won't work for r4E.
+ if (comment.getLocations().size() == 1) {
+ ILocation location = comment.getLocations().get(0);
+ if (location instanceof ILineLocation) {
+ ILineLocation lineLocation = (ILineLocation) location;
+ startLine = lineLocation.getRangeMin();
+ endLine = lineLocation.getRangeMax();
+ if (lineNr >= startLine && lineNr <= endLine) {
+ AnnotationPreference pref = new AnnotationPreferenceLookup()
+ .getAnnotationPreference(annotation);
+ if (pref.getHighlightPreferenceValue()) {
+ event.lineBackground = colorCommented;
+ }
}
}
}
@@ -117,7 +121,7 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
/**
* Galileo hack to deal with slaveDocuments (when clicking on java structure elements). The styledText will not
* contain the whole text anymore, so our line numbering is off
- *
+ *
* @param event
* @return
*/
@@ -170,7 +174,8 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
}
AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();
- final AnnotationPreference commentedPref = lookup.getAnnotationPreference(CommentAnnotation.COMMENT_ANNOTATION_ID);
+ final AnnotationPreference commentedPref = lookup
+ .getAnnotationPreference(CommentAnnotation.COMMENT_ANNOTATION_ID);
updateCommentedColor(commentedPref, store);
@@ -321,8 +326,8 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
createOverviewRuler(newInput, sourceViewerClazz);
createHighlighting(sourceViewerClazz);
} catch (Throwable t) {
- StatusHandler.log(new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID,
- "Error attaching annotation model", t)); //$NON-NLS-1$
+ StatusHandler.log(
+ new Status(IStatus.ERROR, ReviewsUiPlugin.PLUGIN_ID, "Error attaching annotation model", t)); //$NON-NLS-1$
}
//}
}
@@ -345,8 +350,8 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
// mergeSourceViewer.addTextAction(addGeneralCommentAction);
}
- private void createHighlighting(Class<SourceViewer> sourceViewerClazz) throws IllegalArgumentException,
- IllegalAccessException, SecurityException, NoSuchFieldException {
+ private void createHighlighting(Class<SourceViewer> sourceViewerClazz)
+ throws IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException {
// TODO this could use some performance tweaks
final StyledText styledText = sourceViewer.getTextWidget();
styledText.addLineBackgroundListener(new ColoringLineBackgroundListener(styledText));
@@ -364,8 +369,8 @@ class ReviewCompareInputListener implements ITextInputListener, IReviewCompareSo
sourceViewer.setOverviewRulerAnnotationHover(new CommentAnnotationHover(null));
- OverviewRuler ruler = new OverviewRuler(new DefaultMarkerAnnotationAccess(), 15, EditorsPlugin.getDefault()
- .getSharedTextColors());
+ OverviewRuler ruler = new OverviewRuler(new DefaultMarkerAnnotationAccess(), 15,
+ EditorsPlugin.getDefault().getSharedTextColors());
Field compositeField = sourceViewerClazz.getDeclaredField("fComposite"); //$NON-NLS-1$
compositeField.setAccessible(true);
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerColumn.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerColumn.java
index 5f28db43..3643949a 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerColumn.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerColumn.java
@@ -161,7 +161,8 @@ public class CommentAnnotationRulerColumn extends AbstractRulerColumn implements
}
AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();
- final AnnotationPreference commentedPref = lookup.getAnnotationPreference(CommentAnnotation.COMMENT_ANNOTATION_ID);
+ final AnnotationPreference commentedPref = lookup
+ .getAnnotationPreference(CommentAnnotation.COMMENT_ANNOTATION_ID);
updateCommentedColor(commentedPref, store);
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerHover.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerHover.java
index c4534a7c..42c35b61 100644
--- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerHover.java
+++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/editors/ruler/CommentAnnotationRulerHover.java
@@ -59,8 +59,8 @@ import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotationHoverExtension,
- IAnnotationHoverExtension2 {
+public class CommentAnnotationRulerHover
+ implements IAnnotationHover, IAnnotationHoverExtension, IAnnotationHoverExtension2 {
private final IInformationControlCreator informationControlCreator = new CommentInformationControlCreator();
@@ -238,7 +238,8 @@ public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotatio
continue;
}
- if (includeAnnotation(annotation, position, commentAnnotations) && annotation instanceof CommentAnnotation) {
+ if (includeAnnotation(annotation, position, commentAnnotations)
+ && annotation instanceof CommentAnnotation) {
commentAnnotations.add((CommentAnnotation) annotation);
}
}
@@ -248,7 +249,7 @@ public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotatio
/**
* Tries to make an annotation hover focusable (or "sticky").
- *
+ *
* @return <code>true</code> if successful, <code>false</code> otherwise
*/
public static boolean makeAnnotationHoverFocusable() {
@@ -296,7 +297,8 @@ public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotatio
// hover region: the beginning of the concerned line to place the control right over the line
IDocument document = currentSourceViewer.getDocument();
int offset = document.getLineOffset(line);
- String partitioning = new TextSourceViewerConfiguration().getConfiguredDocumentPartitioning(currentSourceViewer);
+ String partitioning = new TextSourceViewerConfiguration()
+ .getConfiguredDocumentPartitioning(currentSourceViewer);
String contentType = TextUtilities.getContentType(document, partitioning, offset, true);
IInformationControlCreator controlCreator = null;
@@ -324,8 +326,8 @@ public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotatio
fInformationPresenter.showInformation();
// remove our own handler as F2 focus handler
- ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(
- ICommandService.class);
+ ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
Command showInfoCommand = commandService.getCommand(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
showInfoCommand.setHandler(null);
@@ -340,11 +342,11 @@ public class CommentAnnotationRulerHover implements IAnnotationHover, IAnnotatio
/**
* Information provider used to present focusable information shells.
- *
+ *
* @since 3.3
*/
- private static final class InformationProvider implements IInformationProvider, IInformationProviderExtension,
- IInformationProviderExtension2 {
+ private static final class InformationProvider
+ implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
private final IRegion fHoverRegion;

Back to the top