summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbouthillie2011-12-09 14:36:44 (EST)
committer jbouthillie2011-12-09 15:00:56 (EST)
commitc5364e6913b13ee7447658c2538a937a68a60d95 (patch)
treeb1c9008f971b9e8f3a7cee2f4e2e7c37c07b5957
parentcee41b2fa15d6c42afee1c65426522f1de2fc5ce (diff)
downloadorg.eclipse.mylyn.reviews.r4e-c5364e6913b13ee7447658c2538a937a68a60d95.zip
org.eclipse.mylyn.reviews.r4e-c5364e6913b13ee7447658c2538a937a68a60d95.tar.gz
org.eclipse.mylyn.reviews.r4e-c5364e6913b13ee7447658c2538a937a68a60d95.tar.bz2
RESOLVED - bug 366052: Create an Anomaly on workspace file
version when a different file version is already present in the review. https://bugs.eclipse.org/bugs/show_bug.cgi?id=366052 Pop-up dialogue notifying the end-user Modification to test the path Change-Id: Ibf8a422088ecabf938d05463e0ef3b776076e950
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/NewAnomalyHandler.java84
-rw-r--r--org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/utils/R4EUIConstants.java5
2 files changed, 89 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/NewAnomalyHandler.java b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/NewAnomalyHandler.java
index 0763da1..e3da09a 100644
--- a/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/NewAnomalyHandler.java
+++ b/org.eclipse.mylyn.reviews.r4e.ui/src/org/eclipse/mylyn/reviews/r4e/ui/internal/commands/NewAnomalyHandler.java
@@ -32,12 +32,14 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.window.Window;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EAnomaly;
import org.eclipse.mylyn.reviews.r4e.core.model.R4EFileVersion;
import org.eclipse.mylyn.reviews.r4e.core.model.serial.impl.OutOfSyncException;
@@ -68,6 +70,24 @@ import org.eclipse.ui.texteditor.ITextEditor;
public class NewAnomalyHandler extends AbstractHandler {
// ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+// fWarningButtonLabels
+ private static final String[] fWarningButtonLabels = { "Continue", "Cancel" }; //$NON-NLS-1$
+
+ private static final String VERSION_STR = "Version: ";
+
+ private static final String QUESTION_TITLE = "R4E question";
+
+ private static final String WORKSPACE_FILE_STR = "Workspace file: ";
+
+ private static final String FILE_VERSION_STR = "Selected file version to review: ";
+
+ private static final String QUESTION_STR = "Are you sure you want to add this anomaly to the workspace file ?";
+
+ private static final String MESSAGE_STR = "You are adding an anomaly to a file version which is different from the one selected for review.";
+
+ // ------------------------------------------------------------------------
// Methods
// ------------------------------------------------------------------------
@@ -231,6 +251,7 @@ public class NewAnomalyHandler extends AbstractHandler {
private void addAnomaly(R4EFileVersion aBaseFileVersion, R4EFileVersion aTargetFileVersion,
IR4EUIPosition aUIPosition) {
+ R4EUIFileContext tempFileContext = null;
try {
//Check if the file element and/or anomaly already exist
@@ -275,10 +296,33 @@ public class NewAnomalyHandler extends AbstractHandler {
+ aUIPosition.toString());
}
return; //We found the file so we are done here
+ } else if (null != file.getFileContext().getTarget()) {
+ //Test if we find both file in the workspace
+ String reviewPlatformURI = file.getFileContext().getTarget().getPlatformURI();
+ String targetPlatformURI = aTargetFileVersion.getPlatformURI();
+ if (null != reviewPlatformURI && null != targetPlatformURI) {
+ //Now we can compare the path
+ if (reviewPlatformURI.equals(targetPlatformURI)) {
+ //Found the same file but not the same version
+ tempFileContext = file;
+ }
+ }
}
}
}
+ //Ask a question to see if the end-user wants to continue or not
+ if (null != tempFileContext) {
+ //The file exist with a different file version
+ int ret = displayDifferentFileVersionDialog(aTargetFileVersion, tempFileContext);
+ R4EUIPlugin.Ftracer.traceInfo("Info " + "return from the dialogue: " + ret);
+ if (ret == Window.CANCEL) {
+ // Cancel selected, so just exit here before adding an anomaly
+ R4EUIPlugin.Ftracer.traceInfo("Info " + "Cancel selected From dialogue in the loop");
+ return;
+ }
+ }
+
//This is a new file create it (and its parent reviewItem) and all its children
addAnomalyToNewFileContext(aBaseFileVersion, aTargetFileVersion, aUIPosition);
R4EUIPlugin.Ftracer.traceInfo("Added Anomaly: Target = "
@@ -297,6 +341,46 @@ public class NewAnomalyHandler extends AbstractHandler {
}
/**
+ * Method displayDifferentFileVersionDialog.
+ *
+ * @param R4EFileVersion
+ * workspace target file version
+ * @param R4EUIFileContext
+ * aTempFileContext current review file version
+ */
+ private int displayDifferentFileVersionDialog(R4EFileVersion aTargetFileVersion, R4EUIFileContext aTempFileContext) {
+
+ //The file exist with a different file version
+ String wsFileName = aTargetFileVersion.getRepositoryPath();
+ String wsFileVersion = aTargetFileVersion.getVersionID();
+ String riFileName = aTempFileContext.getTargetFileVersion().getRepositoryPath();
+ String riFileVersion = aTempFileContext.getTargetFileVersion().getVersionID();
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(MESSAGE_STR + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
+ sb.append(FILE_VERSION_STR);
+ sb.append(riFileName + R4EUIConstants.LINE_FEED);
+ sb.append(VERSION_STR);
+ sb.append(riFileVersion + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
+ sb.append(WORKSPACE_FILE_STR);
+ sb.append(wsFileName + R4EUIConstants.LINE_FEED);
+ sb.append(VERSION_STR);
+ sb.append(wsFileVersion + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
+ sb.append(QUESTION_STR);
+
+ MessageDialog dialog = new MessageDialog(null, // Shell
+ QUESTION_TITLE, // Dialog title
+ null, // Dialog title image message
+ sb.toString(), // Dialog message
+ MessageDialog.WARNING, // Dialog type
+ fWarningButtonLabels, // Dialog button labels
+ Window.OK // Default index (selection)
+ );
+
+ return dialog.open();
+ }
+
+ /**
* Method addCommentToExistingAnomaly.
*
* @param aUIAnomaly
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 e07e31e..dfbca97 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
@@ -34,6 +34,11 @@ public class R4EUIConstants { // $codepro.audit.disable convertClassToInterface
public static final String SEPARATOR = "/";
/**
+ * Field LINE_FEED. (value is "\n" or "\r\n") Depends on operating system
+ */
+ public static final String LINE_FEED = System.getProperty("line.separator");
+
+ /**
* Field R4E_TEMP_PROJECT. (value is ""R4ETemp"")
*/
public static final String R4E_TEMP_PROJECT = "R4ETemp";