Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikaël Barbero2013-10-08 10:18:42 +0000
committerMikaël Barbero2013-10-11 14:22:30 +0000
commit693a08962392bdb31c894bd02c31dfffe3d61847 (patch)
tree3114de2e0fb321bacc771863f0bf2fdd3f94230e /plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java
parentb09d1f1e084aaa201b87ee9de2b8d5a8c1611b79 (diff)
downloadorg.eclipse.emf.compare-693a08962392bdb31c894bd02c31dfffe3d61847.tar.gz
org.eclipse.emf.compare-693a08962392bdb31c894bd02c31dfffe3d61847.tar.xz
org.eclipse.emf.compare-693a08962392bdb31c894bd02c31dfffe3d61847.zip
Introduce MergeMode and rewrite actions.
This simplifies implementation of merge actions and all UI related to merge. Change-Id: I3330c7de23abbca9744d4082b11e2b30b26e9e2f
Diffstat (limited to 'plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java')
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java
new file mode 100644
index 000000000..b77e05715
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/command/impl/MergeCommand.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.command.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.compare.Diff;
+import org.eclipse.emf.compare.domain.IMergeRunnable;
+import org.eclipse.emf.compare.merge.IMerger;
+import org.eclipse.emf.ecore.change.util.ChangeRecorder;
+
+/**
+ * A merge command that delegates it {@link #doExecute()} to the
+ * {@link IMergeRunnable#merge(List, boolean, IMerger.Registry)} method.
+ *
+ * @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
+ */
+public class MergeCommand extends AbstractCopyCommand {
+
+ /** The merge runnable to delegate to. */
+ private final IMergeRunnable runnable;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param changeRecorder
+ * The change recorder associated to this command.
+ * @param notifiers
+ * The collection of notifiers that will be notified of this command's execution.
+ * @param differences
+ * The list of differences that this command should merge.
+ * @param leftToRight
+ * The direction in which {@code differences} should be merged.
+ * @param mergerRegistry
+ * The registry of mergers.
+ * @param runnable
+ * The merge runnable to delegate to.
+ */
+ public MergeCommand(ChangeRecorder changeRecorder, Collection<Notifier> notifiers,
+ List<? extends Diff> differences, boolean leftToRight, IMerger.Registry mergerRegistry,
+ IMergeRunnable runnable) {
+ super(changeRecorder, notifiers, differences, leftToRight, mergerRegistry);
+ this.runnable = runnable;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.edit.command.ChangeCommand#doExecute()
+ */
+ @Override
+ protected void doExecute() {
+ runnable.merge(differences, leftToRight, mergerRegistry);
+ }
+
+}

Back to the top