summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkwilk2011-01-26 19:10:14 (EST)
committerRyan D. Brooks2011-01-26 19:10:14 (EST)
commitb5ba50b98b33fa822f14911f0fa3aef62a7e9e12 (patch)
tree75e030bcb7584f0653330e7d62ff64ce81ee2a39
parent05a85eef2470465abd942a12e27c3e53fba9dc52 (diff)
downloadorg.eclipse.osee-b5ba50b98b33fa822f14911f0fa3aef62a7e9e12.zip
org.eclipse.osee-b5ba50b98b33fa822f14911f0fa3aef62a7e9e12.tar.gz
org.eclipse.osee-b5ba50b98b33fa822f14911f0fa3aef62a7e9e12.tar.bz2
feature[ats_K7L14]: Add multi-conflict resolution options to Merge Manager
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/Conflict.java5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/ConflictHandlingOperation.java85
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java14
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java151
4 files changed, 247 insertions, 8 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/Conflict.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/Conflict.java
index 1f1cb0f..dfb64c0 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/Conflict.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/conflict/Conflict.java
@@ -48,7 +48,6 @@ public abstract class Conflict implements IAdaptable {
private String destDiffFile = null;
protected Conflict(int sourceGamma, int destGamma, int artId, TransactionRecord toTransactionId, TransactionRecord commitTransactionId, Branch mergeBranch, Branch sourceBranch, Branch destBranch) {
- super();
this.sourceGamma = sourceGamma;
this.destGamma = destGamma;
this.artId = artId;
@@ -216,6 +215,10 @@ public abstract class Conflict implements IAdaptable {
return !(status.equals(ConflictStatus.RESOLVED) || status.equals(ConflictStatus.COMMITTED) || status.equals(ConflictStatus.INFORMATIONAL) || status.equals(ConflictStatus.NOT_RESOLVABLE));
}
+ public boolean isResolvable() {
+ return !statusNotResolvable() && !statusInformational();
+ }
+
public int getMergeBranchID() {
return mergeBranch.getId();
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/ConflictHandlingOperation.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/ConflictHandlingOperation.java
new file mode 100644
index 0000000..918435e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/ConflictHandlingOperation.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.skynet.widgets.xmerge;
+
+import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.ConflictStatus;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.skynet.core.conflict.Conflict;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+
+/**
+ * @author Karol M. Wilk
+ */
+public final class ConflictHandlingOperation extends AbstractOperation {
+
+ public static enum ConflictOperationEnum {
+ RESET,
+ SET_DST_AND_RESOLVE,
+ SET_SRC_AND_RESOLVE,
+ MARK_RESOLVED,
+ MARK_UNRESOLVED
+ }
+
+ private final Collection<Conflict> conflicts;
+ private final ConflictOperationEnum operation;
+
+ public ConflictHandlingOperation(ConflictOperationEnum operation, Collection<Conflict> conflicts) {
+ super("Updating conflicts", SkynetGuiPlugin.PLUGIN_ID);
+ this.conflicts = conflicts;
+ this.operation = operation;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws OseeCoreException {
+ Conditions.checkNotNullOrEmpty(conflicts, "conflicts");
+ for (Conflict conflict : conflicts) {
+ if (conflict.isResolvable()) {
+ switch (operation) {
+ case RESET:
+ if (conflict.statusResolved()) {
+ MergeUtility.clearValue(conflict, null, false);
+ conflict.setStatus(ConflictStatus.EDITED);
+ }
+ break;
+ case SET_DST_AND_RESOLVE:
+ if (!conflict.statusResolved()) {
+ MergeUtility.setToDest(conflict, null, false);
+ conflict.setStatus(ConflictStatus.RESOLVED);
+ }
+ break;
+ case SET_SRC_AND_RESOLVE:
+ if (!conflict.statusResolved()) {
+ MergeUtility.setToSource(conflict, null, false);
+ conflict.setStatus(ConflictStatus.RESOLVED);
+ }
+ break;
+ case MARK_RESOLVED:
+ if (!conflict.statusUntouched()) {
+ conflict.setStatus(ConflictStatus.RESOLVED);
+ }
+ break;
+ case MARK_UNRESOLVED:
+ if (!conflict.statusUntouched()) {
+ conflict.setStatus(ConflictStatus.EDITED);
+ }
+ break;
+ default:
+ throw new OseeArgumentException("Invalid operation [%s]", operation);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
index 62d0df7..1de6257 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeUtility.java
@@ -17,8 +17,6 @@ import java.util.List;
import java.util.logging.Level;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.core.enums.ConflictType;
-import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
-import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.operation.Operations;
@@ -62,7 +60,7 @@ public class MergeUtility {
public static final String OPEN_MERGE_DIALOG =
"This will open a window that will allow in-document merging in Word. You will need to right click on every difference and either accept or reject the change. If you begin an in-document merge you will not be able to finalize the conflict until you resolve every change in the document.\n Computing a Merge will wipe out any merge changes you have made and start with a fresh diff of the two files. If you want to only view the changes use the difference options.\n Change that touch the entire file are better handled using copy and paste. \n\nWARNING: Word will occasionaly show incorrect changes especially when users have both modified the same block of text. Check your final version.";
- public static void clearValue(Conflict conflict, Shell shell, boolean prompt) throws MultipleArtifactsExist, ArtifactDoesNotExist, Exception {
+ public static void clearValue(Conflict conflict, Shell shell, boolean prompt) throws OseeCoreException {
if (conflict == null) {
return;
}
@@ -71,7 +69,7 @@ public class MergeUtility {
}
}
- public static void setToDest(Conflict conflict, Shell shell, boolean prompt) throws MultipleArtifactsExist, ArtifactDoesNotExist, Exception {
+ public static void setToDest(Conflict conflict, Shell shell, boolean prompt) throws OseeCoreException {
if (conflict == null) {
return;
}
@@ -80,7 +78,7 @@ public class MergeUtility {
}
}
- public static void setToSource(Conflict conflict, Shell shell, boolean prompt) throws MultipleArtifactsExist, ArtifactDoesNotExist, Exception {
+ public static void setToSource(Conflict conflict, Shell shell, boolean prompt) throws OseeCoreException {
if (conflict == null) {
return;
}
@@ -92,7 +90,11 @@ public class MergeUtility {
public static boolean okToOverwriteEditedValue(Conflict conflict, Shell shell, boolean prompt) throws OseeCoreException {
boolean proceed = true;
if (!conflict.statusEditable()) {
- MessageDialog.openInformation(shell, "Attention", COMMITED_PROMPT);
+ if (shell != null) {
+ MessageDialog.openInformation(shell, "Attention", COMMITED_PROMPT);
+ } else {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Attention: " + COMMITED_PROMPT);
+ }
return false;
}
if (!(conflict.mergeEqualsDestination() || conflict.mergeEqualsSource() || conflict.statusUntouched()) && prompt) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java
index 39e5b09..5e02913 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeView.java
@@ -17,10 +17,13 @@ import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
@@ -32,6 +35,8 @@ import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.help.ui.OseeHelpContext;
import org.eclipse.osee.framework.logging.OseeLevel;
@@ -66,6 +71,7 @@ import org.eclipse.osee.framework.ui.skynet.revert.RevertWizard;
import org.eclipse.osee.framework.ui.skynet.util.SkynetViews;
import org.eclipse.osee.framework.ui.skynet.widgets.GenericViewPart;
import org.eclipse.osee.framework.ui.skynet.widgets.xHistory.HistoryView;
+import org.eclipse.osee.framework.ui.skynet.widgets.xmerge.ConflictHandlingOperation.ConflictOperationEnum;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.NonmodalWizardDialog;
@@ -86,7 +92,9 @@ import org.eclipse.ui.menus.CommandContributionItem;
* @author Donald G. Dunne
*/
public class MergeView extends GenericViewPart implements IBranchEventListener, IArtifactEventListener {
+
public static final String VIEW_ID = "org.eclipse.osee.framework.ui.skynet.widgets.xmerge.MergeView";
+
private MergeXWidget mergeXWidget;
private IHandlerService handlerService;
private Branch sourceBranch;
@@ -95,6 +103,46 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
private TransactionRecord commitTrans;
private boolean showConflicts;
+ private final class MergeManagerConflictHandler extends AbstractSelectionEnabledHandler {
+ private final String dialogString;
+ private final ConflictOperationEnum kindOfOperation;
+ private List<Conflict> conflicts;
+
+ public MergeManagerConflictHandler(MenuManager menuManager, String dialogString, ConflictOperationEnum kindOfOperation) {
+ super(menuManager);
+ this.dialogString = dialogString;
+ this.kindOfOperation = kindOfOperation;
+ }
+
+ @Override
+ public Object executeWithException(ExecutionEvent event) {
+ boolean confirm =
+ MessageDialog.openConfirm(Displays.getActiveShell().getShell(), "Confirm",
+ String.format(dialogString, conflicts.size()));
+ if (confirm) {
+ IOperation operation = new ConflictHandlingOperation(kindOfOperation, conflicts);
+ Operations.executeAsJob(operation, true, Job.SHORT, new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ mergeXWidget.refresh();
+ }
+ });
+ }
+ });
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isEnabledWithException(IStructuredSelection structuredSelection) {
+ conflicts = mergeXWidget.getSelectedConflicts();
+ return !conflicts.isEmpty();
+ }
+ }
+
public static void openView(final Branch sourceBranch, final Branch destBranch, final TransactionRecord tranId) {
if (Conditions.allNull(sourceBranch, destBranch, tranId)) {
throw new IllegalArgumentException("Branch's and Transaction ID can't be null");
@@ -181,6 +229,14 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
addEditArtifactMenuItem(menuManager);
addMergeMenuItem(menuManager);
menuManager.add(new Separator());
+ addMarkAsResolvedMenuItem(menuManager);
+ addMarkAsUnResolvedMenuItem(menuManager);
+ menuManager.add(new Separator());
+ addSourceAsMergeValueMenuItem(menuManager);
+ addDestinationAsMergeValueMenuItem(menuManager);
+ menuManager.add(new Separator());
+ addResetConflictMenuItem(menuManager);
+ menuManager.add(new Separator());
addPreviewMenuItem(menuManager);
addDiffMenuItem(menuManager);
menuManager.add(new Separator());
@@ -199,6 +255,14 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
createEditArtifactMenuItem(menuManager);
createMergeMenuItem(menuManager);
menuManager.add(new Separator());
+ createMarkResolvedMenuItem(menuManager);
+ createMarkUnResolvedMenuItem(menuManager);
+ menuManager.add(new Separator());
+ createSourceAsMergeMenuItem(menuManager);
+ createDestinationAsMergeMenuItem(menuManager);
+ menuManager.add(new Separator());
+ createResetConflictMenuItem(menuManager);
+ menuManager.add(new Separator());
createPreviewMenuItem(menuManager);
createDiffMenuItem(menuManager);
menuManager.add(new Separator());
@@ -338,6 +402,46 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
return revertSelected.getId();
}
+ private String addMarkAsResolvedMenuItem(MenuManager menuManager) {
+ CommandContributionItem markAsResolvedSelected =
+ Commands.getLocalCommandContribution(getSite(), "markAsResolvedSelected", "Mark as Resolved", null, null,
+ null, null, null, null);
+ menuManager.add(markAsResolvedSelected);
+ return markAsResolvedSelected.getId();
+ }
+
+ private String addMarkAsUnResolvedMenuItem(MenuManager menuManager) {
+ CommandContributionItem markAsUnResolvedSelected =
+ Commands.getLocalCommandContribution(getSite(), "markAsUnResolvedSelected", "Mark as Unresolved", null, null,
+ null, null, null, null);
+ menuManager.add(markAsUnResolvedSelected);
+ return markAsUnResolvedSelected.getId();
+ }
+
+ private String addSourceAsMergeValueMenuItem(MenuManager menuManager) {
+ CommandContributionItem mergeValueSourcePickerSelected =
+ Commands.getLocalCommandContribution(getSite(), "mergeValueSourcePickerSelected",
+ "Resolve using Source Value", null, null, null, null, null, null);
+ menuManager.add(mergeValueSourcePickerSelected);
+ return mergeValueSourcePickerSelected.getId();
+ }
+
+ private String addDestinationAsMergeValueMenuItem(MenuManager menuManager) {
+ CommandContributionItem mergeValueDestinationPickerSelected =
+ Commands.getLocalCommandContribution(getSite(), "mergeValueDestinationPickerSelected",
+ "Resolve using Destination Value", null, null, null, null, null, null);
+ menuManager.add(mergeValueDestinationPickerSelected);
+ return mergeValueDestinationPickerSelected.getId();
+ }
+
+ private String addResetConflictMenuItem(MenuManager menuManager) {
+ CommandContributionItem resetConflictMenuItem =
+ Commands.getLocalCommandContribution(getSite(), "resetConflictMenuItem", "Reset Conflict", null, null, null,
+ null, null, null);
+ menuManager.add(resetConflictMenuItem);
+ return resetConflictMenuItem.getId();
+ }
+
private void createEditArtifactMenuItem(MenuManager menuManager) {
handlerService.activateHandler(addEditArtifactMenuItem(menuManager),
@@ -529,6 +633,50 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
});
}
+ private void createMarkResolvedMenuItem(MenuManager menuManager) {
+ String commandId = addMarkAsResolvedMenuItem(menuManager);
+ IHandler handler =
+ new MergeManagerConflictHandler(menuManager,
+ "Are you sure you want to Mark the selected [%s] conflict(s) as Resolved?",
+ ConflictOperationEnum.MARK_RESOLVED);
+ handlerService.activateHandler(commandId, handler);
+ }
+
+ private void createMarkUnResolvedMenuItem(MenuManager menuManager) {
+ String commandId = addMarkAsUnResolvedMenuItem(menuManager);
+ IHandler handler =
+ new MergeManagerConflictHandler(menuManager,
+ "Are you sure you want to Mark the selected [%s] conflict(s) as UnResolved?",
+ ConflictOperationEnum.MARK_UNRESOLVED);
+ handlerService.activateHandler(commandId, handler);
+ }
+
+ private void createSourceAsMergeMenuItem(MenuManager menuManager) {
+ String commandId = addSourceAsMergeValueMenuItem(menuManager);
+ IHandler handler =
+ new MergeManagerConflictHandler(menuManager,
+ "Are you sure you want to set the Merge value to the Source value for the selected [%s] conflict(s)?",
+ ConflictOperationEnum.SET_SRC_AND_RESOLVE);
+ handlerService.activateHandler(commandId, handler);
+ }
+
+ private void createDestinationAsMergeMenuItem(MenuManager menuManager) {
+ String commandId = addDestinationAsMergeValueMenuItem(menuManager);
+ IHandler handler =
+ new MergeManagerConflictHandler(menuManager,
+ "Are you sure you want to set the Merge value to the Destination value for the selected [%s] conflict(s)?",
+ ConflictOperationEnum.SET_DST_AND_RESOLVE);
+ handlerService.activateHandler(commandId, handler);
+ }
+
+ private void createResetConflictMenuItem(MenuManager menuManager) {
+ String commandId = addResetConflictMenuItem(menuManager);
+ IHandler handler =
+ new MergeManagerConflictHandler(menuManager, "Are you sure you want to reset %s conflict(s)?",
+ ConflictOperationEnum.RESET);
+ handlerService.activateHandler(commandId, handler);
+ }
+
private String addMergeMenuItem(MenuManager menuManager) {
CommandContributionItem mergeArtifactCommand =
Commands.getLocalCommandContribution(getSite(), "mergeArtifactCommand",
@@ -842,4 +990,5 @@ public class MergeView extends GenericViewPart implements IBranchEventListener,
});
}
-} \ No newline at end of file
+
+}