Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdubois2013-03-21 20:08:47 +0000
committerSebastien Dubois2013-03-21 20:08:47 +0000
commit73516f4ffdfe68cdbc30d210470db72943557cc8 (patch)
tree5fd963b31205ad5bc1ae32d056023e69a6c7bb92
parenta8860f587b3e4ab644041db06544ac7bbd6b7359 (diff)
downloadorg.eclipse.mylyn.reviews.r4e-73516f4ffdfe68cdbc30d210470db72943557cc8.tar.gz
org.eclipse.mylyn.reviews.r4e-73516f4ffdfe68cdbc30d210470db72943557cc8.tar.xz
org.eclipse.mylyn.reviews.r4e-73516f4ffdfe68cdbc30d210470db72943557cc8.zip
372044: [user]: New feature to transfer anomalies between review items
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372044 - Completed implementation for comparing 2 review items with each other with full annotation support - Added code to prevent adding review items/anomalies to the right side of the compare editor (for now) - Added test code - Added help documentation Change-Id: Ic54313c386f7af03402e4ab546f85ceba42ac200
-rw-r--r--org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationModel.java8
-rw-r--r--org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationSupport.java16
-rw-r--r--org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewAnnotationSupport.java78
-rw-r--r--org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewCompareAnnotationSupport.java119
-rw-r--r--org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewSingleAnnotationSupport.java4
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/build-r4e-help.xml3
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItems.pngbin0 -> 18320 bytes
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItemsEditor.pngbin0 -> 63098 bytes
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/Tasks.html57
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser-toc.xml3
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.html30
-rw-r--r--org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.mediawiki20
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/R4EUIAllTests.java3
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/feature/CompareReviewItemsTests.java485
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestCommands.java46
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestItem.java132
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/utils/TestUtils.java16
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui.tests/testFiles/extModCommitFile12.java30
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/icons/elcl16/compareitems_menu.gifbin0 -> 224 bytes
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/plugin.xml15
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/content/R4EAnnotationModel.java19
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/control/R4ECompareAnnotationSupport.java10
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/ModelContributionItems.java20
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/CompareItemsHandler.java108
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/FindReviewItemsHandler.java46
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/CloneAnomalyPropertyTester.java12
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewAnomalyPropertyTester.java12
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewReviewItemPropertyTester.java14
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/EditorProxy.java282
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4ECompareEditorInput.java286
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDeltaCompareEditorInput.java133
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDiffNode.java329
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextCompareEditorInput.java142
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextNode.java85
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EReviewItemCompareEditorInput.java358
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/model/R4EUIReviewBasic.java5
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/CommandUtils.java114
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/DiffUtils.java10
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/MailServicesProxy.java3
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java25
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/UIUtils.java124
41 files changed, 2502 insertions, 700 deletions
diff --git a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationModel.java b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationModel.java
index 490f82cb..96636be6 100644
--- a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationModel.java
+++ b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationModel.java
@@ -113,4 +113,12 @@ public interface IReviewAnnotationModel extends IAnnotationModel {
* - The file the annotation model refers to
*/
void setFile(Object aFile);
+
+ /**
+ * Method getFile. Gets the file the current annotation model refers to
+ *
+ * @return Object
+ * - The file the annotation model refers to
+ */
+ Object getFile();
}
diff --git a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationSupport.java b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationSupport.java
index ea94cfd8..56ec4809 100644
--- a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/IReviewAnnotationSupport.java
@@ -31,14 +31,14 @@ public interface IReviewAnnotationSupport {
*
* @return ITextEditor - the Text Editor instance
*/
- ITextEditor getTargetEditor();
+ ITextEditor getEditor();
/**
* Gets the Annotation Model connected to the current file.
*
* @return IReviewAnnotationModel - the Annotation Model
*/
- IReviewAnnotationModel getTargetAnnotationModel();
+ IReviewAnnotationModel getAnnotationModel();
/**
* Sets the current object instance the Annotation Model is connected to.
@@ -61,23 +61,29 @@ public interface IReviewAnnotationSupport {
*
* @param aElement
* - the element source for the new annotation
+ * @param aFile
+ * - the file on which the annotation is applied
*/
- void addAnnotation(Object aElement);
+ void addAnnotation(Object aElement, Object aFile);
/**
* Update Annotation data in the Annotation Model.
*
* @param aElement
* - the element source for the annotation to update
+ * @param aFile
+ * - the file on which the annotation is applied
*/
- void updateAnnotation(Object aElement);
+ void updateAnnotation(Object aElement, Object aFile);
/**
* Remove an Annotation from the Annotation Model.
*
* @param aElement
* - the element source for the annotation to remove
+ * @param aFile
+ * - the file on which the annotation is applied
*/
- void removeAnnotation(Object aElement);
+ void removeAnnotation(Object aElement, Object aFile);
}
diff --git a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewAnnotationSupport.java b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewAnnotationSupport.java
index d39c58ee..c1f144a9 100644
--- a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewAnnotationSupport.java
@@ -37,14 +37,14 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
// ------------------------------------------------------------------------
/**
- * Field fTargetAnnotationModel.
+ * Field fAnnotationModel.
*/
- protected final IReviewAnnotationModel fTargetAnnotationModel;
+ protected IReviewAnnotationModel fAnnotationModel = null;
/**
- * Field fTargetViewerListener.
+ * Field fViewerListener.
*/
- protected IEditorInputListener fTargetViewerListener = null;
+ protected IEditorInputListener fViewerListener = null;
// ------------------------------------------------------------------------
// Constructors
@@ -53,12 +53,14 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
/**
* Constructor for ReviewAnnotationSupport.
*
- * @param aSourceFile
+ * @param aFileVersion
* Object
*/
- public ReviewAnnotationSupport(Object aSourceFile) {
- this.fTargetAnnotationModel = createAnnotationModel(aSourceFile);
- this.fTargetAnnotationModel.setFile(aSourceFile);
+ public ReviewAnnotationSupport(Object aFileVersion) {
+ if (null != aFileVersion) {
+ this.fAnnotationModel = createAnnotationModel(aFileVersion);
+ this.fAnnotationModel.setFile(aFileVersion);
+ }
}
// ------------------------------------------------------------------------
@@ -86,23 +88,23 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
* Method getTargetEditor.
*
* @return ITextEditor
- * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#getTargetEditor()
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#getEditor()
*/
- public ITextEditor getTargetEditor() {
- if (null != fTargetViewerListener) {
- return fTargetViewerListener.getEditor();
+ public ITextEditor getEditor() {
+ if (null != fViewerListener) {
+ return fViewerListener.getEditor();
}
return null;
}
/**
- * Method getTargetAnnotationModel.
+ * Method getAnnotationModel.
*
* @return IReviewAnnotationModel
- * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#getTargetAnnotationModel()
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#getAnnotationModel()
*/
- public IReviewAnnotationModel getTargetAnnotationModel() {
- return fTargetAnnotationModel;
+ public IReviewAnnotationModel getAnnotationModel() {
+ return fAnnotationModel;
}
/**
@@ -113,8 +115,8 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
* @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#setAnnotationModelElement(Object)
*/
public void setAnnotationModelElement(Object aElement) {
- if (null != fTargetAnnotationModel) {
- fTargetAnnotationModel.setFile(aElement);
+ if (null != fAnnotationModel) {
+ fAnnotationModel.setFile(aElement);
}
}
@@ -126,9 +128,11 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
* @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#refreshAnnotations(Object)
*/
public void refreshAnnotations(Object aElement) {
- if (null != fTargetAnnotationModel) {
- fTargetAnnotationModel.setFile(aElement);
- fTargetAnnotationModel.refreshAnnotations();
+ if (null != fAnnotationModel) {
+ if (null != aElement) {
+ fAnnotationModel.setFile(aElement); //Set new file if it has changed
+ }
+ fAnnotationModel.refreshAnnotations();
}
}
@@ -137,11 +141,13 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
*
* @param aElement
* Object
+ * @param aFile
+ * Object
* @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#addAnnotation(Object)
*/
- public void addAnnotation(Object aElement) {
- if (null != fTargetAnnotationModel) {
- fTargetAnnotationModel.addAnnotation(aElement);
+ public void addAnnotation(Object aElement, Object aFile) {
+ if (null != fAnnotationModel && aFile.equals(fAnnotationModel.getFile())) {
+ fAnnotationModel.addAnnotation(aElement);
}
}
@@ -150,11 +156,13 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
*
* @param aElement
* Object
+ * @param aFile
+ * Object
* @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#updateAnnotation(Object)
*/
- public void updateAnnotation(Object aElement) {
- if (null != fTargetAnnotationModel) {
- fTargetAnnotationModel.updateAnnotation(aElement);
+ public void updateAnnotation(Object aElement, Object aFile) {
+ if (null != fAnnotationModel && aFile.equals(fAnnotationModel.getFile())) {
+ fAnnotationModel.updateAnnotation(aElement);
}
}
@@ -163,11 +171,13 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
*
* @param aElement
* Object
+ * @param aFile
+ * Object
* @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#removeAnnotation(Object)
*/
- public void removeAnnotation(Object aElement) {
- if (null != fTargetAnnotationModel) {
- fTargetAnnotationModel.removeAnnotation(aElement);
+ public void removeAnnotation(Object aElement, Object aFile) {
+ if (null != fAnnotationModel && aFile.equals(fAnnotationModel.getFile())) {
+ fAnnotationModel.removeAnnotation(aElement);
}
}
@@ -190,11 +200,11 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
return false;
}
final ReviewAnnotationSupport other = (ReviewAnnotationSupport) aObject;
- if (fTargetAnnotationModel == null) {
- if (other.fTargetAnnotationModel != null) {
+ if (fAnnotationModel == null) {
+ if (other.fAnnotationModel != null) {
return false;
}
- } else if (!fTargetAnnotationModel.equals(other.fTargetAnnotationModel)) {
+ } else if (!fAnnotationModel.equals(other.fAnnotationModel)) {
return false;
}
return true;
@@ -209,7 +219,7 @@ public abstract class ReviewAnnotationSupport implements IReviewAnnotationSuppor
public int hashCode() {
final int prime = 31;
int result = 1;
- result = (prime * result) + ((fTargetAnnotationModel == null) ? 0 : fTargetAnnotationModel.hashCode());
+ result = (prime * result) + ((fAnnotationModel == null) ? 0 : fAnnotationModel.hashCode());
return result;
}
diff --git a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewCompareAnnotationSupport.java b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewCompareAnnotationSupport.java
index 2fae3fcf..c86c08f3 100644
--- a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewCompareAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewCompareAnnotationSupport.java
@@ -22,7 +22,6 @@ import java.lang.reflect.Field;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -54,16 +53,113 @@ public abstract class ReviewCompareAnnotationSupport extends ReviewAnnotationSup
*
* @param aViewer
* Viewer
- * @param aSourceFile
+ * @param aTargetFile
+ * Object
+ * @param aBaseFile
* Object
*/
- public ReviewCompareAnnotationSupport(Viewer aViewer, Object aSourceFile) {
- super(aSourceFile);
- fBaseAnnotationModel = createAnnotationModel(null);
+ public ReviewCompareAnnotationSupport(Viewer aViewer, Object aTargetFile, Object aBaseFile) {
+ super(aTargetFile);
+ if (null != aBaseFile) {
+ fBaseAnnotationModel = createAnnotationModel(aBaseFile);
+ fBaseAnnotationModel.setFile(aBaseFile);
+ } else {
+ fBaseAnnotationModel = null;
+ }
install(aViewer);
}
/**
+ * Method getBaseAnnotationModel.
+ *
+ * @return IReviewAnnotationModel
+ */
+ public IReviewAnnotationModel getBaseAnnotationModel() {
+ return fBaseAnnotationModel;
+ }
+
+ /**
+ * Method setAnnotationModelBaseElement.
+ *
+ * @param aElement
+ * - Object
+ */
+ public void setAnnotationModelBaseElement(Object aElement) {
+ if (null != fBaseAnnotationModel) {
+ fBaseAnnotationModel.setFile(aElement);
+ }
+ }
+
+ /**
+ * Method refreshAnnotations.
+ *
+ * @param aElement
+ * Object
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#refreshAnnotations(Object)
+ */
+ @Override
+ public void refreshAnnotations(Object aElement) {
+ super.refreshAnnotations(aElement);
+ if (null != fBaseAnnotationModel) {
+ if (null != aElement) {
+ fBaseAnnotationModel.setFile(aElement); //Set new file if it has changed
+ }
+ fBaseAnnotationModel.refreshAnnotations();
+ }
+ }
+
+ /**
+ * Method addAnnotation.
+ *
+ * @param aElement
+ * Object
+ * @param aFile
+ * Object
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#addAnnotation(Object)
+ */
+ @Override
+ public void addAnnotation(Object aElement, Object aFile) {
+ super.addAnnotation(aElement, aFile);
+ if (null != fBaseAnnotationModel && null != aFile && aFile.equals(fBaseAnnotationModel.getFile())) {
+ fBaseAnnotationModel.addAnnotation(aElement);
+ }
+ }
+
+ /**
+ * Method updateAnnotation.
+ *
+ * @param aElement
+ * Object
+ * @param aFile
+ * Object
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#updateAnnotation(Object)
+ */
+ @Override
+ public void updateAnnotation(Object aElement, Object aFile) {
+ super.updateAnnotation(aElement, aFile);
+ if (null != fBaseAnnotationModel && null != aFile && aFile.equals(fBaseAnnotationModel.getFile())) {
+ fBaseAnnotationModel.updateAnnotation(aElement);
+ }
+ }
+
+ /**
+ * Method removeAnnotation.
+ *
+ * @param aElement
+ * Object
+ * @param aFile
+ * Object
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport#removeAnnotation(Object)
+ */
+ @Override
+ public void removeAnnotation(Object aElement, Object aFile) {
+ super.addAnnotation(aElement, aFile);
+ if (null != fBaseAnnotationModel && aFile.equals(fBaseAnnotationModel.getFile())) {
+ fBaseAnnotationModel.removeAnnotation(aElement);
+ }
+ }
+
+ /**
* Method createEditorInputListener.
*
* @param aViewer
@@ -95,7 +191,7 @@ public abstract class ReviewCompareAnnotationSupport extends ReviewAnnotationSup
declaredField.setAccessible(true);
final MergeSourceViewer fRight = (MergeSourceViewer) declaredField.get(textMergeViewer);
- fTargetViewerListener = registerInputListener(fLeft, fTargetAnnotationModel);
+ fViewerListener = registerInputListener(fLeft, fAnnotationModel);
fBaseViewerListener = registerInputListener(fRight, fBaseAnnotationModel);
} catch (Throwable t) {
//do nothing for now
@@ -121,10 +217,13 @@ public abstract class ReviewCompareAnnotationSupport extends ReviewAnnotationSup
*/
private IEditorInputListener registerInputListener(final MergeSourceViewer aViewer,
final IReviewAnnotationModel aAnnotationModel) {
- final ISourceViewer sourceViewer = ReviewAnnotationSupport.getSourceViewer(aViewer);
- final IEditorInputListener listener = createEditorInputListener(aViewer, aAnnotationModel);
- if (sourceViewer != null) {
- sourceViewer.addTextInputListener(listener);
+ IEditorInputListener listener = null;
+ if (null != aAnnotationModel) {
+ final ISourceViewer sourceViewer = ReviewAnnotationSupport.getSourceViewer(aViewer);
+ listener = createEditorInputListener(aViewer, aAnnotationModel);
+ if (sourceViewer != null) {
+ sourceViewer.addTextInputListener(listener);
+ }
}
return listener;
}
diff --git a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewSingleAnnotationSupport.java b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewSingleAnnotationSupport.java
index 1c889016..c26a418f 100644
--- a/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewSingleAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.frame.ui/src/org/eclipse/mylyn/reviews/frame/ui/annotation/impl/ReviewSingleAnnotationSupport.java
@@ -39,7 +39,7 @@ public abstract class ReviewSingleAnnotationSupport extends ReviewAnnotationSupp
public ReviewSingleAnnotationSupport(ISourceViewer aSourceViewer, Object aSourceFile) {
super(aSourceFile);
install(aSourceViewer);
- fTargetViewerListener.inputDocumentChanged(null, aSourceViewer.getDocument()); //Force annotation updates
+ fViewerListener.inputDocumentChanged(null, aSourceViewer.getDocument()); //Force annotation updates
}
/**
@@ -63,7 +63,7 @@ public abstract class ReviewSingleAnnotationSupport extends ReviewAnnotationSupp
@Override
protected void install(Object aSourceViewer) {
if (aSourceViewer instanceof SourceViewer) {
- fTargetViewerListener = registerInputListener((ISourceViewer) aSourceViewer, fTargetAnnotationModel);
+ fViewerListener = registerInputListener((ISourceViewer) aSourceViewer, fAnnotationModel);
}
}
diff --git a/org.eclipse.mylyn.reviews.r4e.help/build-r4e-help.xml b/org.eclipse.mylyn.reviews.r4e.help/build-r4e-help.xml
index 1e6d7067..cc57fb52 100644
--- a/org.eclipse.mylyn.reviews.r4e.help/build-r4e-help.xml
+++ b/org.eclipse.mylyn.reviews.r4e.help/build-r4e-help.xml
@@ -61,7 +61,7 @@
<!-- IMPORTANT NOTE2
This is now used for reference only, and to verify if anything was changed on
the Eclipse web wiki that needs to be included to the local _r4eOpen.mediawiki file.
- -->
+
<mediawiki-to-eclipse-help wikiBaseUrl="${help.doc.url.base}"
validate="true"
failonvalidationerror="true"
@@ -83,6 +83,7 @@
http://wiki.eclipse.org/Reviews/R4E/User_Guide
</pageAppendum>
</mediawiki-to-eclipse-help>
+ -->
</sequential>
</target>
</project> \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItems.png b/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItems.png
new file mode 100644
index 00000000..7c8fd340
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItems.png
Binary files differ
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItemsEditor.png b/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItemsEditor.png
new file mode 100644
index 00000000..7e902e3c
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/CompareReviewItemsEditor.png
Binary files differ
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/Tasks.html b/org.eclipse.mylyn.reviews.r4e.help/doc/Tasks.html
index 167ff416..f71a3e91 100644
--- a/org.eclipse.mylyn.reviews.r4e.help/doc/Tasks.html
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/Tasks.html
@@ -54,9 +54,7 @@
<br/>
</p>
<h3 id="Disabling_and_Restoring_Elements">Disabling and Restoring Elements</h3>
- <p>When Review Navigator elements are not relevant anymore (e.g. completed reviews), they can be removed from the view by using the
- <i>Disable </i>command from the element's context menu.
- </p>
+ <p>When Review Navigator elements are not relevant anymore (e.g. completed reviews), they can be removed from the view by using the ''Disable ''command from the element's context menu. </p>
<p>
<br/>
</p>
@@ -73,8 +71,7 @@
</p>
<p>Ideally, disabled elements should never be shown, but there could be a need to restore mistakenly disabled elements. To do so, first go to the Eclipse preferences R4E page, on the
<i>Filters</i> tab and enable the
- <i>Show Disabled Elements</i> filter, then return to the Navigator view and select the
- <i>Restore </i>command from the disabled element context menu
+ <i>Show Disabled Elements</i> filter, then return to the Navigator view and select the ''Restore ''command from the disabled element context menu
</p>
<p>
<br/>
@@ -259,9 +256,7 @@
<br/>
</p>
<ul>
- <li>Add a new Review Group reference file by clicking the
- <i>Add </i>button and select the appropriate Group File. Take note that all Review Group filename end with "_group_root.xrer" suffix.
- </li>
+ <li>Add a new Review Group reference file by clicking the ''Add ''button and select the appropriate Group File. Take note that all Review Group filename end with "_group_root.xrer" suffix. </li>
<li>The Review Group Name and Description are also shown in the Preferences Group tab.</li>
</ul>
<p>
@@ -461,6 +456,23 @@
<p>
<br/>
</p>
+ <pre>When two Review Items have the same first line description, their displayed name in the Review Navigator will include a version number just after the Review Item type (e.g. Commit 1:... and Commit 2:..., where ... are two identical strings). This will show the users that the two Review Items are two different versions of the same code change. Of course, the first line of the Review Item description must not be changed for this function to work.
+</pre>
+ <h3 id="Comparing_Review_Items">Comparing Review Items</h3>
+ <p>Is is possible to compare two arbitrary Review Items that are included in the same Review. Typically this will be used to see the differences between two versions of a given code change.</p>
+ <p>In order to do this, select two Review Items in the Review Navigator (using Ctrl-Left click or Shift-Left click) and then right click on one of the items and select the "Compare Review Items" command from the context menu</p>
+ <p>
+ <img border="0" src="CompareReviewItems.png"/>
+ </p>
+ <p>This will open a Structural Compare Editor that will show the files versions that are different. The file that belong to the most recently committed Review Item will always be the target files (on the left side) and the files belonging to the oldest Review Item will be the base files (on the right side).</p>
+ <p>Little + decorators show the files that were added in the newest Review Item, whereas - decorators show removed files.</p>
+ <p>To see the differences within a specific file, just double click on it and the lower side of the compare editor will be populated with the content differences between the files. From the Compare Editor, it is also possible to modify the R4E annotation markers (see
+ <a href="Tasks.html#Using_Review_Annotations_and_Inline_Comments">R4E Annotations</a>), on either side.
+ </p>
+ <p>For instance, one could verify that anomalies that were written on a previous version of the code change are indeed corrected and change the state of the anomalies on the base version (right side) accordingly, as shown below.</p>
+ <p>
+ <img border="0" src="CompareReviewItemsEditor.png"/>
+ </p>
<h3 id="Assigning_Review_Elements">Assigning Review Elements</h3>
<p>It is possible to assign specific review elements (i.e. Review Items, File Contexts, Selections and Deltas) to specific participants. To do so, use the context command
<i>Assign to Participant</i> for the desired elements.
@@ -647,9 +659,7 @@
<br/>
</p>
<ul>
- <li>Add a new Rule Set reference file by clicking the
- <i>Add </i>button and select the appropriate Rule Set File. Take note that all Review Group filename end with "_rule_set.xrer" suffix.
- </li>
+ <li>Add a new Rule Set reference file by clicking the ''Add ''button and select the appropriate Rule Set File. Take note that all Review Group filename end with "_rule_set.xrer" suffix. </li>
<li>The Rule Set Version and Name are also shown in the Preferences Group tab.</li>
</ul>
<p>
@@ -865,8 +875,7 @@
<ul>
<li>The Review name. </li>
<li>The current Review phase. Basic and Informal reviews can have only 2 phases,
- <i>Started </i>and
- <i>Completed</i>. Formal reviews have multiple phases. Refer to the formal review section for more information.
+ <i>Started ''and ''Completed</i>. Formal reviews have multiple phases. Refer to the formal review section for more information.
</li>
<li>A brief description of the review. </li>
</ul>
@@ -892,8 +901,7 @@
<li>In the Decision Information expandable section (Informal/Formal reviews only)
<ul>
<li>Meeting data for the decision meeting (Subject, Time, Duration, Location). This can be updated at any time using the
- <i>Update </i>button. The data can be fetched using the
- <i>Refresh</i> button
+ <i>Update ''button. The data can be fetched using the ''Refresh</i> button
</li>
<li>The Exit Decision that tell whether the review is accepted or if some rework has to be done </li>
<li>Participants that were part of the exit decision </li>
@@ -1034,8 +1042,7 @@
<li>In the Time Management expandable section
<ul>
<li>A table that tracks the Time Spent by the participant reviewing the file. Entries can be added (or removed) by the participant at any time by using the
- <i>Add </i>(or
- <i>Remove</i>) button. The table will also show the cumulative time spent in its header.
+ <i>Add ''(or ''Remove</i>) button. The table will also show the cumulative time spent in its header.
</li>
</ul>
</li>
@@ -1138,9 +1145,7 @@
<p>
<br/>
</p>
- <p>Selecting one option and closing the dialog will show up a simple email client pre-filled with all the relevant information. The user is free to modify the information as he sees fit and send the email by clicking the
- <i>OK </i>button.
- </p>
+ <p>Selecting one option and closing the dialog will show up a simple email client pre-filled with all the relevant information. The user is free to modify the information as he sees fit and send the email by clicking the ''OK ''button. </p>
<p>
<br/>
</p>
@@ -1153,9 +1158,7 @@
</p>
<h3 id="Using_Meeting_Notifications">Using Meeting Notifications</h3>
<p>Meeting can also be scheduled directly in the workbench using R4E. Meeting data generated is in a VCalendar format that is attached to the Email that will be sent. Meeting data for decision meeting is mandatory for Formal Reviews and optional for other review types. </p>
- <p>To add meeting data, use the
- <i>Update </i>button in the Extra property tab, under the Decision Information section, for the selected Review element. This will open the Meeting Information dialog.
- </p>
+ <p>To add meeting data, use the ''Update ''button in the Extra property tab, under the Decision Information section, for the selected Review element. This will open the Meeting Information dialog. </p>
<p>
<br/>
</p>
@@ -1175,9 +1178,7 @@
<p>
<img border="0" src="MeetingInfoDate.png"/>
</p>
- <p>The meeting info stored in the system can be retrieved at all times by using the
- <i>Refresh </i>button in the Extra property tab, under the Decision Information section, for the selected Review element.
- </p>
+ <p>The meeting info stored in the system can be retrieved at all times by using the ''Refresh ''button in the Extra property tab, under the Decision Information section, for the selected Review element. </p>
<p>
<br/>
</p>
@@ -1339,9 +1340,7 @@
<img border="0" src="FormalAnomalyStates.png"/>
</p>
<p>A new Anomaly in a Formal Review is set to
- <i>CREATED </i>by default. During the decision phase, it could be set to the same values as in Informal Reviews, and it can also be set to
- <i>ACCEPTED</i>, which means that the anomaly is deemed valid and will be handled and fixed. There is no
- <i>ASSIGNED </i>state for Anomalies in Formal Reviews. The rest of the anomaly flow is essentially the same as with Informal Reviews.
+ <i>CREATED ''by default. During the decision phase, it could be set to the same values as in Informal Reviews, and it can also be set to ''ACCEPTED</i>, which means that the anomaly is deemed valid and will be handled and fixed. There is no ''ASSIGNED ''state for Anomalies in Formal Reviews. The rest of the anomaly flow is essentially the same as with Informal Reviews.
<br/>
</p><hr/>
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser-toc.xml b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser-toc.xml
index 75226edc..366e77cd 100644
--- a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser-toc.xml
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser-toc.xml
@@ -89,6 +89,7 @@
<topic href="doc/Tasks.html#Creating_a_Resource_Review_Item" label="Creating a Resource Review Item"></topic>
<topic href="doc/Tasks.html#Creating_a_Commit_Review_Item" label="Creating a Commit Review Item"></topic>
</topic>
+ <topic href="doc/Tasks.html#Comparing_Review_Items" label="Comparing Review Items"></topic>
<topic href="doc/Tasks.html#Assigning_Review_Elements" label="Assigning Review Elements"></topic>
<topic href="doc/Tasks.html#Creating_an_Anomaly" label="Creating an Anomaly"></topic>
<topic href="doc/Tasks.html#Cloning_an_existing_Anomaly" label="Cloning an existing Anomaly"></topic>
@@ -159,7 +160,7 @@
<topic href="doc/Advanced-Topics.html" label="Advanced Topics">
<topic href="doc/Advanced-Topics.html#Working_with_multiple_patch_set_of_the_same_commit_in_a_review" label="Working with multiple patch set of the same commit in a review"></topic>
</topic>
- <anchor id="r4eUser"/>
<topic href="doc/_Updating-This-Document.html" label="_Updating This Document">
</topic>
+ <anchor id="r4eUser"/>
</toc>
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.html b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.html
index 4e3601b6..c6b18004 100644
--- a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.html
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.html
@@ -277,6 +277,9 @@
</ol>
</li>
<li>
+ <a href="Tasks.html#Comparing_Review_Items">Comparing Review Items</a>
+ </li>
+ <li>
<a href="Tasks.html#Assigning_Review_Elements">Assigning Review Elements</a>
</li>
<li>
@@ -590,10 +593,7 @@
<br/>
</p>
<p>&nbsp; &nbsp;This is used to specify the location of the data files that contain Review Group information.
- See below for more information on Review Groups. The Name and Description fields show additional information attached to the selected Review Group file. Typically, all R4E data files will be located on a shared network drive. Users can add one or multiple references to Group files to their workspace as needed using the
- <i>Add </i>button. Files can be removed from the workspace by pressing the
- <i>Remove </i>button. Files can be moved up or down in the list by clicking the corresponding button. This will affect the order in which the Groups are displayed in the Review Navigator.
- </p>
+ See below for more information on Review Groups. The Name and Description fields show additional information attached to the selected Review Group file. Typically, all R4E data files will be located on a shared network drive. Users can add one or multiple references to Group files to their workspace as needed using the ''Add ''button. Files can be removed from the workspace by pressing the ''Remove ''button. Files can be moved up or down in the list by clicking the corresponding button. This will affect the order in which the Groups are displayed in the Review Navigator.</p>
<p>&nbsp; &nbsp;If there is a version compatibility problem between the version of the Group file and the current R4E plugin version, where the R4E version is older than the Group file version, then this group cannot be used and the description field will show a version mismatch error. Such errors can typically be fixed by upgrading the R4E plugins to their later version.</p>
<p>
<b>Note: Make sure the defined directory location is accessible and configured with read/write permissions for the team members involved in the review.</b>
@@ -609,8 +609,7 @@
<br/>
</p>
<p>&nbsp; &nbsp;This is used to specify the location of the data files that contain Rule Set information. See below for more information on Rule Sets. The Name and Version fields show additional information attached to the selected Rule Set file. Typically, all R4E data files will be located on a shared network drive. Users can add one or multiple references to Rule Set files to their workspace as needed using the
- <i>Add </i>button. Files can be removed from the workspace by pressing the
- <i>Remove</i> button. Files can be moved up or down in the list by clicking the corresponding button. This will affect the order in which the Rule Sets are displayed in the Review Navigator.
+ <i>Add ''button. Files can be removed from the workspace by pressing the ''Remove</i> button. Files can be moved up or down in the list by clicking the corresponding button. This will affect the order in which the Rule Sets are displayed in the Review Navigator.
</p>
<p>&nbsp; &nbsp;If there is a version compatibility problem between the version of the Rule Set file and the current R4E plugin version, where the R4E version is older than the Rule Set file version, then this ruleset cannot be used and the description field will show a version mismatch error. Such errors can typically be fixed by upgrading the R4E plugins to their later version.</p>
<p>
@@ -646,10 +645,7 @@
<p>
<br/>
</p>
- <p>&nbsp; &nbsp;This is used to specify the mail server(s) that will be used to send manual and automatic email notifications to the users. More than one server can be specified. Users can add one or multiple servers to their workspace as needed using the
- <i>Add </i>button. Servers can be removed from the workspace by pressing the
- <i>Remove </i>button. Servers can be moved up or down in the list by clicking the corresponding button. The primary server should always be the first on the list.
- </p>
+ <p>&nbsp; &nbsp;This is used to specify the mail server(s) that will be used to send manual and automatic email notifications to the users. More than one server can be specified. Users can add one or multiple servers to their workspace as needed using the ''Add ''button. Servers can be removed from the workspace by pressing the ''Remove ''button. Servers can be moved up or down in the list by clicking the corresponding button. The primary server should always be the first on the list. </p>
<p>
<br/>
</p>
@@ -1168,9 +1164,7 @@
<br/>
</p>
<ul>
- <li>This will trigger the Email Client dialog. You can review the contents of the message, modify it as you see fit, and press the
- <i>OK </i>button to send it. Of course, the destination email address(es) need to be valid for the email to actually be sent.
- </li>
+ <li>This will trigger the Email Client dialog. You can review the contents of the message, modify it as you see fit, and press the ''OK ''button to send it. Of course, the destination email address(es) need to be valid for the email to actually be sent.</li>
</ul>
<p>
<br/>
@@ -1269,8 +1263,7 @@
<ul>
<li>Once the anomaly is resolved, we can set the Anomaly state to
<i>FIXED</i> by changing the
- <i>State </i>combo box value in the R4E Properties view. Note that the
- <i>Fixed by</i> property (in the
+ <i>State ''combo box value in the R4E Properties view. Note that the ''Fixed by</i> property (in the
<i>Participant Details</i> expandable section) gets automatically set to the current user. This can be changed to any of the participants if needed.
</li>
</ul>
@@ -1373,8 +1366,7 @@
</ul>
<ul>
<li>If you look at the Review Properties Detailed tab, you will notice that is display a
- <i>Phase Map</i> table. The phase map is only displayed for formal reviews and is used to track the progress of the review. At review creation, the
- <i>PLANNING </i>phase is the active one (highlighted in blue).
+ <i>Phase Map</i> table. The phase map is only displayed for formal reviews and is used to track the progress of the review. At review creation, the ''PLANNING ''phase is the active one (highlighted in blue).
</li>
</ul>
<ul>
@@ -1460,9 +1452,7 @@
<br/>
</p>
<ul>
- <li>Once the details are entered, the Email client dialog is shown, and upon clicking the
- <i>OK </i>button, a new notification of items ready for review, bundled with a meeting invitation will be sent to all participants.
- </li>
+ <li>Once the details are entered, the Email client dialog is shown, and upon clicking the ''OK ''button, a new notification of items ready for review, bundled with a meeting invitation will be sent to all participants.</li>
</ul>
<ul>
<li>Now, in
diff --git a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.mediawiki b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.mediawiki
index d94ea0f5..bed1802e 100644
--- a/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.mediawiki
+++ b/org.eclipse.mylyn.reviews.r4e.help/doc/_r4eOpenUser.mediawiki
@@ -1177,6 +1177,26 @@ Once a Commit Review Item is created, it will be shown in the Review Navigator.
The icons for the files that are new and were added in the commit will be shown decorated with a little [[Image:Addovr tsk.png]] icon The icons for the files that were removed in the commit will be shown decorated with a little [[Image:Removr tsk.png]] icon Files in the commit that are out of sync i.e. for which the version to review and the version present in the users workspace differ will be shown with the &gt; sign prepended to the filename. Such files can be reviewed, but to use the full navigatability provided by the editors, it is strongly recommended that the files be in sync with the workspace whenever possible.
<br>
+
+ When two Review Items have the same first line description, their displayed name in the Review Navigator will include a version number just after the Review Item type (e.g. Commit 1:... and Commit 2:..., where ... are two identical strings). This will show the users that the two Review Items are two different versions of the same code change. Of course, the first line of the Review Item description must not be changed for this function to work.
+
+=== Comparing Review Items ===
+
+Is is possible to compare two arbitrary Review Items that are included in the same Review. Typically this will be used to see the differences between two versions of a given code change.
+
+In order to do this, select two Review Items in the Review Navigator (using Ctrl-Left click or Shift-Left click) and then right click on one of the items and select the "Compare Review Items" command from the context menu
+
+[[Image:CompareReviewItems.png]]
+
+This will open a Structural Compare Editor that will show the files versions that are different. The file that belong to the most recently committed Review Item will always be the target files (on the left side) and the files belonging to the oldest Review Item will be the base files (on the right side).
+
+Little + decorators show the files that were added in the newest Review Item, whereas - decorators show removed files.
+
+To see the differences within a specific file, just double click on it and the lower side of the compare editor will be populated with the content differences between the files. From the Compare Editor, it is also possible to modify the R4E annotation markers (see [[#Using Review Annotations and Inline Comments|R4E Annotations]]), on either side.
+
+For instance, one could verify that anomalies that were written on a previous version of the code change are indeed corrected and change the state of the anomalies on the base version (right side) accordingly, as shown below.
+
+[[Image:CompareReviewItemsEditor.png]]
=== Assigning Review Elements ===
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/R4EUIAllTests.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/R4EUIAllTests.java
index 19c5a07b..cd84870c 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/R4EUIAllTests.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/R4EUIAllTests.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.eclipse.mylyn.reviews.r4e.ui.tests.feature.CloneAnomaliesCommentsTests;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.feature.CompareReviewItemsTests;
import org.eclipse.mylyn.reviews.r4e.ui.tests.feature.DuplicateAnomalyTests;
import org.eclipse.mylyn.reviews.r4e.ui.tests.feature.PostponedAnomaliesTests;
import org.eclipse.mylyn.reviews.r4e.ui.tests.feature.PreferencesTests;
@@ -66,6 +67,8 @@ public class R4EUIAllTests extends TestSuite {
suite.addTestSuite(DuplicateAnomalyTests.class);
suite.addTestSuite(ReviewWithStrangeCharTest.class);
suite.addTestSuite(UpgradeVersionTests.class);
+ suite.addTestSuite(CompareReviewItemsTests.class);
+
//TODO Add test cases here
//suite.addTestSuite(ReviewGroupTests.class);
//suite.addTestSuite(ReviewTests.class);
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/feature/CompareReviewItemsTests.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/feature/CompareReviewItemsTests.java
new file mode 100644
index 00000000..011f83e3
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/feature/CompareReviewItemsTests.java
@@ -0,0 +1,485 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson Research Canada
+ *
+ * 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
+ *
+ * Description:
+ *
+ * This class implements JUnit Test Cases for comparing 2 review items
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.ui.tests.feature;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4ECommentType;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EParticipant;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4ETextContent;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4ETextPosition;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EUserRole;
+import org.eclipse.mylyn.reviews.r4e.core.model.RModelFactory;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIAnomalyBasic;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIParticipant;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewBasic;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewGroup;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.navigator.ReviewNavigatorActionGroup;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.R4EUIConstants;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.R4ETestSetup;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.proxy.R4EUITestMain;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.utils.R4EAssert;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestConstants;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestUtils;
+import org.junit.After;
+import org.junit.Before;
+
+@SuppressWarnings("restriction")
+public class CompareReviewItemsTests extends TestCase {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ private static final String JAVA_FILE12_EXT_MOD_PATH = "testFiles" + File.separator + "extModCommitFile12.java";
+
+ private static final String REVIEW_ITEM_COMMIT_1 = "Commit 1: second Jav...";
+
+ private static final String REVIEW_ITEM_COMMIT_2 = "Commit 2: second Jav...";
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+
+ private R4EUITestMain fProxy = null;
+
+ private R4EUIReviewGroup fGroup = null;
+
+ private String fGroupName = null;
+
+ private R4EUIReviewBasic fReview = null;
+
+ private R4EUIReviewItem fItem = null;
+
+ private R4EUIReviewItem fItem2 = null;
+
+ private int fAnomalyFileIndex;
+
+ private R4EUIParticipant fParticipant = null;
+
+ private R4EUIAnomalyBasic fCompareEditorAnomaly = null;
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method suite - Sets up the global test environment, if not already done at the suite level.
+ *
+ * @return Test
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTestSuite(CompareReviewItemsTests.class);
+ return new R4ETestSetup(suite);
+ }
+
+ /**
+ * Method setUp - Sets up the fixture, for example, open a network connection. This method is called before a test
+ * is executed.
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ fProxy = R4EUITestMain.getInstance();
+ createReviewGroup();
+ if (((ReviewNavigatorActionGroup) R4EUIModelController.getNavigatorView().getActionSet()).isHideDeltasFilterSet()) {
+ fProxy.getCommandProxy().toggleHideDeltasFilter();
+ }
+ createReview();
+ createReviewItems();
+ createParticipants();
+ createCompareEditorAnomalies();
+ }
+
+ /**
+ * Method tearDown
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ fProxy = null;
+ }
+
+ /**
+ * Method testInformalReviews
+ *
+ * @throws CoreException
+ */
+ public void testCompareReviewItems() throws CoreException, IOException, URISyntaxException {
+ TestUtils.waitForJobs();
+ commitNewReviewItemVersion();
+ compareReviewItemsVersions();
+ }
+
+ /**
+ * Method createReviewGroup
+ */
+ private void createReviewGroup() {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("createReviewGroups");
+
+ fGroup = null;
+
+ //Create Review Group
+ r4eAssert.setTest("Create Review Group");
+ for (R4EUIReviewGroup group : R4EUIModelController.getRootElement().getGroups()) {
+ if (group.getReviewGroup().getName().equals(TestConstants.REVIEW_GROUP_TEST_NAME)) {
+ fGroup = group;
+ fGroupName = group.getName();
+ break;
+ }
+ }
+ if (null == fGroup) {
+ fGroup = fProxy.getReviewGroupProxy().createReviewGroup(
+ TestUtils.FSharedFolder + File.separator + TestConstants.REVIEW_GROUP_TEST_NAME,
+ TestConstants.REVIEW_GROUP_TEST_NAME, TestConstants.REVIEW_GROUP_TEST_DESCRIPTION,
+ TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA, TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS,
+ TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS, new String[0]);
+ r4eAssert.assertNotNull(fGroup);
+ r4eAssert.assertEquals(TestConstants.REVIEW_GROUP_TEST_NAME, fGroup.getReviewGroup().getName());
+ r4eAssert.assertEquals(new Path(TestUtils.FSharedFolder).toPortableString() + "/"
+ + TestConstants.REVIEW_GROUP_TEST_NAME, fGroup.getReviewGroup().getFolder());
+ r4eAssert.assertEquals(TestConstants.REVIEW_GROUP_TEST_DESCRIPTION, fGroup.getReviewGroup()
+ .getDescription());
+ r4eAssert.assertEquals(TestConstants.REVIEW_GROUP_TEST_ENTRY_CRITERIA, fGroup.getReviewGroup()
+ .getDefaultEntryCriteria());
+ for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS.length; i++) {
+ r4eAssert.assertEquals(TestConstants.REVIEW_GROUP_TEST_AVAILABLE_PROJECTS[i], fGroup.getReviewGroup()
+ .getAvailableProjects()
+ .get(i));
+ }
+ for (int i = 0; i < TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS.length; i++) {
+ r4eAssert.assertEquals(TestConstants.REVIEW_GROUP_TEST_AVAILABLE_COMPONENTS[i], fGroup.getReviewGroup()
+ .getAvailableComponents()
+ .get(i));
+ }
+ fGroupName = fGroup.getName();
+ }
+ }
+
+ /**
+ * Method createReviews
+ */
+ private void createReview() {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("createReviews");
+
+ //Update Review Group handle
+ for (IR4EUIModelElement elem : R4EUIModelController.getRootElement().getChildren()) {
+ if (fGroupName.equals(elem.getName())) {
+ fGroup = (R4EUIReviewGroup) elem;
+ }
+ }
+
+ r4eAssert.setTest("Open Review Group");
+ if (!fGroup.isOpen()) {
+ fProxy.getCommandProxy().openElement(fGroup);
+ }
+ r4eAssert.assertTrue(fGroup.isOpen());
+
+ r4eAssert.setTest("Create Review");
+ fReview = fProxy.getReviewProxy().createReview(fGroup, TestConstants.REVIEW_TEST_TYPE_INFORMAL,
+ TestConstants.REVIEW_TEST_NAME_INF, TestConstants.REVIEW_TEST_DESCRIPTION,
+ TestConstants.REVIEW_TEST_DUE_DATE, TestConstants.REVIEW_TEST_PROJECT,
+ TestConstants.REVIEW_TEST_COMPONENTS, TestConstants.REVIEW_TEST_ENTRY_CRITERIA,
+ TestConstants.REVIEW_TEST_OBJECTIVES, TestConstants.REVIEW_TEST_REFERENCE_MATERIALS);
+ r4eAssert.assertNotNull(fReview);
+ r4eAssert.assertNotNull(fReview.getParticipantContainer());
+ r4eAssert.assertNotNull(fReview.getAnomalyContainer());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_TYPE_INFORMAL, fReview.getReview().getType());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_NAME_INF, fReview.getReview().getName());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_DESCRIPTION, fReview.getReview().getExtraNotes());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_DUE_DATE, fReview.getReview().getDueDate());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_PROJECT, fReview.getReview().getProject());
+ for (int i = 0; i < TestConstants.REVIEW_TEST_COMPONENTS.length; i++) {
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_COMPONENTS[i], fReview.getReview().getComponents().get(i));
+ }
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_ENTRY_CRITERIA, fReview.getReview().getEntryCriteria());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_OBJECTIVES, fReview.getReview().getObjectives());
+ r4eAssert.assertEquals(TestConstants.REVIEW_TEST_REFERENCE_MATERIALS, fReview.getReview()
+ .getReferenceMaterial());
+ r4eAssert.assertTrue(fReview.isOpen());
+ }
+
+ /**
+ * Method createReviewItems
+ */
+ private void createReviewItems() throws CoreException {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("createReviewItems");
+
+ r4eAssert.setTest("Create Commit Item");
+ fItem = fProxy.getItemProxy().createCommitItem(TestUtils.FJavaIProject, 0);
+ //close and re-open, so the validation takes de-serialized information
+ String itemName = fItem.getName();
+ fProxy.getCommandProxy().closeElement(fReview);
+ fProxy.getCommandProxy().openElement(fReview);
+ for (IR4EUIModelElement elem : fReview.getChildren()) {
+ if (elem.getName().equals(itemName)) {
+ fItem = (R4EUIReviewItem) elem;
+ }
+ }
+
+ //Now validate
+ r4eAssert.assertNotNull(fItem);
+ r4eAssert.assertEquals(R4EUIModelController.getReviewer(), fItem.getItem().getAddedById());
+ r4eAssert.assertEquals("The.committer@some.com", fItem.getItem().getAuthorRep());
+ r4eAssert.assertEquals("second Java Commit", fItem.getItem().getDescription());
+ r4eAssert.assertEquals(4, fItem.getChildren().length);
+ for (int i = 0; i < fItem.getChildren().length; i++) {
+ if (((R4EUIFileContext) fItem.getChildren()[i]).getName().equals(TestUtils.JAVA_FILE1_PROJ_NAME)) {
+ fAnomalyFileIndex = i; //Used later to add anomalies
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE1_PROJ_NAME, fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getBase()
+ .getName());
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE1_PROJ_NAME, fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getTarget()
+ .getName());
+ r4eAssert.assertEquals(606, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(0)
+ .getTarget()
+ .getLocation()).getStartPosition());
+ r4eAssert.assertEquals(25, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(0)
+ .getTarget()
+ .getLocation()).getLength());
+ r4eAssert.assertEquals(665, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(1)
+ .getTarget()
+ .getLocation()).getStartPosition());
+ r4eAssert.assertEquals(63, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(1)
+ .getTarget()
+ .getLocation()).getLength());
+ r4eAssert.assertEquals(733, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(2)
+ .getTarget()
+ .getLocation()).getStartPosition());
+ r4eAssert.assertEquals(61, ((R4ETextPosition) fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(2)
+ .getTarget()
+ .getLocation()).getLength());
+ r4eAssert.assertTrue(fProxy.getCommandProxy().verifyAnnotations(
+ ((R4EUIFileContext) fItem.getChildren()[i]).getContentsContainerElement().getChildren(), true,
+ R4EUIConstants.DELTA_ANNOTATION_ID));
+ } else if (((R4EUIFileContext) fItem.getChildren()[i]).getName().equals(TestUtils.JAVA_FILE4_PROJ_NAME)) {
+ r4eAssert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE4_PROJ_NAME, fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getTarget()
+ .getName());
+ } else if (((R4EUIFileContext) fItem.getChildren()[i]).getName().equals(TestUtils.JAVA_FILE3_PROJ_NAME)) {
+ r4eAssert.assertNull(fItem.getItem().getFileContextList().get(i).getBase());
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE3_PROJ_NAME, fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getTarget()
+ .getName());
+ } else if (((R4EUIFileContext) fItem.getChildren()[i]).getName().equals(TestUtils.JAVA_FILE2_PROJ_NAME)) {
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE2_PROJ_NAME, fItem.getItem()
+ .getFileContextList()
+ .get(i)
+ .getBase()
+ .getName());
+ r4eAssert.assertNull(fItem.getItem().getFileContextList().get(i).getTarget());
+ }
+ }
+ }
+
+ /**
+ * Method createParticipants
+ */
+ private void createParticipants() {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("createParticipants");
+
+ r4eAssert.setTest("Create Participant");
+
+ List<R4EParticipant> participants = new ArrayList<R4EParticipant>(1);
+ R4EParticipant participant = RModelFactory.eINSTANCE.createR4EParticipant();
+ participant.setId(TestConstants.PARTICIPANT_TEST_ID);
+ participant.setEmail(TestConstants.PARTICIPANT_TEST_EMAIL);
+ participants.add(participant);
+ fParticipant = fProxy.getParticipantProxy().createParticipant(fReview.getParticipantContainer(), participants);
+ r4eAssert.assertNotNull(fParticipant);
+ r4eAssert.assertEquals(TestConstants.PARTICIPANT_TEST_ID, fParticipant.getParticipant().getId());
+ r4eAssert.assertEquals(TestConstants.PARTICIPANT_TEST_EMAIL, fParticipant.getParticipant().getEmail());
+ r4eAssert.assertEquals(R4EUserRole.REVIEWER, fParticipant.getParticipant().getRoles().get(0));
+ }
+
+ /**
+ * Method createCompareEditorAnomalies
+ */
+ private void createCompareEditorAnomalies() {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("createCompareEditorAnomalies");
+
+ r4eAssert.setTest("Create Compare Editor Anomaly");
+ fCompareEditorAnomaly = fProxy.getAnomalyProxy().createCompareEditorAnomaly(
+ fItem.getFileContexts().get(fAnomalyFileIndex), 20, 50,
+ TestConstants.COMPARE_EDITOR_ANOMALY_TEST_TITLE, TestConstants.COMPARE_EDITOR_ANOMALY_TEST_DESCRIPTION,
+ TestConstants.ANOMALY_TEST_CLASS_ERRONEOUS, TestConstants.ANOMALY_TEST_RANK_MINOR,
+ TestConstants.ANOMALY_TEST_DUE_DATE, TestConstants.PARTICIPANT_ASSIGN_TO, null);
+ r4eAssert.assertNotNull(fCompareEditorAnomaly);
+ r4eAssert.assertEquals(TestConstants.COMPARE_EDITOR_ANOMALY_TEST_TITLE, fCompareEditorAnomaly.getAnomaly()
+ .getTitle());
+ r4eAssert.assertEquals(TestConstants.COMPARE_EDITOR_ANOMALY_TEST_DESCRIPTION,
+ fCompareEditorAnomaly.getAnomaly().getDescription());
+ r4eAssert.assertEquals(TestConstants.ANOMALY_TEST_CLASS_ERRONEOUS,
+ ((R4ECommentType) fCompareEditorAnomaly.getAnomaly().getType()).getType());
+ r4eAssert.assertEquals(TestConstants.ANOMALY_TEST_RANK_MINOR, fCompareEditorAnomaly.getAnomaly().getRank());
+ r4eAssert.assertEquals(TestConstants.ANOMALY_TEST_DUE_DATE, fCompareEditorAnomaly.getAnomaly().getDueDate());
+ r4eAssert.assertEquals(TestConstants.PARTICIPANT_ASSIGN_TO, fCompareEditorAnomaly.getAnomaly()
+ .getAssignedTo()
+ .get(0));
+ r4eAssert.assertEquals(20, ((R4ETextPosition) ((R4ETextContent) fCompareEditorAnomaly.getAnomaly()
+ .getLocations()
+ .get(0)).getLocation()).getStartPosition());
+ r4eAssert.assertEquals(50, ((R4ETextPosition) ((R4ETextContent) fCompareEditorAnomaly.getAnomaly()
+ .getLocations()
+ .get(0)).getLocation()).getLength());
+ r4eAssert.assertTrue(fProxy.getCommandProxy().verifyAnnotation(fCompareEditorAnomaly, true,
+ R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID));
+ }
+
+ /**
+ * Method commitNewReviewItemVersion
+ */
+ private void commitNewReviewItemVersion() throws CoreException, IOException, URISyntaxException {
+
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("commitNewReviewItemVersion");
+
+ r4eAssert.setTest("Commit New Review Item Version");
+ TestUtils.FJavaFile1 = TestUtils.changeContentOfFile(TestUtils.FJavaFile1, JAVA_FILE12_EXT_MOD_PATH);
+ TestUtils.commitFiles(TestUtils.FJavaIProject, TestUtils.FJavaRepository, "second Java Commit", true);
+
+ fItem2 = fProxy.getItemProxy().createCommitItem(TestUtils.FJavaIProject, 0);
+ //close and re-open, so the validation takes de-serialized information
+ fProxy.getCommandProxy().closeElement(fReview);
+ fProxy.getCommandProxy().openElement(fReview);
+
+ for (IR4EUIModelElement elem : fReview.getChildren()) {
+ if (elem.getName().equals(REVIEW_ITEM_COMMIT_1)) {
+ fItem = (R4EUIReviewItem) elem;
+ }
+ if (elem.getName().equals(REVIEW_ITEM_COMMIT_2)) {
+ fItem2 = (R4EUIReviewItem) elem;
+ }
+ }
+
+ //Now validate
+ r4eAssert.assertNotNull(fItem);
+ r4eAssert.assertEquals(R4EUIModelController.getReviewer(), fItem2.getItem().getAddedById());
+ r4eAssert.assertEquals("The.committer@some.com", fItem2.getItem().getAuthorRep());
+ r4eAssert.assertEquals("second Java Commit", fItem2.getItem().getDescription());
+ r4eAssert.assertEquals(2, fItem2.getChildren().length);
+ for (int i = 0; i < fItem2.getChildren().length; i++) {
+ if (((R4EUIFileContext) fItem2.getChildren()[i]).getName().equals(TestUtils.JAVA_FILE1_PROJ_NAME)) {
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE1_PROJ_NAME, fItem2.getItem()
+ .getFileContextList()
+ .get(i)
+ .getBase()
+ .getName());
+ r4eAssert.assertEquals(TestUtils.JAVA_FILE1_PROJ_NAME, fItem2.getItem()
+ .getFileContextList()
+ .get(i)
+ .getTarget()
+ .getName());
+ r4eAssert.assertEquals(733, ((R4ETextPosition) fItem2.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(0)
+ .getTarget()
+ .getLocation()).getStartPosition());
+ r4eAssert.assertEquals(31, ((R4ETextPosition) fItem2.getItem()
+ .getFileContextList()
+ .get(i)
+ .getDeltas()
+ .get(0)
+ .getTarget()
+ .getLocation()).getLength());
+ }
+ }
+
+ }
+
+ /**
+ * Method compareReviewItemsVersions
+ */
+ private void compareReviewItemsVersions() {
+ // Assert object
+ R4EAssert r4eAssert = new R4EAssert("compareReviewItemsVersions");
+
+ r4eAssert.setTest("Compare Review Items Versions");
+ fCompareEditorAnomaly = (R4EUIAnomalyBasic) fItem.getFileContexts()
+ .get(fAnomalyFileIndex)
+ .getAnomalyContainerElement()
+ .getChildren()[0];
+ fProxy.getItemProxy().openCompareReviewItems(fItem, fItem2, fCompareEditorAnomaly,
+ R4EUIConstants.ANOMALY_OPEN_ANNOTATION_ID);
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestCommands.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestCommands.java
index 15b8c243..8ab94228 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestCommands.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestCommands.java
@@ -1102,7 +1102,7 @@ public class R4EUITestCommands extends R4EUITestElement {
//Assume postponed element
sourceElement = (R4EUIFileContext) element.getParent().getParent();
}
- IReviewAnnotation annotation = ((R4EAnnotationModel) ((R4ESingleAnnotationSupport) UIUtils.getAnnotationSupport(sourceElement)).getTargetAnnotationModel()).findAnnotation(
+ IReviewAnnotation annotation = ((R4EAnnotationModel) ((R4ESingleAnnotationSupport) UIUtils.getAnnotationSupport(sourceElement)).getAnnotationModel()).findAnnotation(
type, element);
if (null == annotation) {
return;
@@ -1174,6 +1174,7 @@ public class R4EUITestCommands extends R4EUITestElement {
if (null == editor) {
return;
}
+
annotation = ((R4ECompareEditorInput) editor.getEditorInput()).getAnnotationModel().findAnnotation(
type, element);
if (null == annotation) {
@@ -1181,29 +1182,30 @@ public class R4EUITestCommands extends R4EUITestElement {
}
closeEditor(editor);
TestUtils.waitForJobs();
- }
-
- //Open Single editor on first element and check annotations
- setFocusOnNavigatorElement(element);
- editor = openEditorOnCurrentElement(true);
- TestUtils.waitForJobs();
- if (null == editor) {
- return;
- }
- R4EUIFileContext sourceElement;
- if (element instanceof R4EUIPostponedAnomaly) {
- sourceElement = (R4EUIPostponedFile) element.getParent();
} else {
- //Assume postponed element
- sourceElement = (R4EUIFileContext) element.getParent().getParent();
- }
- annotation = ((R4EAnnotationModel) ((R4ESingleAnnotationSupport) UIUtils.getAnnotationSupport(sourceElement)).getTargetAnnotationModel()).findAnnotation(
- type, element);
- if (null == annotation) {
- return;
+
+ //Open Single editor on first element and check annotations
+ setFocusOnNavigatorElement(element);
+ editor = openEditorOnCurrentElement(true);
+ TestUtils.waitForJobs();
+ if (null == editor) {
+ return;
+ }
+ R4EUIFileContext sourceElement;
+ if (element instanceof R4EUIPostponedAnomaly) {
+ sourceElement = (R4EUIPostponedFile) element.getParent();
+ } else {
+ //Assume postponed element
+ sourceElement = (R4EUIFileContext) element.getParent().getParent();
+ }
+ annotation = ((R4EAnnotationModel) ((R4ESingleAnnotationSupport) UIUtils.getAnnotationSupport(sourceElement)).getAnnotationModel()).findAnnotation(
+ type, element);
+ if (null == annotation) {
+ return;
+ }
+ closeEditor(editor);
+ TestUtils.waitForJobs();
}
- closeEditor(editor);
- TestUtils.waitForJobs();
result = true;
}
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestItem.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestItem.java
index 56166c09..1f18178b 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestItem.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/proxy/R4EUITestItem.java
@@ -22,8 +22,12 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import java.util.ArrayList;
import java.util.List;
+import org.eclipse.compare.ICompareNavigator;
+import org.eclipse.compare.internal.CompareEditorInputNavigator;
+import org.eclipse.compare.internal.CompareStructureViewerSwitchingPane;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.NotEnabledException;
import org.eclipse.core.commands.NotHandledException;
@@ -35,9 +39,19 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotation;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileContext;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.control.R4ECompareAnnotationSupport;
import org.eclipse.mylyn.reviews.r4e.ui.internal.dialogs.R4EUIDialogFactory;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EDiffNode;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.R4EUIConstants;
+import org.eclipse.mylyn.reviews.r4e.ui.tests.utils.R4EAssert;
import org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestUtils;
import org.eclipse.mylyn.versions.core.ChangeSet;
import org.eclipse.mylyn.versions.core.ScmCore;
@@ -45,6 +59,7 @@ import org.eclipse.mylyn.versions.core.ScmRepository;
import org.eclipse.mylyn.versions.core.spi.ScmConnector;
import org.eclipse.mylyn.versions.ui.spi.ScmConnectorUi;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.history.provider.FileRevision;
import org.eclipse.ui.IEditorPart;
@@ -54,6 +69,8 @@ import org.eclipse.ui.texteditor.ITextEditor;
@SuppressWarnings({ "restriction", "nls" })
public class R4EUITestItem extends R4EUITestElement {
+ private static String COMPARE_REVIEW_ITEMS_COMMAND = "org.eclipse.mylyn.reviews.r4e.ui.commands.compareItems";
+
public R4EUITestItem(R4EUITestMain aR4EUITestProxy) {
super(aR4EUITestProxy);
}
@@ -253,6 +270,121 @@ public class R4EUITestItem extends R4EUITestElement {
}
/**
+ * Method openCompareReviewItems
+ *
+ * @param aItem1
+ * - R4EUIReviewItem
+ * @param aItem2
+ * - R4EUIReviewItem
+ * @param aAnnotationElement
+ * - IR4EUIModelElement
+ * @param aAnnotationType
+ * - String
+ */
+ public void openCompareReviewItems(final R4EUIReviewItem aItem1, final R4EUIReviewItem aItem2,
+ IR4EUIModelElement aAnnotationElement, String aAnnotationType) {
+
+ //Inner class that runs the command on the UI thread
+ class RunCompareReviewItems implements Runnable {
+ private List<IR4EUIModelElement> elements;
+
+ private IR4EUIModelElement annotationElement;
+
+ private String annotationType;
+
+ public void setElements(List<IR4EUIModelElement> aElements) {
+ elements = aElements;
+ }
+
+ public void setAnnotationElement(IR4EUIModelElement aAnnotationElement) {
+ annotationElement = aAnnotationElement;
+ }
+
+ public void setAnnotationType(String aAnnotationType) {
+ annotationType = aAnnotationType;
+ }
+
+ public void run() {
+ try {
+ R4EAssert r4eAssert = new R4EAssert("openCompareReviewItems");
+ r4eAssert.setTest("Open Compare Review Item");
+
+ //Set focus on Review Navigator Element
+ setFocusOnNavigatorElements(elements);
+ TestUtils.waitForJobs();
+
+ //Compare Review Items
+ fParentProxy.getCommandProxy().executeCommand(COMPARE_REVIEW_ITEMS_COMMAND, null);
+ TestUtils.waitForJobs();
+
+ //Select Range in Editor
+ IEditorPart editor = getCurrentEditor();
+ TestUtils.waitForJobs();
+
+ R4EDiffNode selectedDiffNode = (R4EDiffNode) ((R4ECompareEditorInput) editor.getEditorInput()).getSelectedEdition();
+
+ R4EFileVersion targetVersion = null;
+ R4EFileVersion baseVersion = null;
+
+ for (R4EFileContext file : aItem2.getItem().getFileContextList()) {
+ if (null != file.getTarget()
+ && file.getTarget().getName().equals(selectedDiffNode.getTargetVersion().getName())) {
+ targetVersion = file.getTarget();
+ }
+ }
+ r4eAssert.assertEquals(targetVersion, selectedDiffNode.getTargetVersion());
+
+ for (R4EFileContext file : aItem1.getItem().getFileContextList()) {
+ if (null != file.getTarget()
+ && file.getTarget().getName().equals(selectedDiffNode.getBaseVersion().getName())) {
+ baseVersion = file.getTarget();
+ }
+ }
+ r4eAssert.assertEquals(baseVersion, selectedDiffNode.getBaseVersion());
+
+ //Open the content CompareEditor on the selected diffNode
+ final ICompareNavigator navigator = ((R4ECompareEditorInput) editor.getEditorInput()).getNavigator();
+ final Object structuredPane = ((CompareEditorInputNavigator) navigator).getPanes()[0];
+ Tree tree = (Tree) ((CompareStructureViewerSwitchingPane) structuredPane).getChildren()[2];
+ tree.setSelection(tree.getItem(0));
+ Viewer viewer = ((CompareStructureViewerSwitchingPane) structuredPane).getViewer();
+ OpenEvent event = new OpenEvent(viewer, viewer.getSelection());
+ ((CompareStructureViewerSwitchingPane) structuredPane).open(event);
+ TestUtils.waitForJobs();
+
+ //Verify that the annotation for the passed in Anomaly is present on the right (base) side
+ R4ECompareAnnotationSupport support = (R4ECompareAnnotationSupport) ((R4ECompareEditorInput) editor.getEditorInput()).getCurrentDiffNode()
+ .getAnnotationSupport();
+ IReviewAnnotation annotation = support.getBaseAnnotationModel().findAnnotation(annotationType,
+ annotationElement);
+ r4eAssert.assertNotNull(annotation);
+
+ } catch (ExecutionException e) {
+ // ignore, test will fail later
+ } catch (NotDefinedException e) {
+ // ignore, test will fail later
+ } catch (NotEnabledException e) {
+ // ignore, test will fail later
+ } catch (NotHandledException e) {
+ // ignore, test will fail later
+ }
+ }
+ }
+ ;
+
+ //Run the UI job and wait until the command is completely executed before continuing
+ RunCompareReviewItems compareReviewItemsJob = new RunCompareReviewItems();
+ List<IR4EUIModelElement> elements = new ArrayList<IR4EUIModelElement>(2);
+ elements.add(aItem1);
+ elements.add(aItem2);
+ compareReviewItemsJob.setElements(elements);
+ compareReviewItemsJob.setAnnotationElement(aAnnotationElement);
+ compareReviewItemsJob.setAnnotationType(aAnnotationType);
+ Display.getDefault().syncExec(compareReviewItemsJob);
+ TestUtils.waitForJobs();
+ }
+
+ /**
* Method getChangeSet
*
* @param aProject
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/utils/TestUtils.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/utils/TestUtils.java
index b3058939..af7578de 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/utils/TestUtils.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/src/org/eclipse/mylyn/reviews/r4e/ui/tests/utils/TestUtils.java
@@ -289,7 +289,7 @@ public class TestUtils {
resources.add(FJavaFile1);
resources.add(FJavaFile2);
addFilesToRepository(resources);
- commitFiles(FJavaIProject, FJavaRepository, "first Java Commit");
+ commitFiles(FJavaIProject, FJavaRepository, "first Java Commit", false);
//Update files (Modify File1, Remove File2, Add File 3, Add File4)
FJavaFile1 = changeContentOfFile(FJavaFile1, JAVA_FILE1_EXT_MOD_PATH);
@@ -304,7 +304,7 @@ public class TestUtils {
resources.add(FJavaFile3);
resources.add(FJavaFile4);
addFilesToRepository(resources);
- commitFiles(FJavaIProject, FJavaRepository, "second Java Commit");
+ commitFiles(FJavaIProject, FJavaRepository, "second Java Commit", false);
//Update files (Modify File4, Add File5, do not commit)
FJavaFile4 = changeContentOfFile(FJavaFile4, JAVA_FILE4_EXT_MOD_PATH);
@@ -334,7 +334,7 @@ public class TestUtils {
resources.add(FCFile1);
resources.add(FCFile2);
addFilesToRepository(resources);
- commitFiles(FCIProject, FCRepository, "first C Commit");
+ commitFiles(FCIProject, FCRepository, "first C Commit", false);
//Update files (Modify File1, Remove File2, Add File 3, Add File4)
FCFile1 = changeContentOfFile(FCFile1, C_FILE1_EXT_MOD_PATH);
@@ -349,7 +349,7 @@ public class TestUtils {
resources.add(FCFile3);
resources.add(FCFile4);
addFilesToRepository(resources);
- commitFiles(FCIProject, FCRepository, "second C Commit");
+ commitFiles(FCIProject, FCRepository, "second C Commit", false);
//Update files (Modify File4, Add File5, do not commit)
FCFile4 = changeContentOfFile(FCFile4, C_FILE4_EXT_MOD_PATH);
@@ -376,7 +376,7 @@ public class TestUtils {
resources.add(FTextFile1);
resources.add(FTextFile2);
addFilesToRepository(resources);
- commitFiles(FTextIProject, FTextRepository, "first Text Commit");
+ commitFiles(FTextIProject, FTextRepository, "first Text Commit", false);
//Update files (Modify File1, Remove File2, Add File 3, Add File4)
FTextFile1 = changeContentOfFile(FTextFile1, TEXT_FILE1_EXT_MOD_PATH);
@@ -391,7 +391,7 @@ public class TestUtils {
resources.add(FTextFile3);
resources.add(FTextFile4);
addFilesToRepository(resources);
- commitFiles(FTextIProject, FTextRepository, "second Text Commit");
+ commitFiles(FTextIProject, FTextRepository, "second Text Commit", false);
//Update files (Modify File4, Add File5, do not commit)
FTextFile4 = changeContentOfFile(FTextFile4, TEXT_FILE4_EXT_MOD_PATH);
@@ -564,10 +564,12 @@ public class TestUtils {
return file;
}
- public static void commitFiles(IProject aProject, Repository aRepository, String aCommitMsg) throws CoreException {
+ public static void commitFiles(IProject aProject, Repository aRepository, String aCommitMsg, boolean aAmend)
+ throws CoreException {
CommitOperation commitOperation = new CommitOperation(null, null, null, TestUtils.AUTHOR, TestUtils.COMMITTER,
aCommitMsg);
commitOperation.setCommitAll(true);
+ commitOperation.setAmending(aAmend);
commitOperation.setRepository(aRepository);
commitOperation.execute(null);
aProject.refreshLocal(IResource.DEPTH_INFINITE, null);
diff --git a/org.eclipse.mylyn.reviews.r4e.ui.tests/testFiles/extModCommitFile12.java b/org.eclipse.mylyn.reviews.r4e.ui.tests/testFiles/extModCommitFile12.java
new file mode 100644
index 00000000..d707c89a
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui.tests/testFiles/extModCommitFile12.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 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
+ *
+ ******************************************************************************/
+
+
+//This is a test file used by the R4E UI Test framework
+
+package org.eclipse.mylyn.reviews.r4e.ui;
+
+public class extModCommitFile {
+
+ private int someIntMod;
+
+ public extModCommitFile {
+ }
+
+ public setSomeInt(int someInt) {
+ this.someIntMod = someInt;
+ }
+
+ public addSomeIntModified() {
+ this.someIntMod += this.someIntMod;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/icons/elcl16/compareitems_menu.gif b/org.eclipse.mylyn.reviews.r4e.ui/icons/elcl16/compareitems_menu.gif
new file mode 100644
index 00000000..dc549bce
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/icons/elcl16/compareitems_menu.gif
Binary files differ
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/plugin.xml b/org.eclipse.mylyn.reviews.r4e.ui/plugin.xml
index 0ecc6c12..05286056 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/plugin.xml
+++ b/org.eclipse.mylyn.reviews.r4e.ui/plugin.xml
@@ -775,6 +775,12 @@
</command>
<command
categoryId="org.eclipse.mylyn.reviews.r4e.ui.commands.navigatorElementCategory"
+ description="Compare Review Items in Compare Editor"
+ id="org.eclipse.mylyn.reviews.r4e.ui.commands.compareItems"
+ name="Compare Review Items">
+ </command>
+ <command
+ categoryId="org.eclipse.mylyn.reviews.r4e.ui.commands.navigatorElementCategory"
description="Mark as User Reviewed"
id="org.eclipse.mylyn.reviews.r4e.ui.commands.changeReviewState"
name="Mark as User Reviewed">
@@ -1264,6 +1270,15 @@
</enabledWhen>
</handler>
<handler
+ class="org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers.CompareItemsHandler"
+ commandId="org.eclipse.mylyn.reviews.r4e.ui.commands.compareItems">
+ <enabledWhen>
+ <test
+ property="org.eclipse.mylyn.reviews.r4e.ui.commands.dialog.dialogOpen">
+ </test>
+ </enabledWhen>
+ </handler>
+ <handler
class="org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers.ChangeReviewStateHandler"
commandId="org.eclipse.mylyn.reviews.r4e.ui.commands.changeReviewState">
<enabledWhen>
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/content/R4EAnnotationModel.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/content/R4EAnnotationModel.java
index 2162eca4..42d61e2d 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/content/R4EAnnotationModel.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/content/R4EAnnotationModel.java
@@ -139,7 +139,9 @@ public class R4EAnnotationModel implements IReviewAnnotationModel {
*/
public void setFile(Object aFileContext) {
fFileContext = (R4EUIFileContext) aFileContext;
- fFileContext.registerAnnotationModel(this);
+ if (null != aFileContext) {
+ fFileContext.registerAnnotationModel(this);
+ }
}
/**
@@ -190,6 +192,7 @@ public class R4EAnnotationModel implements IReviewAnnotationModel {
*/
public void connect(IDocument aDocument) {
fDocument = aDocument;
+
if (fDocument.getLength() > 0) {
for (IReviewAnnotation annotation : fAnnotationsMap.values()) {
try {
@@ -212,11 +215,15 @@ public class R4EAnnotationModel implements IReviewAnnotationModel {
* @see org.eclipse.jface.text.source.IAnnotationModel#disconnect(IDocument)
*/
public void disconnect(IDocument aDocument) {
+ /* TODO: This is commented out to prevent losing the annotation model when it is connected to multiple
+ * viewers. This should be revisited as it may cause listener leaks.
for (IReviewAnnotation annotation : fAnnotationsMap.values()) {
aDocument.removePosition(annotation.getPosition());
}
aDocument.removeDocumentListener(fDocumentListener);
fDocument = null;
+ refreshAnnotations();
+ */
}
/**
@@ -497,4 +504,14 @@ public class R4EAnnotationModel implements IReviewAnnotationModel {
}
return null;
}
+
+ /**
+ * Method getFile.
+ *
+ * @return Object
+ * @see org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationModel#getFile()
+ */
+ public Object getFile() {
+ return fFileContext;
+ }
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/control/R4ECompareAnnotationSupport.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/control/R4ECompareAnnotationSupport.java
index ed5a1474..f71665df 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/control/R4ECompareAnnotationSupport.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/annotation/control/R4ECompareAnnotationSupport.java
@@ -38,11 +38,13 @@ public class R4ECompareAnnotationSupport extends ReviewCompareAnnotationSupport
*
* @param aViewer
* Viewer
- * @param aFileContext
- * Object
+ * @param aTargetFile
+ * R4EUIFileContext
+ * @param aBaseFile
+ * R4EUIFileContext
*/
- public R4ECompareAnnotationSupport(Viewer aViewer, Object aFileContext) {
- super(aViewer, aFileContext);
+ public R4ECompareAnnotationSupport(Viewer aViewer, R4EUIFileContext aTargetFile, R4EUIFileContext aBaseFile) {
+ super(aViewer, aTargetFile, aBaseFile);
}
/**
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/ModelContributionItems.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/ModelContributionItems.java
index 6077577c..76efd35b 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/ModelContributionItems.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/ModelContributionItems.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.R4EUIConstants;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
import org.eclipse.ui.ISharedImages;
@@ -111,6 +112,25 @@ public class ModelContributionItems extends CompoundContributionItem {
list.add(new CommandContributionItem(params));
}
+ if (R4EUIModelController.getNavigatorView().getTreeViewer().getSelection() instanceof IStructuredSelection) {
+ Object[] selections = ((IStructuredSelection) R4EUIModelController.getNavigatorView()
+ .getTreeViewer()
+ .getSelection()).toArray();
+ if (selections.length == 2 && selections[0] instanceof R4EUIReviewItem
+ && selections[1] instanceof R4EUIReviewItem && ((R4EUIReviewItem) selections[0]).isEnabled()
+ && ((R4EUIReviewItem) selections[1]).isEnabled()) {
+ params = new CommandContributionItemParameter(R4EUIModelController.getNavigatorView().getSite(),
+ R4EUIConstants.COMPARE_ITEMS_COMMAND, R4EUIConstants.COMPARE_ITEMS_COMMAND, null,
+ ImageDescriptor.createFromURL(R4EUIPlugin.getDefault()
+ .getBundle()
+ .getEntry(R4EUIConstants.COMPARE_ITEMS_ICON_FILE)), null, null,
+ R4EUIConstants.COMPARE_ITEMS_COMMAND_NAME, R4EUIConstants.COMPARE_ITEMS_COMMAND_MNEMONIC,
+ R4EUIConstants.COMPARE_ITEMS_COMMAND_TOOLTIP, CommandContributionItem.STYLE_PUSH, null,
+ true);
+ list.add(new CommandContributionItem(params));
+ }
+ }
+
if (aElement.isCopyElementCmd()) {
params = new CommandContributionItemParameter(R4EUIModelController.getNavigatorView().getSite(),
R4EUIConstants.COPY_ELEMENT_COMMAND, R4EUIConstants.COPY_ELEMENT_COMMAND, null,
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/CompareItemsHandler.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/CompareItemsHandler.java
new file mode 100644
index 00000000..f43ad663
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/CompareItemsHandler.java
@@ -0,0 +1,108 @@
+// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Description:
+ *
+ * This class implements the context-sensitive command used
+ * compare two selected Review Items from the Review Navigator
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+package org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers;
+
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.EditorProxy;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
+import org.eclipse.ui.progress.UIJob;
+
+/**
+ * @author Sebastien Dubois
+ * @version $Revision: 1.0 $
+ */
+public class CompareItemsHandler extends AbstractHandler {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field COMMAND_MESSAGE. (value is ""Comparing Review Items..."")
+ */
+ private static final String COMMAND_MESSAGE = "Comparing Review Items...";
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method execute.
+ *
+ * @param aEvent
+ * ExecutionEvent
+ * @return Object
+ * @see org.eclipse.core.commands.IHandler#execute(ExecutionEvent)
+ */
+ public Object execute(final ExecutionEvent aEvent) {
+
+ final List<IR4EUIModelElement> selectedElements = UIUtils.getCommandUIElements();
+
+ final UIJob job = new UIJob(COMMAND_MESSAGE) {
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ monitor.beginTask(COMMAND_MESSAGE, 1);
+
+ if (!selectedElements.isEmpty()) {
+ if (selectedElements.size() == 2 && selectedElements.get(0) instanceof R4EUIReviewItem
+ && selectedElements.get(1) instanceof R4EUIReviewItem) {
+ R4EUIReviewItem item1 = (R4EUIReviewItem) selectedElements.get(0);
+ R4EUIReviewItem item2 = (R4EUIReviewItem) selectedElements.get(1);
+ //If there's no date submitted, it is a resource review item, use current date
+ Date item1SubmitDate = item1.getItem().getSubmitted();
+ Date item2SubmitDate = item2.getItem().getSubmitted();
+ if (null == item1SubmitDate) {
+ item1SubmitDate = new Date();
+ }
+ if (null == item2SubmitDate) {
+ item2SubmitDate = new Date();
+ }
+
+ //The most recently submitted Review Item is always the target
+ if (item1SubmitDate.after(item2SubmitDate)) {
+ EditorProxy.openReviewItemCompareEditor(R4EUIModelController.getNavigatorView()
+ .getSite()
+ .getPage(), item1, item2);
+ } else {
+ EditorProxy.openReviewItemCompareEditor(R4EUIModelController.getNavigatorView()
+ .getSite()
+ .getPage(), item2, item1);
+ }
+ }
+ }
+ monitor.worked(1);
+ monitor.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ return null;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/FindReviewItemsHandler.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/FindReviewItemsHandler.java
index fb77713e..0b5af4b3 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/FindReviewItemsHandler.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/handlers/FindReviewItemsHandler.java
@@ -19,6 +19,7 @@
package org.eclipse.mylyn.reviews.r4e.ui.internal.commands.handlers;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -36,6 +37,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
@@ -65,7 +67,7 @@ import org.eclipse.mylyn.reviews.r4e.core.rfs.spi.ReviewsFileStorageException;
import org.eclipse.mylyn.reviews.r4e.core.utils.Tracer;
import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
import org.eclipse.mylyn.reviews.r4e.ui.internal.dialogs.R4EUIDialogFactory;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EDeltaCompareEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIPosition;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIDeltaContainer;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
@@ -703,29 +705,35 @@ public class FindReviewItemsHandler extends AbstractHandler {
private void updateFilesWithDeltas(final TempFileContext aFile) throws CoreException {
//Find all differences between Base and Target files
- final R4ECompareEditorInput input = CommandUtils.createCompareEditorInput(aFile.getBase(), aFile.getTarget());
- input.prepareCompareInputNoEditor();
+ try {
+ final R4EDeltaCompareEditorInput input = new R4EDeltaCompareEditorInput(aFile.getTarget(), aFile.getBase());
+ input.prepareCompareInput(new NullProgressMonitor());
- final DiffUtils diffUtils = new DiffUtils();
- final List<Diff> diffs;
+ final DiffUtils diffUtils = new DiffUtils();
+ final List<Diff> diffs;
- fLock.lock();
- try {
- diffs = diffUtils.doDiff(false, true, input);
- } finally {
- fLock.unlock();
- }
+ fLock.lock();
+ try {
+ diffs = diffUtils.doDiff(false, true, input);
+ } finally {
+ fLock.unlock();
+ }
- //Add Deltas from the list of differences
- for (Diff diff : diffs) {
- IR4EUIPosition position = CommandUtils.getPosition(diff.getPosition(R4EUIConstants.LEFT_CONTRIBUTOR)
- .getOffset(), diff.getPosition(R4EUIConstants.LEFT_CONTRIBUTOR).getLength(),
- diff.getDocument(R4EUIConstants.LEFT_CONTRIBUTOR));
+ //Add Deltas from the list of differences
+ for (Diff diff : diffs) {
+ IR4EUIPosition position = CommandUtils.getPosition(diff.getPosition(R4EUIConstants.LEFT_CONTRIBUTOR)
+ .getOffset(), diff.getPosition(R4EUIConstants.LEFT_CONTRIBUTOR).getLength(),
+ diff.getDocument(R4EUIConstants.LEFT_CONTRIBUTOR));
- if ((null == position) || (RangeDifference.NOCHANGE == diff.getKind())) {
- continue; //Cannot resolve position for this delta or no change
+ if ((null == position) || (RangeDifference.NOCHANGE == diff.getKind())) {
+ continue; //Cannot resolve position for this delta or no change
+ }
+ aFile.getPositions().add(position);
}
- aFile.getPositions().add(position);
+ } catch (InvocationTargetException e) {
+ throw new CoreException(new Status(IStatus.WARNING, R4EUIPlugin.PLUGIN_ID, IStatus.OK, e.toString(), e));
+ } catch (InterruptedException e) {
+ throw new CoreException(new Status(IStatus.WARNING, R4EUIPlugin.PLUGIN_ID, IStatus.OK, e.toString(), e));
}
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/CloneAnomalyPropertyTester.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/CloneAnomalyPropertyTester.java
index e497e726..59b9751c 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/CloneAnomalyPropertyTester.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/CloneAnomalyPropertyTester.java
@@ -35,6 +35,7 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileRevisionEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewBasic;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -74,8 +75,7 @@ public class CloneAnomalyPropertyTester extends PropertyTester {
}
//Command is disabled if the active review is completed
- if (((R4EReviewState) activeReview.getReview().getState()).getState().equals(
- R4EReviewPhase.COMPLETED)) {
+ if (((R4EReviewState) activeReview.getReview().getState()).getState().equals(R4EReviewPhase.COMPLETED)) {
return false;
}
@@ -144,7 +144,13 @@ public class CloneAnomalyPropertyTester extends PropertyTester {
}
//Compare editor
} else if (editorInput instanceof R4ECompareEditorInput) {
- final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getLeftElement();
+
+ if (!UIUtils.isLeftCompareEditorSelected(page.getActiveEditor())) {
+ return false;
+ }
+
+ final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getCurrentDiffNode()
+ .getTargetTypedElement();
if (null == targetElement) {
return false;
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewAnomalyPropertyTester.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewAnomalyPropertyTester.java
index 6b73df56..c468adba 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewAnomalyPropertyTester.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewAnomalyPropertyTester.java
@@ -33,6 +33,7 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileRevisionEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewBasic;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -72,8 +73,7 @@ public class NewAnomalyPropertyTester extends PropertyTester {
}
//Command is disabled if the active review is completed
- if (((R4EReviewState) activeReview.getReview().getState()).getState().equals(
- R4EReviewPhase.COMPLETED)) {
+ if (((R4EReviewState) activeReview.getReview().getState()).getState().equals(R4EReviewPhase.COMPLETED)) {
return false;
}
@@ -125,7 +125,13 @@ public class NewAnomalyPropertyTester extends PropertyTester {
}
//Compare editor
} else if (editorInput instanceof R4ECompareEditorInput) {
- final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getLeftElement();
+
+ if (!UIUtils.isLeftCompareEditorSelected(page.getActiveEditor())) {
+ return false;
+ }
+
+ final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getCurrentDiffNode()
+ .getTargetTypedElement();
if (null == targetElement) {
return false;
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewReviewItemPropertyTester.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewReviewItemPropertyTester.java
index 246686e9..a1b49ea3 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewReviewItemPropertyTester.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/testers/NewReviewItemPropertyTester.java
@@ -35,6 +35,7 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileRevisionTypedEle
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileTypedElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewBasic;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -128,16 +129,19 @@ public class NewReviewItemPropertyTester extends PropertyTester {
}
//Compare editor
} else if (editorInput instanceof R4ECompareEditorInput) {
- final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getLeftElement();
+
+ if (!UIUtils.isLeftCompareEditorSelected(page.getActiveEditor())) {
+ return false;
+ }
+ final ITypedElement targetElement = ((R4ECompareEditorInput) editorInput).getCurrentDiffNode()
+ .getTargetTypedElement();
if (null == targetElement) {
return false;
}
- //R4EItem parentItem = null;
- final ITypedElement element = ((R4ECompareEditorInput) editorInput).getLeftElement();
-
//NOTE: For now we only support adding new review items from an R4E Compare Editor.
// Eventually this should be enhanced to include any compare editor input
- if (!(element instanceof R4EFileRevisionTypedElement) && !(element instanceof R4EFileTypedElement)) {
+ if (!(targetElement instanceof R4EFileRevisionTypedElement)
+ && !(targetElement instanceof R4EFileTypedElement)) {
return false;
}
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/EditorProxy.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/EditorProxy.java
index aa55614a..3ef90d14 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/EditorProxy.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/EditorProxy.java
@@ -23,7 +23,6 @@ import java.io.InputStream;
import java.util.Iterator;
import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -36,7 +35,6 @@ import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileContext;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
@@ -45,6 +43,7 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIAnomalyBasic;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIComment;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIContent;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUITextPosition;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.CommandUtils;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
@@ -70,11 +69,6 @@ public class EditorProxy {
// ------------------------------------------------------------------------
/**
- * Field R4E_COMPARE_EDITOR_TITLE. (value is ""R4E Compare"")
- */
- private static final String R4E_COMPARE_EDITOR_TITLE = "R4E Compare";
-
- /**
* Field DEFAULT_EDITOR_NAME. (value is ""org.eclipse.ui.DefaultTextEditor"")
*/
private static final String DEFAULT_EDITOR_NAME = "org.eclipse.ui.DefaultTextEditor";
@@ -106,8 +100,6 @@ public class EditorProxy {
IR4EUIPosition position = null;
R4EUIFileContext context = null;
- R4EFileVersion baseFileVersion = null;
- R4EFileVersion targetFileVersion = null;
for (final Iterator<?> iterator = ((IStructuredSelection) aSelection).iterator(); iterator.hasNext();) {
@@ -136,102 +128,73 @@ public class EditorProxy {
}
context = ((R4EUIFileContext) element);
- //Get files from FileContext
- baseFileVersion = context.getBaseFileVersion();
- targetFileVersion = context.getTargetFileVersion();
-
//If the files are the same (or do not exist), open the single editor
- if (null == baseFileVersion || null == targetFileVersion
- || baseFileVersion.getVersionID().equals(targetFileVersion.getVersionID())) {
+ if (null == context.getBaseFileVersion()
+ || null == context.getTargetFileVersion()
+ || context.getBaseFileVersion()
+ .getVersionID()
+ .equals(context.getTargetFileVersion().getVersionID())) {
aForceSingleEditor = true;
}
//Check if the base file is set, if so, we will use the compare editor. Otherwise we use the normal editor of the appropriate type
if (context.isFileVersionsComparable() && !aForceSingleEditor) {
- editor = openCompareEditor(aPage, baseFileVersion, targetFileVersion);
+ editor = openCompareEditor(aPage, context);
} else {
- if (null != targetFileVersion) {
- editor = openSingleEditor(aPage, context, targetFileVersion, position);
- } else if (null != baseFileVersion) {
- //File was removed, open the base then
- editor = openSingleEditor(aPage, context, baseFileVersion, position);
- } else {
- //Show the error, the file was in another project and was not
- //found when creating the commit review item
- String error = "Base and target file version not found for this review item";
- R4EUIPlugin.Ftracer.traceError("Exception: " + error);
- CoreException exception = new CoreException(new Status(IStatus.ERROR, R4EUIPlugin.PLUGIN_ID, error));
- //Display the error, but do not log in the error log
- UIUtils.displayCoreErrorDialog(exception, false);
-
- }
+ editor = openSingleEditor(aPage, context, position);
}
}
return editor;
}
/**
- * Method openEditor. Open the editor
+ * Method openReviewItemCompareEditor. Open the compare editor to compare Review Items
*
* @param aPage
* IWorkbenchPage - the current workbench page
- * @param aSelection
- * ISelection - the currently selected model element
- * @param aForceSingleEditor
- * boolean - flag to force single editor
+ * @param aTargetItem
+ * R4EUIReviewItem - the currently selected target (newer) Review Item
+ * @param aBaseItem
+ * R4EUIReviewItem - the currently selected base (older) Review Item
* @throws CoreException
*/
- public static IEditorPart openSimpleEditor(IWorkbenchPage aPage, ISelection aSelection, boolean aForceSingleEditor) {
-
- IEditorPart editor = null;
-
- if (aSelection.isEmpty() || !(aSelection instanceof IStructuredSelection)) {
- return editor;
- }
-
- Object element = null;
- IR4EUIPosition position = null;
-
- for (final Iterator<?> iterator = ((IStructuredSelection) aSelection).iterator(); iterator.hasNext();) {
-
- element = iterator.next();
- if (!(element instanceof R4EFileContext)) {
- continue;
- }
-
- R4EFileContext context = (R4EFileContext) element;
-
- //Get files from FileContext
- R4EFileVersion baseFileVersion = context.getBase();
- R4EFileVersion targetFileVersion = context.getTarget();
+ public static IEditorPart openReviewItemCompareEditor(IWorkbenchPage aPage, R4EUIReviewItem aTargetItem,
+ R4EUIReviewItem aBaseItem) {
- //If the files are the same (or do not exist), open the single editor
- if (null == baseFileVersion || null == targetFileVersion
- || baseFileVersion.getVersionID().equals(targetFileVersion.getVersionID())) {
- aForceSingleEditor = true;
- }
+ //Reuse editor if it is already open on the same input
+ CompareEditorInput input = null;
+ IEditorPart editor = findReusableReviewItemCompareEditor(aPage, aTargetItem, aBaseItem);
- //Check if the base file is set, if so, we will use the compare editor. Otherwise we use the normal editor of the appropriate type
- if (!aForceSingleEditor) {
- editor = openCompareEditor(aPage, baseFileVersion, targetFileVersion);
- } else {
- if (null != targetFileVersion) {
- editor = openSingleEditor(aPage, null, targetFileVersion, position);
- } else if (null != baseFileVersion) {
- //File was removed, open the base then
- editor = openSingleEditor(aPage, null, baseFileVersion, position);
+ if (null != editor) {
+ //First try to activate current editor. If it is not possible to display the element in the editor, reuse it if possible, or worse case close and re-open it
+ aPage.activate(editor);
+ if (!UIUtils.selectElementInEditor((R4EReviewItemCompareEditorInput) editor.getEditorInput())) {
+ //Reuse editor whenever possible, otherwise close and re-open it
+ if (editor instanceof IReusableEditor) {
+ aPage.reuseEditor((IReusableEditor) editor, new R4EReviewItemCompareEditorInput(aTargetItem,
+ aBaseItem));
+ //NOTE: The position is set in editor in R4ECompareEditorInput#createContents TODO
+ return editor;
} else {
- //Show the error, the file was in another project and was not
- //found when creating the commit review item
- String error = "Base and target file version not found for this review item";
- R4EUIPlugin.Ftracer.traceError("Exception: " + error);
- CoreException exception = new CoreException(new Status(IStatus.ERROR, R4EUIPlugin.PLUGIN_ID, error));
- //Display the error, but do not log in the error log
- UIUtils.displayCoreErrorDialog(exception, false);
-
+ aPage.closeEditor(editor, true); //Close current editor
}
+ } else {
+ return editor;
}
}
+
+ input = new R4EReviewItemCompareEditorInput(aTargetItem, aBaseItem);
+
+ R4EUIPlugin.Ftracer.traceInfo("Open compare editor on Review Items "
+ + ((null != aTargetItem) ? aTargetItem.getItem().getId() : "") + " (Target) and "
+ + ((null != aBaseItem) ? aBaseItem.getItem().getId() : "") + " (Base)");
+ try {
+ editor = aPage.openEditor(input, "org.eclipse.compare.CompareEditor", OpenStrategy.activateOnOpen());
+ } catch (PartInitException e) {
+ R4EUIPlugin.Ftracer.traceError("Exception: " + e.toString() + " (" + e.getMessage() + ")");
+ R4EUIPlugin.getDefault().logError("Exception: " + e.toString(), e);
+ }
+ //NOTE: The position is set in editor in R4ECompareEditorInput#createContents TODO
return editor;
}
@@ -242,25 +205,40 @@ public class EditorProxy {
* IWorkbenchPage - the current workbench page
* @param aContext
* R4EUIFileContext - the file context
- * @param aFileVersion
- * R4EFileVersion - the file version
* @param aPosition
* IR4EUIPosition - the position to go to in the file
* @return IEditorPart
*/
private static IEditorPart openSingleEditor(IWorkbenchPage aPage, R4EUIFileContext aContext,
- R4EFileVersion aFileVersion, IR4EUIPosition aPosition) {
+ IR4EUIPosition aPosition) {
+ R4EFileVersion version;
IEditorPart editor = null;
+ if (null != aContext.getTargetFileVersion()) {
+ version = aContext.getTargetFileVersion();
+ } else if (null != aContext.getBaseFileVersion()) {
+ //File was removed, open the base then
+ version = aContext.getTargetFileVersion();
+ } else {
+ //Show the error, the file was in another project and was not
+ //found when creating the commit review item
+ String error = "Base and target file version not found for this review item";
+ R4EUIPlugin.Ftracer.traceError("Exception: " + error);
+ CoreException exception = new CoreException(new Status(IStatus.ERROR, R4EUIPlugin.PLUGIN_ID, error));
+ //Display the error, but do not log in the error log
+ UIUtils.displayCoreErrorDialog(exception, false);
+ return editor;
+ }
+
try {
IStorageEditorInput editorInput = null;
//NOTE: We use the workspace file as input if it is in sync with the file to review,
// otherwise we use the file to review that is included in the review repository
- if (CommandUtils.useWorkspaceResource(aFileVersion)) {
- editorInput = new R4EFileEditorInput(aFileVersion);
+ if (CommandUtils.useWorkspaceResource(version)) {
+ editorInput = new R4EFileEditorInput(version);
} else {
- editorInput = new R4EFileRevisionEditorInput(aFileVersion);
+ editorInput = new R4EFileRevisionEditorInput(version);
}
InputStream contents = null;
IStorage storage = editorInput.getStorage();
@@ -294,27 +272,24 @@ public class EditorProxy {
*
* @param aPage
* IWorkbenchPage - the current workbench page
- * @param aBaseFileVersion
- * R4EFileVersion - the base (or reference) file version
- * @param aTargetFileVersion
- * R4EFileVersion - the target (or current) file version
+ * @param aContext
+ * R4EUIFileContext - the file Context (base and target) to open
* @return IEditorPart
*/
- private static IEditorPart openCompareEditor(IWorkbenchPage aPage, R4EFileVersion aBaseFileVersion,
- R4EFileVersion aTargetFileVersion) {
+ private static IEditorPart openCompareEditor(IWorkbenchPage aPage, R4EUIFileContext aContext) {
//Reuse editor if it is already open on the same input
CompareEditorInput input = null;
- IEditorPart editor = findReusableCompareEditor(aPage, aBaseFileVersion, aTargetFileVersion);
+ IEditorPart editor = findReusableFileContextCompareEditor(aPage, aContext.getTargetFileVersion(),
+ aContext.getBaseFileVersion());
if (null != editor) {
//First try to activate current editor. If it is not possible to display the element in the editor, reuse it if possible, or worse case close and re-open it
aPage.activate(editor);
- if (!UIUtils.selectElementInEditor((R4ECompareEditorInput) editor.getEditorInput())) {
+ if (!UIUtils.selectElementInEditor((R4EFileContextCompareEditorInput) editor.getEditorInput())) {
//Reuse editor whenever possible, otherwise close and re-open it
if (editor instanceof IReusableEditor) {
- aPage.reuseEditor((IReusableEditor) editor,
- CommandUtils.createCompareEditorInput(aBaseFileVersion, aTargetFileVersion));
+ aPage.reuseEditor((IReusableEditor) editor, new R4EFileContextCompareEditorInput(aContext));
//NOTE: The position is set in editor in R4ECompareEditorInput#createContents
return editor;
} else {
@@ -324,12 +299,12 @@ public class EditorProxy {
return editor;
}
}
- input = CommandUtils.createCompareEditorInput(aBaseFileVersion, aTargetFileVersion);
- input.setTitle(R4E_COMPARE_EDITOR_TITLE); // Adjust the compare title
+ input = new R4EFileContextCompareEditorInput(aContext);
R4EUIPlugin.Ftracer.traceInfo("Open compare editor on files "
- + ((null != aTargetFileVersion) ? aTargetFileVersion.getName() : "") + " (Target) and "
- + ((null != aBaseFileVersion) ? aBaseFileVersion.getName() : "") + " (Base)");
+ + ((null != aContext.getTargetFileVersion()) ? aContext.getTargetFileVersion().getName() : "")
+ + " (Target) and "
+ + ((null != aContext.getBaseFileVersion()) ? aContext.getBaseFileVersion().getName() : "") + " (Base)");
try {
editor = aPage.openEditor(input, "org.eclipse.compare.CompareEditor", OpenStrategy.activateOnOpen());
} catch (PartInitException e) {
@@ -341,54 +316,38 @@ public class EditorProxy {
}
/**
- * Method findReusableCompareEditor. Find the appropriate compare editor based on the file types
+ * Method findReusableCompareEditor. Find the appropriate file context compare editor based on the file types
*
* @param aPage
* IWorkbenchPage - the current workbench page
- * @param aBaseFile
- * R4EFileVersion - the base (or reference) file version
* @param aTargetFile
* R4EFileVersion - the target file version
+ * @param aBaseFile
+ * R4EFileVersion - the base (or reference) file version
* @return IEditorPart - the editor to use
*/
- public static IEditorPart findReusableCompareEditor(IWorkbenchPage aPage, R4EFileVersion aBaseFile,
- R4EFileVersion aTargetFile) {
+ public static IEditorPart findReusableFileContextCompareEditor(IWorkbenchPage aPage, R4EFileVersion aTargetFile,
+ R4EFileVersion aBaseFile) {
final IEditorReference[] editorRefs = aPage.getEditorReferences();
IEditorPart part = null;
- R4ECompareEditorInput input = null;
- ITypedElement left = null;
- ITypedElement right = null;
+ R4EFileContextCompareEditorInput input = null;
// first loop looking for an editor with the same input
for (IEditorReference editorRef : editorRefs) {
part = editorRef.getEditor(false);
if (null != part && part instanceof IReusableEditor) {
// check if the editor input type complies with the types given by the caller
- if (R4ECompareEditorInput.class.isInstance(part.getEditorInput())) {
+ if (R4EFileContextCompareEditorInput.class.isInstance(part.getEditorInput())) {
//Now check if the input files are the same as with the found editor
- input = (R4ECompareEditorInput) part.getEditorInput();
- left = input.getLeftElement();
- right = input.getRightElement();
+ input = (R4EFileContextCompareEditorInput) part.getEditorInput();
+ R4EFileVersion leftVersion = input.getCurrentDiffNode().getTargetVersion();
+ R4EFileVersion rightVersion = input.getCurrentDiffNode().getBaseVersion();
//Case: No input in editor, that should never happen but guard here just in case
- if (null == left && null == right) {
+ if (null == leftVersion && null == rightVersion) {
return null;
}
- //Get the file versions
- R4EFileVersion leftVersion = null;
- R4EFileVersion rightVersion = null;
- if (left instanceof R4EFileRevisionTypedElement) {
- leftVersion = ((R4EFileRevisionTypedElement) left).getFileVersion();
- } else if (left instanceof R4EFileTypedElement) {
- leftVersion = ((R4EFileTypedElement) left).getFileVersion();
- }
- if (right instanceof R4EFileRevisionTypedElement) {
- rightVersion = ((R4EFileRevisionTypedElement) right).getFileVersion();
- } else if (right instanceof R4EFileTypedElement) {
- rightVersion = ((R4EFileTypedElement) right).getFileVersion();
- }
-
//Case: No target file and base is the same
if (null == leftVersion && null == aTargetFile && null != rightVersion && null != aBaseFile
&& rightVersion.equals(aBaseFile)) {
@@ -416,6 +375,73 @@ public class EditorProxy {
}
/**
+ * Method findReusableCompareEditor. Find the appropriate Review Item compare editor based on the file types
+ *
+ * @param aPage
+ * IWorkbenchPage - the current workbench page
+ * @param aTargetItem
+ * R4EUIReviewItem - the target review item
+ * @param aBaseItem
+ * R4EUIReviewItem - the base (or reference) review item
+ * @return IEditorPart - the editor to use
+ */
+ public static IEditorPart findReusableReviewItemCompareEditor(IWorkbenchPage aPage, R4EUIReviewItem aTargetItem,
+ R4EUIReviewItem aBaseItem) {
+
+ final IEditorReference[] editorRefs = aPage.getEditorReferences();
+ IEditorPart part = null;
+ R4EReviewItemCompareEditorInput input = null;
+ // first loop looking for an editor with the same input
+ for (IEditorReference editorRef : editorRefs) {
+ part = editorRef.getEditor(false);
+ if (null != part && part instanceof IReusableEditor) {
+ // check if the editor input type complies with the types given by the caller
+ if (R4EReviewItemCompareEditorInput.class.isInstance(part.getEditorInput())) {
+ //Now check if the input files are the same as with the found editor
+ input = (R4EReviewItemCompareEditorInput) part.getEditorInput();
+ if ((aBaseItem == null || aBaseItem.equals(input.getBaseReviewItem()))
+ && aTargetItem.equals(input.getTargetReviewItem())) {
+ return part;
+ }
+ }
+ }
+ }
+ // no re-usable editor found
+ return null;
+ }
+
+ /**
+ * Method getReviewItemCompareEditorPart. Find the appropriate editor for this review item
+ *
+ * @param aPage
+ * IWorkbenchPage - the current workbench page
+ * @param aItem
+ * R4EUIReviewItem - the target review item
+ * @return IEditorPart - the editor to use
+ */
+ public static IEditorPart getReviewItemCompareEditorPart(IWorkbenchPage aPage, R4EUIReviewItem aItem) {
+ final IEditorReference[] editorRefs = aPage.getEditorReferences();
+ IEditorPart part = null;
+ R4EReviewItemCompareEditorInput input = null;
+ // first loop looking for an editor with the same input
+ for (IEditorReference editorRef : editorRefs) {
+ part = editorRef.getEditor(false);
+ if (null != part && part instanceof IReusableEditor) {
+ // check if the editor input type complies with the types given by the caller
+ if (R4EReviewItemCompareEditorInput.class.isInstance(part.getEditorInput())) {
+ //Now check if the input review item is the same as with the found editor
+ input = (R4EReviewItemCompareEditorInput) part.getEditorInput();
+ if (aItem.equals(input.getTargetReviewItem()) || aItem.equals(input.getBaseReviewItem())) {
+ return part;
+ }
+ }
+ }
+ }
+ // no re-usable editor found
+ return null;
+ }
+
+ /**
* Method findReusableEditor. Find the appropriate editor based on the file types
*
* @param aPage
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4ECompareEditorInput.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4ECompareEditorInput.java
index e648f963..b8f2cc07 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4ECompareEditorInput.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4ECompareEditorInput.java
@@ -10,7 +10,7 @@
* Description:
*
* This class is used as the input class that feeds the eclipse compare
- * editor
+ * editor for R4E element. It needs to be subclassed for the each compare operation type
*
* Contributors:
* Sebastien Dubois - Created for Mylyn Review R4E project
@@ -24,33 +24,17 @@ import java.text.MessageFormat;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareUI;
-import org.eclipse.compare.CompareViewerPane;
import org.eclipse.compare.ICompareNavigator;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
import org.eclipse.compare.internal.CompareEditorInputNavigator;
-import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationModel;
-import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport;
-import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.commands.R4EAnnotationContributionItems;
import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.content.R4EAnnotation;
import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.content.R4EAnnotationModel;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIPosition;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIAnomalyBasic;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIContent;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -61,36 +45,16 @@ import org.eclipse.ui.texteditor.ITextEditor;
* @author Sebastien Dubois
* @version $Revision: 1.0 $
*/
-public class R4ECompareEditorInput extends SaveableCompareEditorInput {
+public abstract class R4ECompareEditorInput extends SaveableCompareEditorInput {
// ------------------------------------------------------------------------
// Member variables
// ------------------------------------------------------------------------
/**
- * Field fConfig - the compare configuration
+ * Field fCurrentDiffNode
*/
- private final CompareConfiguration fConfig;
-
- /**
- * Field fAncestor - the optional element that will appear on the top of the compare editor
- */
- private final ITypedElement fAncestor;
-
- /**
- * Field fLeft - the element that will appear on the left side of the compare editor
- */
- private final ITypedElement fLeft;
-
- /**
- * Field fRight - the element that will appear on the right side of the compare editor
- */
- private final ITypedElement fRight;
-
- /**
- * Field fAnnotationSupport.
- */
- private IReviewAnnotationSupport fAnnotationSupport = null;
+ protected R4EDiffNode fCurrentDiffNode;
// ------------------------------------------------------------------------
// Constructors
@@ -98,23 +62,9 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
/**
* Constructor for R4ECompareEditorInput.
- *
- * @param aConfig
- * CompareConfiguration
- * @param aAncestor
- * ITypedElement
- * @param aLeft
- * ITypedElement
- * @param aRight
- * ITypedElement
*/
- public R4ECompareEditorInput(CompareConfiguration aConfig, ITypedElement aAncestor, ITypedElement aLeft,
- ITypedElement aRight) {
- super(aConfig, null);
- fConfig = aConfig;
- fAncestor = aAncestor;
- fLeft = aLeft;
- fRight = aRight;
+ public R4ECompareEditorInput() {
+ super(new CompareConfiguration(), null);
}
// ------------------------------------------------------------------------
@@ -122,44 +72,31 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
// ------------------------------------------------------------------------
/**
- * Method getAncestorElement.
- *
- * @return ITypedElement
+ * Method initConfiguration.
*/
- public ITypedElement getAncestorElement() {
- return fAncestor;
+ protected void initConfiguration() {
+ // Set the label values for the compare editor
+ getCompareConfiguration().setLeftEditable(false);
+ getCompareConfiguration().setRightEditable(false);
+ getCompareConfiguration().setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(true));
}
/**
- * Method getLeftElement.
+ * Method getAncestorElement.
*
* @return ITypedElement
*/
- public ITypedElement getLeftElement() {
- return fLeft;
+ public ITypedElement getAncestorElement() {
+ return null; //Not supported for now
}
/**
- * Method getRightElement.
+ * Method getCurrentDiffNode.
*
- * @return ITypedElement
+ * @return R4EDiffNode
*/
- public ITypedElement getRightElement() {
- return fRight;
- }
-
- /**
- * Method prepareCompareInputNoEditor.
- */
- public void prepareCompareInputNoEditor() {
- //Build the diff node to compare the files
- final Differencer differencer = new Differencer();
- //Bug 392349
- if (null == fLeft && null == fRight) {
- R4EUIPlugin.Ftracer.traceWarning("Nothing to compare, both sides are NULL");
- } else {
- differencer.findDifferences(false, null, null, fAncestor, fLeft, fRight);
- }
+ public R4EDiffNode getCurrentDiffNode() {
+ return fCurrentDiffNode;
}
/**
@@ -170,57 +107,10 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
*/
@Override
public String getToolTipText() {
- if ((null != fLeft) && (null != fRight)) {
- String format = null;
-
- // Set the label values for the compare editor
- StringBuilder leftLabel = null;
- if (null != fLeft) {
- leftLabel = new StringBuilder("Target: " + fLeft.getName());
- if (fLeft instanceof R4EFileRevisionTypedElement) {
- leftLabel.append("_" + ((R4EFileRevisionTypedElement) fLeft).getFileVersion().getVersionID());
- }
- fConfig.setLeftLabel(leftLabel.toString());
- }
- StringBuilder rightLabel = null;
- if (null != fRight) {
- rightLabel = new StringBuilder("Base: " + fRight.getName());
- if (fRight instanceof R4EFileRevisionTypedElement) {
- rightLabel.append("_" + ((R4EFileRevisionTypedElement) fRight).getFileVersion().getVersionID());
- }
- fConfig.setRightLabel(rightLabel.toString());
- }
-
- if (null != fAncestor) {
- format = CompareUI.getResourceBundle().getString("ResourceCompare.threeWay.tooltip"); //$NON-NLS-1$
- final String ancestorLabel = "";
- return MessageFormat.format(format, new Object[] { ancestorLabel, leftLabel, rightLabel });
- }
- format = CompareUI.getResourceBundle().getString("ResourceCompare.twoWay.tooltip"); //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { leftLabel, rightLabel });
- }
- // fall back
- return super.getToolTipText();
- }
-
- /**
- * Method getAdapter.
- *
- * @param aAdapter
- * Class
- * @return Object
- * @see org.eclipse.compare.CompareEditorInput#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(@SuppressWarnings("rawtypes")
- Class aAdapter) {
- if (IFile.class.equals(aAdapter)) {
- if (null != getWorkspaceElement()) {
- return getWorkspaceElement().getResource();
- }
- return null;
- }
- return super.getAdapter(aAdapter);
+ String targetTooltip = fCurrentDiffNode.getTargetLabel();
+ String baseTooltip = fCurrentDiffNode.getBaseLabel();
+ String format = CompareUI.getResourceBundle().getString("ResourceCompare.twoWay.tooltip"); //$NON-NLS-1$
+ return MessageFormat.format(format, new Object[] { targetTooltip, baseTooltip });
}
/**
@@ -232,18 +122,6 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
}
/**
- * Method getWorkspaceElement.
- *
- * @return R4EFileTypedElement
- */
- private R4EFileTypedElement getWorkspaceElement() {
- if (fLeft instanceof R4EFileTypedElement) {
- return (R4EFileTypedElement) fLeft;
- }
- return null;
- }
-
- /**
* Method prepareCompareInput.
*
* @param aMonitor
@@ -251,45 +129,14 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
* @return ICompareInput
* @throws InvocationTargetException
* @throws InterruptedException
- * @see org.eclipse.compare.CompareEditorInput#prepareCompareInput(IProgressMonitor)
+ * @see org.eclipse.team.ui.synchronize.SaveableCompareEditorInput#prepareCompareInput(IProgressMonitor)
*/
@Override
protected ICompareInput prepareCompareInput(IProgressMonitor aMonitor) {
-
if (null != aMonitor) {
- aMonitor.beginTask("R4E Compare", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- }
-
- // Set the label values for the compare editor
- initLabels();
-
- return new R4EFileContextNode(fLeft, fRight);
- }
-
- /**
- * Method initLabels.
- */
- private void initLabels() {
- // Set the label values for the compare editor
- if (null != fLeft) {
- final StringBuilder leftLabel = new StringBuilder("Target: " + fLeft.getName());
- if (fLeft instanceof R4EFileRevisionTypedElement) {
- leftLabel.append(" " + ((R4EFileRevisionTypedElement) fLeft).getFileVersion().getVersionID());
- }
- fConfig.setLeftLabel(leftLabel.toString());
- }
- if (null != fRight) {
- final StringBuilder rightLabel = new StringBuilder("Base: " + fRight.getName());
- if (fRight instanceof R4EFileRevisionTypedElement) {
- rightLabel.append("_" + ((R4EFileRevisionTypedElement) fRight).getFileVersion().getVersionID());
- }
- fConfig.setRightLabel(rightLabel.toString());
- }
-
- // If the ancestor is not null, just put the file name as the workspace label
- if (null != fAncestor) {
- fConfig.setAncestorLabel(fAncestor.getName());
+ aMonitor.beginTask("R4E File Context Compare", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
}
+ return fCurrentDiffNode;
}
/**
@@ -307,49 +154,15 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
//Go to the correct element in the compare editor
UIUtils.selectElementInEditor(this);
- //TODO: This is needed to show annotation highlighting whne opening the compare editor.
- // It should not be needed so this could be investigated in the future.
- if (fAnnotationSupport != null) {
- fAnnotationSupport.getTargetAnnotationModel().refreshAnnotations();
+ //TODO: This is needed to show annotation highlighting when opening the compare editor.
+ // It should not be needed so this should be investigated in the future.
+ if (null != fCurrentDiffNode) {
+ fCurrentDiffNode.refreshAnnotations();
}
-
return control;
}
/**
- * Method findContentViewer.
- *
- * @param aOldViewer
- * Viewer
- * @param aInput
- * ICompareInput
- * @param aParent
- * Composite
- * @return Viewer
- */
- @Override
- public Viewer findContentViewer(Viewer aOldViewer, ICompareInput aInput, Composite aParent) {
- final Viewer contentViewer = super.findContentViewer(aOldViewer, aInput, aParent);
- //TODO lmcdubo: ideally we would like to get the file context from the FileContextNode element. Need refactoring
- if (aInput instanceof R4EFileContextNode) {
- final ISelection selection = R4EUIModelController.getNavigatorView().getTreeViewer().getSelection();
- if (selection instanceof IStructuredSelection) {
- final Object element = ((IStructuredSelection) selection).getFirstElement();
- if (element instanceof R4EUIFileContext) {
- fAnnotationSupport = UIUtils.getCompareAnnotationSupport(contentViewer, element);
- insertAnnotationNavigationCommands(CompareViewerPane.getToolBarManager(aParent), fAnnotationSupport);
- } else if (element instanceof R4EUIContent || element instanceof R4EUIAnomalyBasic) {
- final IReviewAnnotationSupport support = UIUtils.getCompareAnnotationSupport(contentViewer,
- ((IR4EUIModelElement) element).getParent().getParent());
- fAnnotationSupport = UIUtils.getCompareAnnotationSupport(contentViewer, element);
- insertAnnotationNavigationCommands(CompareViewerPane.getToolBarManager(aParent), support);
- }
- }
- }
- return contentViewer;
- }
-
- /**
* Method getContentViewer.
*
* @return Viewer
@@ -368,24 +181,6 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
}
/**
- * Method insertAnnotationNavigationCommands.
- *
- * @param aManager
- * IToolBarManager
- * @param aSupport
- * IReviewAnnotationSupport
- */
- private void insertAnnotationNavigationCommands(IToolBarManager aManager, IReviewAnnotationSupport aSupport) {
- aManager.add(new Separator());
- final R4EAnnotationContributionItems r4eItemsManager = new R4EAnnotationContributionItems();
- final IContributionItem[] items = r4eItemsManager.getR4EContributionItems();
- for (IContributionItem item : items) {
- aManager.add(item);
- }
- aManager.update(true);
- }
-
- /**
* Method isAnnotationsAvailable.
*
* @param aType
@@ -393,8 +188,8 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
* @return boolean
*/
public boolean isAnnotationsAvailable(String aType) {
- if (null != fAnnotationSupport) {
- IReviewAnnotationModel model = fAnnotationSupport.getTargetAnnotationModel();
+ if (null != fCurrentDiffNode.getAnnotationSupport()) {
+ IReviewAnnotationModel model = fCurrentDiffNode.getAnnotationSupport().getAnnotationModel();
if (null != model) {
if (model.isAnnotationsAvailable(aType)) {
return true;
@@ -416,10 +211,10 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
R4EAnnotation foundAnnotation = null;
//We need to only consider the anomalies currently visible in the viewport
- if (null != fAnnotationSupport) {
- ITextEditor editor = fAnnotationSupport.getTargetEditor();
+ if (null != fCurrentDiffNode.getAnnotationSupport()) {
+ ITextEditor editor = fCurrentDiffNode.getAnnotationSupport().getEditor();
if (null != editor) {
- IReviewAnnotationModel model = fAnnotationSupport.getTargetAnnotationModel();
+ IReviewAnnotationModel model = fCurrentDiffNode.getAnnotationSupport().getAnnotationModel();
if (null != model) {
ICompareNavigator navigator = ((R4ECompareEditorInput) editor.getEditorInput()).getNavigator();
@@ -453,10 +248,10 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
R4EAnnotation foundAnnotation = null;
//We need to only consider the anomalies currently visible in the viewport
- if (null != fAnnotationSupport) {
- ITextEditor editor = fAnnotationSupport.getTargetEditor();
+ if (null != fCurrentDiffNode.getAnnotationSupport()) {
+ ITextEditor editor = fCurrentDiffNode.getAnnotationSupport().getEditor();
if (null != editor) {
- IReviewAnnotationModel model = fAnnotationSupport.getTargetAnnotationModel();
+ IReviewAnnotationModel model = fCurrentDiffNode.getAnnotationSupport().getAnnotationModel();
if (null != model) {
ICompareNavigator navigator = ((R4ECompareEditorInput) editor.getEditorInput()).getNavigator();
@@ -486,10 +281,9 @@ public class R4ECompareEditorInput extends SaveableCompareEditorInput {
* @return R4EAnnotationModel
*/
public R4EAnnotationModel getAnnotationModel() {
- if (fAnnotationSupport == null) {
+ if (fCurrentDiffNode.getAnnotationSupport() == null) {
return null;
}
-
- return (R4EAnnotationModel) fAnnotationSupport.getTargetAnnotationModel();
+ return (R4EAnnotationModel) fCurrentDiffNode.getAnnotationSupport().getAnnotationModel();
}
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDeltaCompareEditorInput.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDeltaCompareEditorInput.java
new file mode 100644
index 00000000..96bbda4f
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDeltaCompareEditorInput.java
@@ -0,0 +1,133 @@
+// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity, explicitThisUsage
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 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
+ *
+ * Description:
+ *
+ * This class is used as the input class that feeds the eclipse compare
+ * editor to internally compare 2 files to extract the differences (deltas)
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.ui.internal.editors;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
+import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.CommandUtils;
+
+/**
+ * @author Sebastien Dubois
+ * @version $Revision: 1.0 $
+ */
+public class R4EDeltaCompareEditorInput extends CompareEditorInput {
+
+ // ------------------------------------------------------------------------
+ // Members
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fTargetElement
+ */
+ private final ITypedElement fTargetElement;
+
+ /**
+ * Field fBaseElement
+ */
+ private final ITypedElement fBaseElement;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4ECompareEditorInput.
+ *
+ * @param aTargetVersion
+ * R4EFileVersion
+ * @param aBaseVersion
+ * R4EFileVersion
+ */
+ public R4EDeltaCompareEditorInput(R4EFileVersion aTargetVersion, R4EFileVersion aBaseVersion) {
+ super(new CompareConfiguration());
+ fTargetElement = CommandUtils.createTypedElement(aTargetVersion);
+ fBaseElement = CommandUtils.createTypedElement(aBaseVersion);
+ getCompareConfiguration().setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(true));
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method getAncestorElement.
+ *
+ * @return ITypedElement
+ */
+ public ITypedElement getAncestorElement() {
+ return null; //Not supported for now
+ }
+
+ /**
+ * Method getTargetElement.
+ *
+ * @return ITypedElement
+ */
+ public ITypedElement getTargetElement() {
+ return fTargetElement;
+ }
+
+ /**
+ * Method getBaseElement.
+ *
+ * @return ITypedElement
+ */
+ public ITypedElement getBaseElement() {
+ return fBaseElement;
+ }
+
+ /**
+ * Method prepareCompareInput
+ *
+ * @param aMonitor
+ * - IProgressMonitor
+ * @return Object
+ */
+ public Object prepareCompareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ return prepareInput(monitor);
+ }
+
+ /**
+ * Method prepareInput
+ *
+ * @param aMonitor
+ * - IProgressMonitor
+ * @return Object
+ * @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ //Bug 392349
+ if (null == fTargetElement && null == fBaseElement) {
+ R4EUIPlugin.Ftracer.traceWarning("Nothing to compare, both sides are NULL");
+ return null;
+ }
+ //Get Types Elements and compare the sides
+ final Differencer differencer = new Differencer();
+ return differencer.findDifferences(false, monitor, null, null, fTargetElement, fBaseElement);
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDiffNode.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDiffNode.java
new file mode 100644
index 00000000..d78790f6
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EDiffNode.java
@@ -0,0 +1,329 @@
+// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity, explicitThisUsage
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Description:
+ *
+ * This class is used as the difference node in R4E Compare Editor inputs
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.ui.internal.editors;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.CommandUtils;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Sebastien Dubois
+ * @author Steffen Pingel
+ * @version $Revision: 1.0 $
+ */
+public class R4EDiffNode extends DiffNode {
+
+ // ------------------------------------------------------------------------
+ // Members
+ // -----------------------------------------------------------------------
+
+ private IPath path;
+
+ private String name;
+
+ /**
+ * Field fTargetElement
+ */
+ private final ITypedElement fTargetElement;
+
+ /**
+ * Field fBaseElement
+ */
+ private final ITypedElement fBaseElement;
+
+ /**
+ * Field fTargetFile
+ */
+ private final R4EUIFileContext fTargetFile;
+
+ /**
+ * Field fBaseFile
+ */
+ private final R4EUIFileContext fBaseFile;
+
+ /**
+ * Field fAnnotationSupport
+ */
+ private IReviewAnnotationSupport fAnnotationSupport = null;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4EDiffNode.
+ *
+ * @param aTargetFile
+ * R4EUIFileContext
+ * @param aBaseFile
+ * R4EUIFileContext
+ * @param aUseBaseFileTargetVersion
+ * - boolean
+ */
+ public R4EDiffNode(R4EUIFileContext aTargetFile, R4EUIFileContext aBaseFile, boolean aUseBaseFileTargetVersion) {
+ super(Differencer.NO_CHANGE);
+ fTargetFile = aTargetFile;
+ fBaseFile = aBaseFile;
+
+ //The target version of the selected UI File Context element is always used as target for compare
+ R4EFileVersion targetVersion = null;
+ if (null != aTargetFile) {
+ targetVersion = aTargetFile.getTargetFileVersion();
+ }
+
+ //Use the proper base file version based on the Compare editor input type
+ R4EFileVersion baseVersion = null;
+ if (null != aBaseFile) {
+ if (aUseBaseFileTargetVersion) {
+ baseVersion = aBaseFile.getTargetFileVersion();
+ } else {
+ baseVersion = aBaseFile.getBaseFileVersion();
+ }
+ }
+
+ //Set content for the two sides of the compare editor
+ fTargetElement = CommandUtils.createTypedElement(targetVersion);
+ setLeft(fTargetElement);
+ fBaseElement = CommandUtils.createTypedElement(baseVersion);
+
+ setRight(fBaseElement);
+ setKind(resolveKind(targetVersion, baseVersion));
+ setPath(Path.fromPortableString(resolvePath(targetVersion, baseVersion)));
+ name = path.lastSegment();
+ }
+
+ public R4EDiffNode(String name) {
+ super(Differencer.NO_CHANGE);
+ this.name = name;
+ fTargetFile = null;
+ fBaseFile = null;
+ fTargetElement = null;
+ fBaseElement = null;
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method resolveKind.
+ *
+ * @param aTargetVersion
+ * - R4EFileVersion
+ * @return int
+ */
+ private int resolveKind(R4EFileVersion aTargetVersion, R4EFileVersion aBaseVersion) {
+ if (null == aTargetVersion || null == aTargetVersion.getRepositoryPath()) {
+ return Differencer.ADDITION;
+ }
+ if (null == aBaseVersion || null == aBaseVersion.getRepositoryPath()) {
+ return Differencer.DELETION;
+ }
+ return Differencer.CHANGE;
+ }
+
+ /**
+ * Method resolvePath.
+ *
+ * @param aTargetVersion
+ * - R4EFileVersion
+ * @return String
+ */
+ private String resolvePath(R4EFileVersion aTargetVersion, R4EFileVersion aBaseVersion) {
+ if (null != aTargetVersion && null != aTargetVersion.getRepositoryPath()) {
+ return aTargetVersion.getRepositoryPath();
+ }
+ if (null != aBaseVersion && null != aBaseVersion.getRepositoryPath()) {
+ return aBaseVersion.getRepositoryPath();
+ }
+ return ""; //Should never happen
+ }
+
+ /**
+ * Method getTargetLabel.
+ *
+ * @return String
+ */
+ public String getTargetLabel() {
+ return getLabel("Target: ", fTargetElement); //$NON-NLS-1$
+ }
+
+ /**
+ * Method getBaseLabel.
+ *
+ * @return String
+ */
+ public String getBaseLabel() {
+ return getLabel("Base: ", fBaseElement); //$NON-NLS-1$
+ }
+
+ /**
+ * Method getLabel.
+ *
+ * @param aTitle
+ * - String
+ * @param aElement
+ * - ITypedElement
+ * @return String
+ */
+ private String getLabel(String aTitle, ITypedElement aElement) {
+ final StringBuilder label = new StringBuilder(aTitle + (null != aElement ? aElement.getName() : ""));
+ R4EFileVersion version = getFileVersion(aElement);
+ if (null != version && !CommandUtils.useWorkspaceResource(version)) {
+ label.append(" " + version.getVersionID()); //$NON-NLS-1$
+ }
+ return label.toString();
+ }
+
+ /**
+ * Method getTargetFile.
+ *
+ * @return R4EUIFileContext
+ */
+ public R4EUIFileContext getTargetFile() {
+ return fTargetFile;
+ }
+
+ /**
+ * Method getBaseFile.
+ *
+ * @return R4EUIFileContext
+ */
+ public R4EUIFileContext getBaseFile() {
+ return fBaseFile;
+ }
+
+ /**
+ * Method getTargetVersion.
+ *
+ * @return R4EFileVersion
+ */
+ public R4EFileVersion getTargetVersion() {
+ return getFileVersion(fTargetElement);
+ }
+
+ /**
+ * Method getBaseVersion.
+ *
+ * @return R4EFileVersion
+ */
+ public R4EFileVersion getBaseVersion() {
+ return getFileVersion(fBaseElement);
+ }
+
+ /**
+ * Method getFileVersion.
+ *
+ * @param aElement
+ * - ITypedElement
+ * @return R4EFileVersion
+ */
+ private R4EFileVersion getFileVersion(ITypedElement aElement) {
+ if (aElement instanceof R4EFileTypedElement) {
+ return ((R4EFileTypedElement) aElement).getFileVersion();
+ } else if (aElement instanceof R4EFileRevisionTypedElement) {
+ return ((R4EFileRevisionTypedElement) aElement).getFileVersion();
+ }
+ return null;
+ }
+
+ /**
+ * Method getTargetTypedElement.
+ *
+ * @return ITypedElement
+ */
+ public ITypedElement getTargetTypedElement() {
+ return fTargetElement;
+ }
+
+ /**
+ * Method getBaseTypedElement.
+ *
+ * @return ITypedElement
+ */
+ public ITypedElement getBaseTypedElement() {
+ return fBaseElement;
+ }
+
+ /**
+ * Method setAnnotationSupport.
+ *
+ * @param aSupport
+ * - IReviewAnnotationSupport
+ */
+ public void setAnnotationSupport(IReviewAnnotationSupport aSupport) {
+ fAnnotationSupport = aSupport;
+ }
+
+ /**
+ * Method getAnnotationSupport.
+ *
+ * @return IReviewAnnotationSupport
+ */
+ public IReviewAnnotationSupport getAnnotationSupport() {
+ return fAnnotationSupport;
+ }
+
+ /**
+ * Method refreshAnnotations.
+ */
+ public void refreshAnnotations() {
+ if (fAnnotationSupport != null) {
+ fAnnotationSupport.refreshAnnotations(null);
+ }
+ }
+
+ @Override
+ public Image getImage() {
+ return (fTargetFile == null && fBaseFile == null) ? PlatformUI.getWorkbench()
+ .getSharedImages()
+ .getImage(ISharedImages.IMG_OBJ_FOLDER) : super.getImage();
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ @Override
+ public String getType() {
+ return (fTargetFile != null || fBaseFile != null) ? super.getType() : FOLDER_TYPE;
+ }
+
+ public void setPath(IPath path) {
+ this.path = path;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextCompareEditorInput.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextCompareEditorInput.java
new file mode 100644
index 00000000..c7d2055b
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextCompareEditorInput.java
@@ -0,0 +1,142 @@
+// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity, explicitThisUsage
+/*******************************************************************************
+ * Copyright (c) 2010, 2013 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
+ *
+ * Description:
+ *
+ * This class is used as the input class that feeds the eclipse compare
+ * editor to compare the target and base version of a File Context element
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.ui.internal.editors;
+
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Sebastien Dubois
+ * @version $Revision: 1.0 $
+ */
+public class R4EFileContextCompareEditorInput extends R4ECompareEditorInput {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field R4E_FILE_COMPARE_EDITOR_TITLE. (value is ""R4E File Compare"")
+ */
+ private static final String R4E_FILE_COMPARE_EDITOR_TITLE = "R4E File Compare"; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4ECompareEditorInput.
+ *
+ * @param aContext
+ * R4EUIFileContext
+ */
+ public R4EFileContextCompareEditorInput(R4EUIFileContext aContext) {
+ super();
+ fCurrentDiffNode = new R4EDiffNode(aContext, aContext, false);
+ initConfiguration();
+ setTitle(R4E_FILE_COMPARE_EDITOR_TITLE);
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method initConfiguration.
+ *
+ * @see org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput#initConfiguration()
+ */
+ @Override
+ protected void initConfiguration() {
+ super.initConfiguration();
+ getCompareConfiguration().setLeftLabel(fCurrentDiffNode.getTargetLabel());
+ getCompareConfiguration().setRightLabel(fCurrentDiffNode.getBaseLabel());
+ }
+
+ /**
+ * Method getAdapter.
+ *
+ * @param aAdapter
+ * Class
+ * @return Object
+ * @see org.eclipse.compare.CompareEditorInput#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class aAdapter) {
+ if (IFile.class.equals(aAdapter)) {
+ if (null != getWorkspaceElement()) {
+ return getWorkspaceElement().getResource();
+ }
+ return null;
+ }
+ return super.getAdapter(aAdapter);
+ }
+
+ /**
+ * Method getWorkspaceElement.
+ *
+ * @return R4EFileTypedElement
+ */
+ private R4EFileTypedElement getWorkspaceElement() {
+ ITypedElement targetElement = fCurrentDiffNode.getTargetTypedElement();
+ if (targetElement instanceof R4EFileTypedElement) {
+ return (R4EFileTypedElement) targetElement;
+ }
+ return null;
+ }
+
+ /**
+ * Method findContentViewer.
+ *
+ * @param aOldViewer
+ * - Viewer
+ * @param aInput
+ * - ICompareInput
+ * @param aParent
+ * - Composite
+ * @return Viewer
+ * @see org.eclipse.compare.CompareEditorInput#findContentViewer(org.eclipse.jface.viewers.Viewer,
+ * org.eclipse.compare.structuremergeviewer.ICompareInput, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public Viewer findContentViewer(Viewer aOldViewer, ICompareInput aInput, Composite aParent) {
+ final Viewer contentViewer = super.findContentViewer(aOldViewer, aInput, aParent);
+ if (aInput instanceof R4EDiffNode) {
+ //Check if files should be editable
+ if (((R4EDiffNode) aInput).getTargetTypedElement() instanceof R4EFileTypedElement) {
+ getCompareConfiguration().setLeftEditable(true);
+ //Right side (base) is always read-only
+ }
+ IReviewAnnotationSupport annotationSupport = UIUtils.getCompareAnnotationSupport(contentViewer,
+ ((R4EDiffNode) aInput).getTargetFile(), null); //No annotation model for the base is created/used
+ ((R4EDiffNode) aInput).setAnnotationSupport(annotationSupport);
+ UIUtils.insertAnnotationNavigationCommands(CompareViewerPane.getToolBarManager(aParent), annotationSupport);
+ }
+ return contentViewer;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextNode.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextNode.java
deleted file mode 100644
index 1841235f..00000000
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EFileContextNode.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 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.reviews.r4e.ui.internal.editors;
-
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DiffNode;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
-
-/**
- * @author Steffen Pingel
- */
-public class R4EFileContextNode extends DiffNode {
-
- private IPath fPath;
-
- private String fName;
-
- public R4EFileContextNode(ITypedElement aTarget, ITypedElement aBase) {
- super(Differencer.NO_CHANGE);
- R4EFileVersion targetVersion = null;
- R4EFileVersion baseVersion = null;
- if (aTarget instanceof R4EFileTypedElement) {
- targetVersion = ((R4EFileTypedElement) aTarget).getFileVersion();
- } else { //Assume R4EFileRevisionTypedElement
- targetVersion = ((R4EFileRevisionTypedElement) aTarget).getFileVersion();
- }
- if (aBase instanceof R4EFileTypedElement) {
- baseVersion = ((R4EFileTypedElement) aBase).getFileVersion();
- } else { //Assume R4EFileRevisionTypedElement
- baseVersion = ((R4EFileRevisionTypedElement) aBase).getFileVersion();
- }
-
- String targetPath = targetVersion.getRepositoryPath();
- int kind = Differencer.CHANGE;
- if (targetPath == null) {
- targetPath = baseVersion.getRepositoryPath();
- kind = Differencer.ADDITION;
- }
- String basePath = baseVersion.getRepositoryPath();
- if (basePath == null) {
- basePath = targetPath;
- kind = Differencer.DELETION;
- }
- if (targetPath.equals("/COMMIT_MSG")) { //$NON-NLS-1$
- kind = Differencer.NO_CHANGE;
- }
-
- //Set content for the two sides of the compare editor
- setLeft(aTarget);
- setRight(aBase);
- setKind(kind);
- IPath path = Path.fromPortableString(targetPath);
- setPath(path);
- setName(path.lastSegment());
- }
-
- public IPath getPath() {
- return fPath;
- }
-
- public void setPath(IPath path) {
- fPath = path;
- }
-
- @Override
- public String getName() {
- return fName;
- }
-
- public void setName(String name) {
- fName = name;
- }
-}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EReviewItemCompareEditorInput.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EReviewItemCompareEditorInput.java
new file mode 100644
index 00000000..1440de01
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/editors/R4EReviewItemCompareEditorInput.java
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Description:
+ *
+ * This class is used as an input class that feeds the eclipse compare
+ * editor to compare 2 Review Items
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.ui.internal.editors;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIFileContext;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.utils.UIUtils;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Sebastien Dubois
+ */
+public class R4EReviewItemCompareEditorInput extends R4ECompareEditorInput {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field R4E_REVIEW_ITEM_COMPARE_EDITOR_TITLE. (value is ""R4E Review Item Compare"")
+ */
+ private static final String R4E_REVIEW_ITEM_COMPARE_EDITOR_TITLE = "R4E Compare Review Item "; //$NON-NLS-1$
+
+ // ------------------------------------------------------------------------
+ // Members
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fBaseReviewItem
+ */
+ private final R4EUIReviewItem fBaseReviewItem;
+
+ /**
+ * Field fTargetReviewItem
+ */
+ private final R4EUIReviewItem fTargetReviewItem;
+
+ /**
+ * Field fRootNode
+ */
+ private DiffNode fRootNode;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for R4EReviewItemCompareEditorInput.
+ *
+ * @param aTargetReviewItem
+ * R4EUIReviewItem
+ * @param aBaseReviewItem
+ * R4EUIReviewItem
+ */
+ public R4EReviewItemCompareEditorInput(R4EUIReviewItem aTargetReviewItem, R4EUIReviewItem aBaseReviewItem) {
+ super();
+ fTargetReviewItem = aTargetReviewItem;
+ fBaseReviewItem = aBaseReviewItem;
+ initConfiguration();
+ setTitle(R4E_REVIEW_ITEM_COMPARE_EDITOR_TITLE + aTargetReviewItem.getName() + " with "
+ + aBaseReviewItem.getName());
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method initConfiguration.
+ *
+ * @see org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput#initConfiguration()
+ */
+ @Override
+ protected void initConfiguration() {
+ // Set the label values for the compare editor
+ getCompareConfiguration().setLeftEditable(false);
+ getCompareConfiguration().setRightEditable(false);
+ getCompareConfiguration().setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(true));
+ }
+
+ /**
+ * Method getBaseReviewItem.
+ *
+ * @return R4EUIReviewItem
+ */
+ public R4EUIReviewItem getBaseReviewItem() {
+ return fBaseReviewItem;
+ }
+
+ /**
+ * Method getTargetReviewItem.
+ *
+ * @return R4EUIReviewItem
+ */
+ public R4EUIReviewItem getTargetReviewItem() {
+ return fTargetReviewItem;
+ }
+
+ /**
+ * Method prepareInput
+ *
+ * @param aMonitor
+ * - IProgressMonitor
+ * @return Object
+ * @see org.eclipse.compare.CompareEditorInput#prepareInput(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected Object prepareInput(IProgressMonitor aMonitor) throws InvocationTargetException, InterruptedException {
+ if (null != aMonitor) {
+ aMonitor.beginTask("R4E Review Item Compare", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ }
+
+ if (fRootNode != null) {
+ return fRootNode;
+ }
+ fRootNode = new DiffNode(Differencer.NO_CHANGE);
+
+ //Here we compare the target versions of the target review item with the target version of the base review item.
+ //For each file in the target review item, we try to match it to the same file in the base item
+ List<R4EUIFileContext> matchedBasefiles = new ArrayList<R4EUIFileContext>();
+ for (final R4EUIFileContext targetFile : fTargetReviewItem.getFileContexts()) {
+ if (null != targetFile.getFileContext().getTarget()) {
+ R4EDiffNode node = null;
+ boolean identicalFiles = false;
+ for (R4EUIFileContext basefile : fBaseReviewItem.getFileContexts()) {
+ String targetPath = null;
+ if (null != basefile.getFileContext().getTarget()) {
+ targetPath = targetFile.getFileContext().getTarget().getRepositoryPath();
+ }
+ String basePath = null;
+ if (null != basefile.getFileContext().getTarget()) {
+ basePath = basefile.getFileContext().getTarget().getRepositoryPath();
+ }
+ if (null != targetPath && null != basePath && targetPath.equals(basePath)) {
+ //Ignore identical files
+ if (!targetFile.getTargetFileVersion()
+ .getVersionID()
+ .equals(basefile.getTargetFileVersion().getVersionID())) {
+ node = new R4EDiffNode(targetFile, basefile, true);
+ } else {
+ identicalFiles = true;
+ }
+ matchedBasefiles.add(basefile);
+ break;
+ }
+ }
+ if (null == node && !identicalFiles) {
+ //No base found, this is a new file
+ node = new R4EDiffNode(targetFile, null, true);
+ }
+
+ if (null != node) {
+ DiffNode parent = findNode(fRootNode, node.getPath());
+ parent.add(node);
+ }
+ }
+ }
+
+ //The files in the base Review Item that were not included are now included here
+ for (final R4EUIFileContext basefile : fBaseReviewItem.getFileContexts()) {
+ if (!matchedBasefiles.contains(basefile)) {
+ if (null != basefile && null != basefile.getFileContext().getTarget()) {
+ //No target found, this is a removed file
+ R4EDiffNode node = new R4EDiffNode(null, basefile, true);
+ DiffNode parent = findNode(fRootNode, node.getPath());
+ parent.add(node);
+ }
+ }
+ }
+
+ for (IDiffElement child : fRootNode.getChildren()) {
+ if (child instanceof R4EDiffNode) {
+ flattenTree((R4EDiffNode) child);
+ }
+ }
+
+ return fRootNode;
+ }
+
+ private void flattenTree(R4EDiffNode node) {
+ mergeChild(node);
+ for (IDiffElement child : node.getChildren()) {
+ if (child instanceof R4EDiffNode) {
+ flattenTree((R4EDiffNode) child);
+ }
+ }
+ }
+
+ public void mergeChild(R4EDiffNode node) {
+ if (node.getChildren().length == 1 && isDirectory(node.getChildren()[0])) {
+ R4EDiffNode child = (R4EDiffNode) node.getChildren()[0];
+ node.setName(node.getName() + "/" + child.getName());
+ node.remove(child);
+ for (IDiffElement element : child.getChildren()) {
+ node.add(element);
+ }
+ mergeChild(node);
+ }
+ }
+
+ private boolean isDirectory(IDiffElement element) {
+ return element instanceof R4EDiffNode && ((R4EDiffNode) element).getTargetFile() == null
+ && ((R4EDiffNode) element).getBaseFile() == null;
+ }
+
+ private DiffNode findNode(DiffNode root, IPath path) {
+ if (path.segmentCount() == 1) {
+ return root;
+ }
+
+ String name = path.segment(0);
+
+ // try to find existing path segment
+ IDiffElement child = root.findChild(name);
+ if (child instanceof DiffNode) {
+ return findNode((DiffNode) child, path.removeFirstSegments(1));
+ }
+
+ // create new path segment
+ R4EDiffNode node = new R4EDiffNode(name);
+ root.add(node);
+ return findNode(node, path.removeFirstSegments(1));
+ }
+
+ /**
+ * Method getToolTipText.
+ *
+ * @return String
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ if ((null != fTargetReviewItem) && (null != fBaseReviewItem)) {
+ String format = null;
+
+ // Set the label values for the compare editor
+ StringBuilder leftLabel = null;
+ String targetItemId = ""; //$NON-NLS-1$
+ if (null != fTargetReviewItem) {
+ targetItemId = fTargetReviewItem.getItem().getRepositoryRef();
+ if (null != targetItemId) {
+ leftLabel = new StringBuilder("Target Review Item " + targetItemId); //$NON-NLS-1$
+ } else {
+ //Resource file in workspace
+ leftLabel = new StringBuilder("Target Review Item " + "(Current Workspace)"); //$NON-NLS-1$
+ }
+ }
+ StringBuilder rightLabel = null;
+ String baseItemId = ""; //$NON-NLS-1$
+ if (null != fBaseReviewItem) {
+ baseItemId = fBaseReviewItem.getItem().getRepositoryRef();
+ rightLabel = new StringBuilder("Base Review Item " + baseItemId); //$NON-NLS-1$
+ }
+ format = CompareUI.getResourceBundle().getString("ResourceCompare.twoWay.tooltip"); //$NON-NLS-1$
+ return MessageFormat.format(format, new Object[] { leftLabel, rightLabel });
+ }
+ // fall back
+ return super.getToolTipText();
+ }
+
+ /**
+ * Method findContentViewer.
+ *
+ * @param aOldViewer
+ * - Viewer
+ * @param aInput
+ * - ICompareInput
+ * @param aParent
+ * - Composite
+ * @return Viewer
+ * @see org.eclipse.compare.CompareEditorInput#findContentViewer(org.eclipse.jface.viewers.Viewer,
+ * org.eclipse.compare.structuremergeviewer.ICompareInput, org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public Viewer findContentViewer(Viewer aOldViewer, ICompareInput aInput, Composite aParent) {
+ Viewer contentViewer = super.findContentViewer(aOldViewer, aInput, aParent);
+ if (aInput instanceof R4EDiffNode) {
+ if (!((R4EDiffNode) aInput).getType().equals(ITypedElement.FOLDER_TYPE)) {
+ //create/insert new Annotation model
+ IReviewAnnotationSupport annotationSupport = UIUtils.getCompareAnnotationSupport(contentViewer,
+ ((R4EDiffNode) aInput).getTargetFile(), ((R4EDiffNode) aInput).getBaseFile());
+ ((R4EDiffNode) aInput).setAnnotationSupport(annotationSupport);
+ UIUtils.insertAnnotationNavigationCommands(CompareViewerPane.getToolBarManager(aParent),
+ annotationSupport);
+ getCompareConfiguration().setLeftLabel(((R4EDiffNode) aInput).getTargetLabel());
+ getCompareConfiguration().setRightLabel(((R4EDiffNode) aInput).getBaseLabel());
+ fCurrentDiffNode = (R4EDiffNode) aInput;
+ //NOTE: This solves the problem described in bug 402060, but causes a bad listener leak in AbstractTextEditor so we remove it for now
+ //updateViewerConfig(contentViewer, (R4EDiffNode) aInput);
+ }
+ }
+ return contentViewer;
+ }
+
+ /**
+ * Method updateViewerConfig.
+ *
+ * @param aContentViewer
+ * - Viewer
+ * @param aInput
+ * - R4EDiffNode
+ */
+ protected void updateViewerConfig(Viewer aContentViewer, R4EDiffNode aInput) {
+ //NOTE: This is a temporary hack to work around the problem described in bug 402060. It should be removed when the bug is fixed
+ if (aContentViewer instanceof TextMergeViewer) {
+ final TextMergeViewer textMergeViewer = (TextMergeViewer) aContentViewer;
+ try {
+ final Class<TextMergeViewer> clazz = TextMergeViewer.class;
+ Field declaredField = clazz.getDeclaredField("isConfigured"); //$NON-NLS-1$
+ declaredField.setAccessible(true);
+ declaredField.setBoolean(textMergeViewer, false);
+ Method declaredMethod2 = clazz.getDeclaredMethod("updateContent", Object.class, Object.class, //$NON-NLS-1$
+ Object.class);
+ declaredMethod2.setAccessible(true);
+ declaredMethod2.invoke(textMergeViewer, null, aInput.getLeft(), aInput.getRight());
+ } catch (Throwable t) {
+ t.printStackTrace();
+ //do nothing for now
+ }
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/model/R4EUIReviewBasic.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/model/R4EUIReviewBasic.java
index 24d22334..9be3def1 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/model/R4EUIReviewBasic.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/model/R4EUIReviewBasic.java
@@ -737,7 +737,7 @@ public class R4EUIReviewBasic extends R4EUIReview {
int endIndex = (description.length() > R4EUIConstants.END_STRING_NAME_INDEX)
? R4EUIConstants.END_STRING_NAME_INDEX
: description.length();
- String name = "Commit: "
+ String name = CommandUtils.getCommitPrefix(items, item)
+ description.substring(R4EUIConstants.START_STRING_INDEX, endIndex) + "...";
uiItem = new R4EUIReviewItem(this, item, name, R4EUIConstants.REVIEW_ITEM_TYPE_COMMIT);
}
@@ -1062,7 +1062,8 @@ public class R4EUIReviewBasic extends R4EUIReview {
? R4EUIConstants.END_STRING_NAME_INDEX
: message.length();
- final String name = "Commit: " + message.substring(R4EUIConstants.START_STRING_INDEX, endIndex) + "...";
+ final String name = CommandUtils.getCommitPrefix(getReview().getItems(), reviewItem)
+ + message.substring(R4EUIConstants.START_STRING_INDEX, endIndex) + "...";
//Create and set UI model element
final R4EUIReviewItem uiReviewItem = new R4EUIReviewItem(this, reviewItem, name,
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/CommandUtils.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/CommandUtils.java
index cc6df7f3..d61e7bd6 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/CommandUtils.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/CommandUtils.java
@@ -22,7 +22,6 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -40,6 +39,7 @@ import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.mylyn.reviews.core.model.ILocation;
+import org.eclipse.mylyn.reviews.core.model.IReviewItem;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EAnomaly;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EAnomalyTextPosition;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EComment;
@@ -47,6 +47,7 @@ import org.eclipse.mylyn.reviews.r4e.core.model.R4ECommentType;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EContent;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EContextType;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
+import org.eclipse.mylyn.reviews.r4e.core.model.R4EItem;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EParticipant;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EReview;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EUser;
@@ -130,10 +131,7 @@ public class CommandUtils {
}
return updateTargetFile(editorFile);
} else if (aInput instanceof R4ECompareEditorInput) {
- //If we get here, this is because we are trying to act on the compare editor contents
- //this means that the file we are acting on is already in the local repository
- //in this case, we only need to provide the versionId of this file
- final ITypedElement element = ((R4ECompareEditorInput) aInput).getLeftElement();
+ final ITypedElement element = ((R4ECompareEditorInput) aInput).getCurrentDiffNode().getTargetTypedElement();
if (element instanceof R4EFileRevisionTypedElement) {
return ((R4EFileRevisionTypedElement) element).getFileVersion();
} else if (element instanceof R4EFileTypedElement) {
@@ -239,8 +237,10 @@ public class CommandUtils {
// In this case, the base file for the new Resource Review item should be the same as the target file i.e. the left file version
//3) The left file is an R4EFileRevisionTypedElement. This means that it is a file in source control.
// In this case, the base file for the new Resource Review item should be the same as the target file i.e. the left file version
- final ITypedElement leftElement = ((R4ECompareEditorInput) aInput).getLeftElement();
- final ITypedElement rightElement = ((R4ECompareEditorInput) aInput).getRightElement();
+ final ITypedElement leftElement = ((R4ECompareEditorInput) aInput).getCurrentDiffNode()
+ .getTargetTypedElement();
+ final ITypedElement rightElement = ((R4ECompareEditorInput) aInput).getCurrentDiffNode()
+ .getBaseTypedElement();
if (leftElement instanceof R4EFileTypedElement && rightElement instanceof R4EFileRevisionTypedElement) {
if (((R4EFileTypedElement) leftElement).getFileVersion()
.getVersionID()
@@ -731,49 +731,6 @@ public class CommandUtils {
}
/**
- * Method createCompareEditorInput.
- *
- * @param aBaseFileVersion
- * R4EFileVersion
- * @param aTargetFileVersion
- * R4EFileVersion
- * @return R4ECompareEditorInput
- */
- public static R4ECompareEditorInput createCompareEditorInput(R4EFileVersion aBaseFileVersion,
- R4EFileVersion aTargetFileVersion) {
-
- final CompareConfiguration config = new CompareConfiguration();
- config.setRightEditable(false);
- config.setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(true));
-
- //NOTE: We use the workspace file as input if it is in sync with the file to review,
- // otherwise we use the file to review that is included in the review repository.
- // Only workspace files are editable.
- final R4EFileRevisionTypedElement ancestor = null; //Might be improved later
- ITypedElement target = null;
- if (null != aTargetFileVersion) {
- if (CommandUtils.useWorkspaceResource(aTargetFileVersion)) {
- target = new R4EFileTypedElement(aTargetFileVersion);
- config.setLeftEditable(true);
- } else {
- target = new R4EFileRevisionTypedElement(aTargetFileVersion);
- config.setLeftEditable(false);
- }
- }
- ITypedElement base = null;
- if (null != aBaseFileVersion) {
- if (CommandUtils.useWorkspaceResource(aBaseFileVersion)) {
- base = new R4EFileTypedElement(aBaseFileVersion);
- config.setRightEditable(true);
- } else {
- base = new R4EFileRevisionTypedElement(aBaseFileVersion);
- config.setRightEditable(false);
- }
- }
- return new R4ECompareEditorInput(config, ancestor, target, base);
- }
-
- /**
* Method getAnomalyPosition.
*
* @param aAnomaly
@@ -1070,4 +1027,61 @@ public class CommandUtils {
public static boolean compareStrings(String aStr1, String aStr2) {
return ((aStr1 == aStr2) || (aStr1 != null && aStr1.equals(aStr2)));
}
+
+ /**
+ * Method createTypedElement.
+ *
+ * @param aFileVersion
+ * R4EFileVersion
+ * @return ITypedElement
+ */
+ public static ITypedElement createTypedElement(R4EFileVersion aFileVersion) {
+ //NOTE: We use the workspace file as input if it is in sync with the file to review,
+ // otherwise we use the file to review that is included in the review repository if there is a repository.
+ // default case is to use an empty typed element with the name set as the same as the other side of the comparison
+ // Only workspace files are editable.
+ if (null != aFileVersion) {
+ if (useWorkspaceResource(aFileVersion)) {
+ return new R4EFileTypedElement(aFileVersion);
+ } else {
+ return new R4EFileRevisionTypedElement(aFileVersion);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method getCommitPrefix.
+ *
+ * @param aItems
+ * List<IReviewItem>
+ * @param aCurrentItem
+ * R4EItem
+ * @return String
+ */
+ public static String getCommitPrefix(List<IReviewItem> aItems, R4EItem aCurrentItem) {
+ int commitIndex = 1;
+ boolean isManyPatchSets = false;
+ for (IReviewItem item : aItems) {
+ if (item.equals(aCurrentItem)) {
+ continue; //ignore the element itself
+ }
+ String referenceCommitLine = "";
+ if (null != ((R4EItem) item).getDescription()) {
+ referenceCommitLine = ((R4EItem) item).getDescription().split("\n")[0].trim();
+ }
+ String currentCommitLine = aCurrentItem.getDescription().split("\n")[0].trim();
+
+ if (currentCommitLine.equals(referenceCommitLine)) {
+ isManyPatchSets = true;
+ if (((R4EItem) item).getSubmitted().before(aCurrentItem.getSubmitted())) {
+ ++commitIndex;
+ }
+ }
+ }
+ if (isManyPatchSets) {
+ return "Commit " + Integer.toString(commitIndex) + ": ";
+ }
+ return "Commit: ";
+ }
}
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/DiffUtils.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/DiffUtils.java
index 46f3911c..c8417317 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/DiffUtils.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/DiffUtils.java
@@ -35,7 +35,7 @@ import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
-import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EDeltaCompareEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileRevisionTypedElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileTypedElement;
import org.eclipse.ui.IEditorInput;
@@ -74,19 +74,19 @@ public class DiffUtils {
* @param aIgnoreWhitespace
* boolean
* @param input
- * R4ECompareEditorInput
+ * R4EDeltaCompareEditorInput
* @return List<Diff>
* @throws CoreException
*/
- public List<Diff> doDiff(boolean aIsThreeWay, boolean aIgnoreWhitespace, R4ECompareEditorInput input)
+ public List<Diff> doDiff(boolean aIsThreeWay, boolean aIgnoreWhitespace, R4EDeltaCompareEditorInput input)
throws CoreException {
//THese structures will be used to hold found differences
List<Diff> changeDiffs = new ArrayList<Diff>();
//Get documents to compare form input
- final IDocument lDoc = getDocument(input.getLeftElement());
- final IDocument rDoc = getDocument(input.getRightElement());
+ final IDocument lDoc = getDocument(input.getTargetElement());
+ final IDocument rDoc = getDocument(input.getBaseElement());
final CompareConfiguration config = input.getCompareConfiguration();
if (null == lDoc || null == rDoc) {
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/MailServicesProxy.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/MailServicesProxy.java
index eddc9be7..6a003c33 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/MailServicesProxy.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/MailServicesProxy.java
@@ -984,7 +984,8 @@ public class MailServicesProxy {
if (input instanceof R4ECompareEditorInput) {
//TODO: For now we give the file version of the file on the left side, regardless of whose side the selected input was.
// Later we want to refine this.
- final ITypedElement element = ((R4ECompareEditorInput) input).getLeftElement();
+ final ITypedElement element = ((R4ECompareEditorInput) input).getCurrentDiffNode()
+ .getTargetTypedElement();
if (element instanceof R4EFileTypedElement) {
final R4EFileVersion file = ((R4EFileTypedElement) element).getFileVersion();
aMsgBody.append("File: " + file.getResource().getProject() + R4EUIConstants.SEPARATOR
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java
index 627f1ea0..26794156 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java
@@ -1287,6 +1287,31 @@ public class R4EUIConstants { // $codepro.audit.disable convertClassToInterface
public static final String OPEN_EDITOR_COMMAND_MNEMONIC = "E";
/**
+ * Field COMPARE_ITEMS_COMMAND. (value is ""org.eclipse.mylyn.reviews.r4e.ui.commands.compareItems"")
+ */
+ public static final String COMPARE_ITEMS_COMMAND = "org.eclipse.mylyn.reviews.r4e.ui.commands.compareItems";
+
+ /**
+ * Field COMPARE_ITEMS_ICON_FILE. (value is ""icons/elcl16/compareitems_menu.gif"")
+ */
+ public static final String COMPARE_ITEMS_ICON_FILE = "icons/elcl16/compareitems_menu.gif";
+
+ /**
+ * Field COMPARE_ITEMS_COMMAND_NAME. (value is ""Compare Review Items"")
+ */
+ public static final String COMPARE_ITEMS_COMMAND_NAME = "Compare Review Items";
+
+ /**
+ * Field COMPARE_ITEMS_COMMAND_TOOLTIP. (value is ""Compare selected Review Items structurally in Compare Editor"")
+ */
+ public static final String COMPARE_ITEMS_COMMAND_TOOLTIP = "Compare selected Review Items structurally in Compare Editor";
+
+ /**
+ * Field COMPARE_ITEMS_COMMAND_MNEMONIC. (value is ""C"")
+ */
+ public static final String COMPARE_ITEMS_COMMAND_MNEMONIC = "C";
+
+ /**
* Field CHANGE_REVIEW_STATE_COMMAND. (value is ""org.eclipse.mylyn.reviews.r4e.ui.commands.changeReviewState"")
*/
public static final String CHANGE_REVIEW_STATE_COMMAND = "org.eclipse.mylyn.reviews.r4e.ui.commands.changeReviewState";
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/UIUtils.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/UIUtils.java
index c68a680c..08605d59 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/UIUtils.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/UIUtils.java
@@ -13,6 +13,7 @@
package org.eclipse.mylyn.reviews.r4e.ui.internal.utils;
import java.io.File;
+import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URI;
@@ -31,10 +32,14 @@ import org.eclipse.compare.ICompareNavigator;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
import org.eclipse.compare.internal.CompareEditorInputNavigator;
+import org.eclipse.compare.internal.CompareEditorSelectionProvider;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -44,10 +49,12 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.reviews.frame.ui.annotation.IReviewAnnotationSupport;
+import org.eclipse.mylyn.reviews.frame.ui.annotation.impl.ReviewCompareAnnotationSupport;
import org.eclipse.mylyn.reviews.notifications.core.IMeetingData;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EAnomalyState;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
@@ -61,6 +68,7 @@ import org.eclipse.mylyn.reviews.r4e.core.model.serial.impl.OutOfSyncException;
import org.eclipse.mylyn.reviews.r4e.core.model.serial.impl.ResourceHandlingException;
import org.eclipse.mylyn.reviews.r4e.core.rfs.spi.ReviewsFileStorageException;
import org.eclipse.mylyn.reviews.r4e.ui.R4EUIPlugin;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.commands.R4EAnnotationContributionItems;
import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.control.R4ECompareAnnotationSupport;
import org.eclipse.mylyn.reviews.r4e.ui.internal.annotation.control.R4ESingleAnnotationSupport;
import org.eclipse.mylyn.reviews.r4e.ui.internal.commands.UIElementsProvider;
@@ -69,6 +77,8 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.dialogs.IParticipantUnassignDia
import org.eclipse.mylyn.reviews.r4e.ui.internal.dialogs.R4EUIDialogFactory;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.EditorProxy;
import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4ECompareEditorInput;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EFileContextCompareEditorInput;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.editors.R4EReviewItemCompareEditorInput;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIModelElement;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.IR4EUIPosition;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIAnomalyBasic;
@@ -80,6 +90,7 @@ import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIModelController;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIPostponedAnomaly;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewBasic;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewExtended;
+import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUIReviewItem;
import org.eclipse.mylyn.reviews.r4e.ui.internal.model.R4EUITextPosition;
import org.eclipse.mylyn.reviews.userSearch.userInfo.IUserInfo;
import org.eclipse.swt.SWT;
@@ -927,8 +938,7 @@ public class UIUtils {
try {
if (aReview instanceof R4EUIReviewExtended) {
final R4EFormalReview review = ((R4EFormalReview) ((R4EUIReviewExtended) aReview).getReview());
- if (aNewPhase.equals(R4EReviewPhase.PREPARATION)
- && null == review.getActiveMeeting()) {
+ if (aNewPhase.equals(R4EReviewPhase.PREPARATION) && null == review.getActiveMeeting()) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
@@ -1170,7 +1180,7 @@ public class UIUtils {
//Add Annotation marker for inline commenting (if applicable)
IReviewAnnotationSupport support = getAnnotationSupport(aFile);
if (null != support) {
- support.addAnnotation(aSource);
+ support.addAnnotation(aSource, aFile);
}
}
@@ -1186,7 +1196,7 @@ public class UIUtils {
//Add Annotation marker for inline commenting (if applicable)
IReviewAnnotationSupport support = getAnnotationSupport(aFile);
if (null != support) {
- support.updateAnnotation(aSource);
+ support.updateAnnotation(aSource, aFile);
}
}
@@ -1202,7 +1212,7 @@ public class UIUtils {
//Add Annotation marker for inline commenting (if applicable)
IReviewAnnotationSupport support = getAnnotationSupport(aFile);
if (null != support) {
- support.removeAnnotation(aSource);
+ support.removeAnnotation(aSource, aFile);
}
}
@@ -1216,15 +1226,17 @@ public class UIUtils {
public static IReviewAnnotationSupport getAnnotationSupport(R4EUIFileContext aFile) {
IReviewAnnotationSupport support = null;
- //First try to find Compare Editor
- IEditorPart editor = EditorProxy.findReusableCompareEditor(R4EUIModelController.getNavigatorView()
+ //First try to find File Context Compare Editor
+ IEditorPart editor = EditorProxy.findReusableFileContextCompareEditor(R4EUIModelController.getNavigatorView()
.getSite()
- .getPage(), aFile.getBaseFileVersion(), aFile.getTargetFileVersion());
+ .getPage(), aFile.getTargetFileVersion(), aFile.getBaseFileVersion());
if (null != editor) {
IEditorInput input = editor.getEditorInput();
- Viewer viewer = ((R4ECompareEditorInput) input).getContentViewer();
- if (null != viewer) {
- support = getCompareAnnotationSupport(viewer, aFile);
+ if (input instanceof R4EFileContextCompareEditorInput) {
+ Viewer viewer = ((R4EFileContextCompareEditorInput) input).getContentViewer();
+ if (null != viewer) {
+ support = getCompareAnnotationSupport(viewer, aFile, null);
+ }
}
} else {
//Try to find Single Editor
@@ -1237,6 +1249,23 @@ public class UIUtils {
support = getSingleAnnotationSupport(sourceViewer, aFile);
}
}
+ if (null == editor) {
+ //Finally try to use the Review Item structured editor
+ editor = EditorProxy.getReviewItemCompareEditorPart(R4EUIModelController.getNavigatorView()
+ .getSite()
+ .getPage(), (R4EUIReviewItem) aFile.getParent());
+ if (null != editor) {
+ IEditorInput input = editor.getEditorInput();
+ if (input instanceof R4EReviewItemCompareEditorInput) {
+ Viewer viewer = ((R4EReviewItemCompareEditorInput) input).getContentViewer();
+ if (null != viewer) {
+ support = getCompareAnnotationSupport(viewer,
+ ((R4EReviewItemCompareEditorInput) input).getCurrentDiffNode().getTargetFile(),
+ ((R4EReviewItemCompareEditorInput) input).getCurrentDiffNode().getBaseFile());
+ }
+ }
+ }
+ }
}
return support;
}
@@ -1262,17 +1291,23 @@ public class UIUtils {
/**
* Method getCompareAnnotationSupport.
*
- * @param aSourceViewer
- * ISourceViewer
- * @param aFileContext
+ * @param aViewer
+ * Viewer
+ * @param aTargetFile
+ * R4EUIFileContext
+ * @param aBaseFile
* R4EUIFileContext
* @return IReviewAnnotationSupport
*/
- public static IReviewAnnotationSupport getCompareAnnotationSupport(Viewer aViewer, Object aFileContext) {
- IReviewAnnotationSupport support = (IReviewAnnotationSupport) aViewer.getData(COMPARE_KEY_ANNOTATION_SUPPORT);
+ public static IReviewAnnotationSupport getCompareAnnotationSupport(Viewer aViewer, R4EUIFileContext aTargetFile,
+ R4EUIFileContext aBaseFile) {
+ ReviewCompareAnnotationSupport support = (ReviewCompareAnnotationSupport) aViewer.getData(COMPARE_KEY_ANNOTATION_SUPPORT);
if (support == null) {
- support = new R4ECompareAnnotationSupport(aViewer, aFileContext);
+ support = new R4ECompareAnnotationSupport(aViewer, aTargetFile, aBaseFile);
aViewer.setData(COMPARE_KEY_ANNOTATION_SUPPORT, support);
+ } else {
+ support.setAnnotationModelBaseElement(aBaseFile);
+ support.setAnnotationModelElement(aTargetFile);
}
return support;
}
@@ -1377,4 +1412,59 @@ public class UIUtils {
}
return null;
}
+
+ /**
+ * Method insertAnnotationNavigationCommands.
+ *
+ * @param aManager
+ * IToolBarManager
+ * @param aSupport
+ * IReviewAnnotationSupport
+ */
+ public static void insertAnnotationNavigationCommands(IToolBarManager aManager, IReviewAnnotationSupport aSupport) {
+ if (null == aManager.find(R4EUIConstants.NEXT_ANOMALY_ANNOTATION_COMMAND)) {
+ aManager.add(new Separator());
+ final R4EAnnotationContributionItems r4eItemsManager = new R4EAnnotationContributionItems();
+ final IContributionItem[] items = r4eItemsManager.getR4EContributionItems();
+ for (IContributionItem item : items) {
+ aManager.add(item);
+ }
+ aManager.update(true);
+ }
+ }
+
+ /**
+ * Method isLeftCompareEditorSelected.
+ *
+ * @param editor
+ * IEditorPart
+ * @return boolean
+ */
+ public static boolean isLeftCompareEditorSelected(IEditorPart editor) {
+ ISelectionProvider provider = editor.getSite().getSelectionProvider();
+
+ if (provider instanceof CompareEditorSelectionProvider) {
+ final CompareEditorSelectionProvider compareProvide = (CompareEditorSelectionProvider) provider;
+ try {
+ //NOTE: THis is a hack that we need to do to get which side of the comapre editor is selected
+ //It makes the big assumption that the left side of the compare editor is at array position 0 in fViewers.
+ //This should be improved later and we should find a better way to find what we need.
+ final Class<CompareEditorSelectionProvider> clazz = CompareEditorSelectionProvider.class;
+ Field declaredField = clazz.getDeclaredField("fViewerInFocus"); //$NON-NLS-1$
+ declaredField.setAccessible(true);
+ Object viewerInFocus = declaredField.get(compareProvide);
+ Field declaredField2 = clazz.getDeclaredField("fViewers"); //$NON-NLS-1$
+ declaredField2.setAccessible(true);
+ Object viewers = declaredField2.get(compareProvide);
+ int length = Array.getLength(viewers);
+ Object leftViewer = Array.get(viewers, 0);
+ if (leftViewer.equals(viewerInFocus)) {
+ return true;
+ }
+ } catch (Throwable t) {
+ R4EUIPlugin.Ftracer.traceWarning("Exception: " + t.toString() + " (" + t.getMessage() + ")");
+ }
+ }
+ return false;
+ }
}

Back to the top