Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Delaigue2016-04-22 08:51:07 -0400
committerMathieu Cartaud2016-06-14 09:43:49 -0400
commitc8c94bc43d1b4c479914475566a2690bce73c785 (patch)
tree76b340eedf0eb56d92c44c04b95f11371658f06f
parenta04478a4cfaa41286386aed838dd2112d2ef66d1 (diff)
downloadorg.eclipse.emf.compare-c8c94bc43d1b4c479914475566a2690bce73c785.tar.gz
org.eclipse.emf.compare-c8c94bc43d1b4c479914475566a2690bce73c785.tar.xz
org.eclipse.emf.compare-c8c94bc43d1b4c479914475566a2690bce73c785.zip
Add a preference for pre-merge on conflict
Change-Id: Ide5265721c970b6d0019f8a764e01f41d70d51b1 Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/plugin.xml6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/ide_ui_messages.properties2
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java10
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferences.java7
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferencesInitializer.java3
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/MergePreferencesPage.java41
6 files changed, 67 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/plugin.xml b/plugins/org.eclipse.emf.compare.ide.ui/plugin.xml
index c3b32fa18..bb2e50e29 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.compare.ide.ui/plugin.xml
@@ -432,6 +432,12 @@
id="org.eclipse.emf.compare.ide.ui.preferencepage.resolvers"
name="Resolution strategy">
</page>
+ <page
+ category="org.eclipse.emf.compare.rcp.ui.preferencePage.global"
+ class="org.eclipse.emf.compare.ide.ui.internal.preferences.MergePreferencesPage"
+ id="org.eclipse.emf.compare.ide.ui.preferencepage.merge"
+ name="Merge">
+ </page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
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 1348ef3b6..196bb0ef5 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
@@ -80,6 +80,8 @@ ModelResolutionPreferencesPage.resolutionScope.container.description = Search fo
ModelResolutionPreferencesPage.resolutionScope.outgoing.description = Only search for cross-references from the compared resource to its children (and recursively).
ModelResolutionPreferencesPage.resolutionScope.invalid = Invalid resolution scope value.
+MergePreferencesPage.preMergeOnConflict = Pre-merge models when a real conflict is detected
+
_UI_NoProblems_message = There are no problems with the computation of the comparison
_UI_DefaultProblem_message = Problems encountered. Click on each problem for further information. The computed comparison and the merge you will do on it may be inaccurate. We suggest you to fix the errors before doing any merge or to switch to text comparison (use 'Text Compare' below)
_UI_Cancel_message = Operation has been canceled. The computed comparison and the merge you will do on it may be inaccurate. We suggest you to be very careful or to switch to text comparison (use 'Text Compare' below)
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
index 51fe332da..0393c1445 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/logical/EMFResourceMappingMerger.java
@@ -71,6 +71,7 @@ import org.eclipse.emf.compare.graph.IGraph;
import org.eclipse.emf.compare.graph.PruningIterator;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
+import org.eclipse.emf.compare.ide.ui.internal.preferences.EMFCompareUIPreferences;
import org.eclipse.emf.compare.ide.ui.logical.IModelMinimizer;
import org.eclipse.emf.compare.ide.ui.logical.SynchronizationModel;
import org.eclipse.emf.compare.ide.utils.ResourceUtil;
@@ -87,6 +88,7 @@ import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.IResourceMappingMerger;
@@ -314,6 +316,12 @@ public class EMFResourceMappingMerger implements IResourceMappingMerger {
* @return the set of the uri for resources on which conflicts were not auto-mergeable.
*/
private Set<URI> performPreMerge(Comparison comparison, SubMonitor subMonitor) {
+ final IPreferenceStore store = EMFCompareIDEUIPlugin.getDefault().getPreferenceStore();
+ boolean preMerge = store.getBoolean(EMFCompareUIPreferences.PRE_MERGE_MODELS_WHEN_CONFLICT);
+ return performPreMerge(comparison, preMerge, subMonitor);
+ }
+
+ private Set<URI> performPreMerge(Comparison comparison, boolean preMerge, SubMonitor subMonitor) {
final IGraph<Diff> differencesGraph = MergeDependenciesUtil.mapDifferences(comparison,
MERGER_REGISTRY, true, MergeMode.RIGHT_TO_LEFT);
final PruningIterator<Diff> iterator = differencesGraph.breadthFirstIterator();
@@ -326,7 +334,7 @@ public class EMFResourceMappingMerger implements IResourceMappingMerger {
iterator.prune();
conflictingURIs
.addAll(collectConflictingResources(differencesGraph.depthFirstIterator(next)));
- } else if (next.getState() != DifferenceState.MERGED) {
+ } else if (next.getState() != DifferenceState.MERGED && preMerge) {
final IMerger merger = MERGER_REGISTRY.getHighestRankingMerger(next);
merger.copyRightToLeft(next, emfMonitor);
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferences.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferences.java
index 3e0564552..eb7a4a2e8 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferences.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferences.java
@@ -39,4 +39,11 @@ public interface EMFCompareUIPreferences {
* {@link org.eclipse.emf.compare.ide.ui.internal.logical.resolver.CrossReferenceResolutionScope}.
*/
String RESOLUTION_SCOPE_PREFERENCE = EMFCompareIDEUIPlugin.PLUGIN_ID + ".preference.resolutionScope"; //$NON-NLS-1$
+
+ /**
+ * Preference indicating whether a pre-merge must be performed when a REAL conflict is detected. The
+ * expected values are <code>true</code> or <code>false</code>.
+ */
+ String PRE_MERGE_MODELS_WHEN_CONFLICT = EMFCompareIDEUIPlugin.PLUGIN_ID
+ + ".preference.preMergeOnConflict"; //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferencesInitializer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferencesInitializer.java
index a3085323b..d6b003ef3 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferencesInitializer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/EMFCompareUIPreferencesInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2016 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
@@ -29,5 +29,6 @@ public class EMFCompareUIPreferencesInitializer extends AbstractPreferenceInitia
store.setDefault(EMFCompareUIPreferences.DISABLE_THREADING_PREFERENCE, false);
store.setDefault(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
CrossReferenceResolutionScope.CONTAINER.name());
+ store.setDefault(EMFCompareUIPreferences.PRE_MERGE_MODELS_WHEN_CONFLICT, false);
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/MergePreferencesPage.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/MergePreferencesPage.java
new file mode 100644
index 000000000..0785b47d9
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/preferences/MergePreferencesPage.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.preferences;
+
+import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preference page for EMFCompare merge.
+ *
+ * @author <a href="mailto:laurent.delaigue@obeo.fr">Laurent Delaigue</a>
+ */
+public class MergePreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private BooleanFieldEditor preMergeOnConflict;
+
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(EMFCompareIDEUIPlugin.getDefault().getPreferenceStore());
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ preMergeOnConflict = new BooleanFieldEditor(EMFCompareUIPreferences.PRE_MERGE_MODELS_WHEN_CONFLICT,
+ EMFCompareIDEUIMessages.getString("MergePreferencesPage.preMergeOnConflict"), //$NON-NLS-1$
+ getFieldEditorParent());
+ addField(preMergeOnConflict);
+ }
+
+}

Back to the top