Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2018-03-14 12:39:10 -0400
committerlgoubet2018-03-16 04:26:49 -0400
commit9dd78010cbf9bacd29434fb79442f05894b22ca0 (patch)
tree352fdf82e77aaf99c3e2217a0645cce88f4d44f6
parentb362286a730fbe7ee9ea9113b62c2ad13629a983 (diff)
downloadorg.eclipse.emf.compare-9dd78010cbf9bacd29434fb79442f05894b22ca0.tar.gz
org.eclipse.emf.compare-9dd78010cbf9bacd29434fb79442f05894b22ca0.tar.xz
org.eclipse.emf.compare-9dd78010cbf9bacd29434fb79442f05894b22ca0.zip
Add actions to merge everything to "get right" or "keep left"
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/.classpath2
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java133
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/AbstractMergeRunnable.java13
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedAction.java69
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedRunnable.java82
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeRunnableImpl.java14
9 files changed, 284 insertions, 41 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/.classpath b/plugins/org.eclipse.emf.compare.ide.ui/.classpath
index 098194ca4..eca7bdba8 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/.classpath
+++ b/plugins/org.eclipse.emf.compare.ide.ui/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.compare.ide.ui/.settings/org.eclipse.jdt.core.prefs
index 8794e3cf3..9ca9e44d2 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.emf.compare.ide.ui/.settings/org.eclipse.jdt.core.prefs
@@ -5,9 +5,9 @@ org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -91,7 +91,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.compare.ide.ui/META-INF/MANIFEST.MF
index 349b84ce2..acb87868a 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.compare.ide.ui/META-INF/MANIFEST.MF
@@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore.xmi;bundle-version="2.5.0",
org.eclipse.team.ui;bundle-version="3.5.0",
org.eclipse.emf.compare.rcp;bundle-version="2.1.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Export-Package: org.eclipse.emf.compare.ide.ui.dependency,
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties
index 82a23fcba..b96bc1ec9 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties
@@ -51,6 +51,10 @@ merged.contained.to.left.tooltip = Apply Contained Non-conflicting Right Changes
merged.contained.to.right.tooltip = Apply Contained Non-conflicting Left Changes on the Right-hand Side
merged.contained.conflicting.to.right.tooltip = Resolve Contained Conflicts by Applying Right Conflicting Changes to the Left-hand Side
merged.contained.conflicting.to.left.tooltip = Resolve Contained Conflicts by Applying Left Conflicting Changes to the Right-hand Side
+
+merge.all.contained.to.left.text = Get the right version, ignoring any change done in the left.
+merge.all.contained.to.right.text = Keep the left version, ignoring any change done in the right.
+
dropdown.left.to.right.text = Show consequences of merging from left to right
dropdown.right.to.left.text = Show consequences of merging from right to left
dropdown.accept.text = Show consequences of accepting change
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 6d55a1194..d1c60edbd 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -103,6 +103,7 @@ import org.eclipse.emf.compare.ide.ui.internal.progress.JobProgressInfoComposite
import org.eclipse.emf.compare.ide.ui.internal.progress.JobProgressMonitorWrapper;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.EMFCompareStructureMergeViewerContentProvider.FetchListener;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.MergeAction;
+import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.MergeContainedAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.MergeContainedConflictingAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.MergeContainedNonConflictingAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.provider.TreeCompareInputAdapterFactory;
@@ -148,6 +149,7 @@ import org.eclipse.emf.edit.tree.TreeNode;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -520,34 +522,121 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
modes = EnumSet.of(MergeMode.ACCEPT, MergeMode.REJECT);
}
if (rightEditable || leftEditable) {
- for (MergeMode mode : modes) {
- IMerger.Registry mergerRegistry = EMFCompareRCPPlugin.getDefault().getMergerRegistry();
- if (isOneDiffSelected()) {
- MergeAction mergeAction = new MergeAction(getCompareConfiguration(), mergerRegistry, mode,
- navigatable, (IStructuredSelection)getSelection());
- manager.add(mergeAction);
- } else if (isOneMatchOrResourceMatchSelected()) {
- final Predicate<TreeNode> filterPredicate = new Predicate<TreeNode>() {
- public boolean apply(TreeNode input) {
- return input != null
- && JFaceUtil.isFiltered(getViewer(), input, input.getParent());
- }
- };
- MergeContainedNonConflictingAction mergeAction = new MergeContainedNonConflictingAction(
- getCompareConfiguration(), mergerRegistry, mode, navigatable,
- (IStructuredSelection)getSelection(), filterPredicate);
- manager.add(mergeAction);
-
- MergeContainedConflictingAction mergeConflictingAction = new MergeContainedConflictingAction(
- getCompareConfiguration(), mergerRegistry, mode, navigatable,
- (IStructuredSelection)getSelection(), filterPredicate);
- manager.add(mergeConflictingAction);
+ IMerger.Registry mergerRegistry = EMFCompareRCPPlugin.getDefault().getMergerRegistry();
+ if (isOneDiffSelected()) {
+ addSingleDiffMergeActions(manager, modes, mergerRegistry);
+ } else if (isOneMatchOrResourceMatchSelected()) {
+ addMergeNonConflictingActions(manager, modes, mergerRegistry);
+ manager.add(new Separator());
+ addMergeConflictingActions(manager, modes, mergerRegistry);
+
+ if (leftEditable && !rightEditable) {
+ manager.add(new Separator());
+ addMergeAllActions(manager, modes, mergerRegistry);
}
}
}
}
/**
+ * This will add the merge actions targeting a single selected difference to the given menu manager.
+ *
+ * @param manager
+ * The menu manager in which we'll be adding actions.
+ * @param modes
+ * The current merge modes.
+ * @param mergerRegistry
+ * The merger registry the new actions need to use.
+ */
+ private void addSingleDiffMergeActions(IMenuManager manager, EnumSet<MergeMode> modes,
+ IMerger.Registry mergerRegistry) {
+ for (MergeMode mode : modes) {
+ MergeAction mergeAction = new MergeAction(getCompareConfiguration(), mergerRegistry, mode,
+ navigatable, (IStructuredSelection)getSelection());
+ manager.add(mergeAction);
+ }
+ }
+
+ /**
+ * This will add the "merge all non-conflicting" actions to the given menu manager. These actions are
+ * meant to allow a user to merge all non-conflicting diffs under the given selection at once, leaving
+ * only conflicts untouched.
+ *
+ * @param manager
+ * The menu manager in which we'll be adding actions.
+ * @param modes
+ * The current merge modes.
+ * @param mergerRegistry
+ * The merger registry the new actions need to use.
+ */
+ private void addMergeNonConflictingActions(IMenuManager manager, EnumSet<MergeMode> modes,
+ IMerger.Registry mergerRegistry) {
+ final Predicate<TreeNode> filterPredicate = new Predicate<TreeNode>() {
+ public boolean apply(TreeNode input) {
+ return input != null && JFaceUtil.isFiltered(getViewer(), input, input.getParent());
+ }
+ };
+ for (MergeMode mode : modes) {
+ MergeContainedNonConflictingAction mergeAction = new MergeContainedNonConflictingAction(
+ getCompareConfiguration(), mergerRegistry, mode, navigatable,
+ (IStructuredSelection)getSelection(), filterPredicate);
+ manager.add(mergeAction);
+ }
+ }
+
+ /**
+ * This will add the "merge non-conflicting" actions to the given menu manager. These actions are meant to
+ * allow a user to merge all conflicting diffs under the given selection at once, leaving non-conflicting
+ * diffs untouched.
+ *
+ * @param manager
+ * The menu manager in which we'll be adding actions.
+ * @param modes
+ * The current merge modes.
+ * @param mergerRegistry
+ * The merger registry the new actions need to use.
+ */
+ private void addMergeConflictingActions(IMenuManager manager, EnumSet<MergeMode> modes,
+ IMerger.Registry mergerRegistry) {
+ final Predicate<TreeNode> filterPredicate = new Predicate<TreeNode>() {
+ public boolean apply(TreeNode input) {
+ return input != null && JFaceUtil.isFiltered(getViewer(), input, input.getParent());
+ }
+ };
+ for (MergeMode mode : modes) {
+ MergeContainedConflictingAction mergeAction = new MergeContainedConflictingAction(
+ getCompareConfiguration(), mergerRegistry, mode, navigatable,
+ (IStructuredSelection)getSelection(), filterPredicate);
+ manager.add(mergeAction);
+ }
+ }
+
+ /**
+ * This will add actions to the given menu manager that will allow a user to merge everything at once in a
+ * given direction, effectively taking the left- or right-side contents as the new left.
+ *
+ * @param manager
+ * The menu manager in which we'll be adding actions.
+ * @param modes
+ * The current merge modes.
+ * @param mergerRegistry
+ * The merger registry the new actions need to use.
+ */
+ private void addMergeAllActions(IMenuManager manager, EnumSet<MergeMode> modes,
+ IMerger.Registry mergerRegistry) {
+ final Predicate<TreeNode> filterPredicate = new Predicate<TreeNode>() {
+ public boolean apply(TreeNode input) {
+ return input != null && JFaceUtil.isFiltered(getViewer(), input, input.getParent());
+ }
+ };
+ for (MergeMode mode : modes) {
+ MergeContainedAction mergeAllAction = new MergeContainedAction(getCompareConfiguration(),
+ mergerRegistry, mode, navigatable, (IStructuredSelection)getSelection(), filterPredicate);
+ manager.add(mergeAllAction);
+ }
+ }
+
+ /**
* Check if the item selected in this viewer is mergeable; that is, if a {@link Diff}, a {@link Match}, or
* {@link MatchResource} is selected.
*
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/AbstractMergeRunnable.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/AbstractMergeRunnable.java
index 9c0dd7337..abd89c396 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/AbstractMergeRunnable.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/AbstractMergeRunnable.java
@@ -21,9 +21,12 @@ import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Set;
+import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.internal.merge.MergeMode;
+import org.eclipse.emf.compare.merge.BatchMerger;
import org.eclipse.emf.compare.merge.DiffRelationshipComputer;
+import org.eclipse.emf.compare.merge.IBatchMerger;
import org.eclipse.emf.compare.merge.IDiffRelationshipComputer;
import org.eclipse.emf.compare.merge.IMerger;
import org.eclipse.emf.compare.merge.IMerger.Registry;
@@ -147,4 +150,14 @@ public abstract class AbstractMergeRunnable {
}
}
}
+
+ protected void mergeAll(Collection<? extends Diff> differences, boolean leftToRight,
+ Registry mergerRegistry) {
+ final IBatchMerger merger = new BatchMerger(getDiffRelationshipComputer(mergerRegistry));
+ if (leftToRight) {
+ merger.copyAllLeftToRight(differences, new BasicMonitor());
+ } else {
+ merger.copyAllRightToLeft(differences, new BasicMonitor());
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedAction.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedAction.java
new file mode 100644
index 000000000..8bc27ec7b
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedAction.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions;
+
+import com.google.common.base.Predicate;
+
+import org.eclipse.compare.INavigatable;
+import org.eclipse.emf.compare.domain.IMergeRunnable;
+import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.internal.merge.MergeMode;
+import org.eclipse.emf.compare.merge.IDiffRelationshipComputer;
+import org.eclipse.emf.compare.merge.IMerger.Registry;
+import org.eclipse.emf.compare.rcp.ui.internal.configuration.IEMFCompareConfiguration;
+import org.eclipse.emf.edit.tree.TreeNode;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * This action will merge all differences contained in the selection, regardless of conflicts or originating
+ * side.
+ * <p>
+ * This will allow the user to either get the right content or keep the left content for the given
+ * differences.
+ * </p>
+ *
+ * @author Laurent Goubet <laurent.goubet@obeo.fr>
+ */
+public class MergeContainedAction extends AbstractMergeContainedAction {
+ public MergeContainedAction(IEMFCompareConfiguration compareConfiguration, Registry mergerRegistry,
+ MergeMode mode, INavigatable navigatable, IStructuredSelection selection,
+ Predicate<TreeNode> isFiltered) {
+ super(compareConfiguration, mergerRegistry, mode, navigatable);
+ this.isFiltered = isFiltered;
+ updateSelection(selection);
+ }
+
+ @Override
+ protected IMergeRunnable createMergeRunnable(MergeMode mode, boolean isLeftEditable,
+ boolean isRightEditable, IDiffRelationshipComputer relationshipComputer) {
+ return new MergeContainedRunnable(isLeftEditable, isRightEditable, mode, relationshipComputer);
+ }
+
+ @Override
+ protected void initToolTipAndImage(MergeMode mode) {
+ switch (mode) {
+ case LEFT_TO_RIGHT:
+ // fall through
+ case ACCEPT:
+ setText(EMFCompareIDEUIMessages.getString("merge.all.contained.to.right.text")); //$NON-NLS-1$
+ setToolTipText(EMFCompareIDEUIMessages.getString("merge.all.contained.to.right.text")); //$NON-NLS-1$
+ break;
+ case RIGHT_TO_LEFT:
+ // fall through
+ case REJECT:
+ setText(EMFCompareIDEUIMessages.getString("merge.all.contained.to.left.text")); //$NON-NLS-1$
+ setToolTipText(EMFCompareIDEUIMessages.getString("merge.all.contained.to.left.text")); //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedRunnable.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedRunnable.java
new file mode 100644
index 000000000..60be0ceca
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeContainedRunnable.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions;
+
+import java.util.List;
+
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.domain.IMergeRunnable;
+import org.eclipse.emf.compare.internal.merge.MergeMode;
+import org.eclipse.emf.compare.merge.IDiffRelationshipComputer;
+import org.eclipse.emf.compare.merge.IMerger;
+import org.eclipse.emf.compare.merge.IMerger.Registry;
+
+/**
+ * The runnable for the {@link MergeContainedAction}. Will only change the left-hand side of the comparison.
+ *
+ * @author Laurent Goubet <laurent.goubet@obeo.fr>
+ */
+public class MergeContainedRunnable extends AbstractMergeRunnable implements IMergeRunnable {
+ /** The delegate merger for the conflicting differences. */
+ private final MergeConflictingRunnable conflictsMergers;
+
+ public MergeContainedRunnable(boolean isLeftEditable, boolean isRightEditable, MergeMode mergeMode,
+ IDiffRelationshipComputer diffRelationshipComputer) {
+ super(isLeftEditable, isRightEditable, mergeMode, diffRelationshipComputer);
+ // Note that we're considering that "ACCEPT" means that we're keeping the left version, so we need to
+ // inverse the mode for the delegate merger.
+ conflictsMergers = new MergeConflictingRunnable(isLeftEditable, isRightEditable, mergeMode.inverse(),
+ diffRelationshipComputer);
+ }
+
+ public void merge(List<? extends Diff> differences, boolean leftToRight, Registry mergerRegistry) {
+ if (getMergeMode().isLeftToRight(isLeftEditable(), isRightEditable()) != leftToRight) {
+ throw new IllegalStateException();
+ }
+
+ // Use our delegate to handle all conflicts
+ conflictsMergers.merge(differences, leftToRight, mergerRegistry);
+
+ // Then merge the remainder as needed
+ final boolean mergeDiffs;
+ switch (getMergeMode()) {
+ case LEFT_TO_RIGHT:
+ // fall through
+ case ACCEPT:
+ mergeDiffs = false;
+ break;
+ case RIGHT_TO_LEFT:
+ // fall through
+ case REJECT:
+ // fall through
+ default:
+ mergeDiffs = true;
+ }
+
+ if (mergeDiffs) {
+ mergeAll(differences, false, mergerRegistry);
+ } else {
+ // Mark all differences from the left as merged and ACCEPTED
+ differences.stream().filter(d -> d.getSource() == DifferenceSource.LEFT)
+ .forEach(d -> markAsMerged(d, MergeMode.ACCEPT, mergerRegistry));
+ // Mark all differences from the right as merged and REJECTED
+ differences.stream().filter(d -> d.getSource() == DifferenceSource.RIGHT)
+ .forEach(d -> markAsMerged(d, MergeMode.REJECT, mergerRegistry));
+ }
+
+ }
+
+ private void markAsMerged(Diff diff, MergeMode mode, IMerger.Registry mergerRegistry) {
+ boolean isLeftToRight = mode.isLeftToRight(diff, isLeftEditable(), isRightEditable());
+ markAsMerged(diff, mode, !isLeftToRight, mergerRegistry);
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeRunnableImpl.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeRunnableImpl.java
index 234b7fff6..84d1bcdc5 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeRunnableImpl.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeRunnableImpl.java
@@ -15,16 +15,12 @@ import static com.google.common.collect.Lists.newArrayList;
import com.google.common.base.Preconditions;
-import java.util.Collection;
import java.util.List;
-import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.domain.IMergeRunnable;
import org.eclipse.emf.compare.internal.merge.MergeMode;
import org.eclipse.emf.compare.internal.merge.MergeOperation;
-import org.eclipse.emf.compare.merge.BatchMerger;
-import org.eclipse.emf.compare.merge.IBatchMerger;
import org.eclipse.emf.compare.merge.IDiffRelationshipComputer;
import org.eclipse.emf.compare.merge.IMerger.Registry;
@@ -70,14 +66,4 @@ public final class MergeRunnableImpl extends AbstractMergeRunnable implements IM
throw new IllegalStateException();
}
}
-
- private void mergeAll(Collection<? extends Diff> differences, boolean leftToRight,
- Registry mergerRegistry) {
- final IBatchMerger merger = new BatchMerger(getDiffRelationshipComputer(mergerRegistry));
- if (leftToRight) {
- merger.copyAllLeftToRight(differences, new BasicMonitor());
- } else {
- merger.copyAllRightToLeft(differences, new BasicMonitor());
- }
- }
}

Back to the top