Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2017-09-18 10:15:39 -0400
committerLaurent Goubet2018-12-11 05:23:11 -0500
commit745ca4b14982b775fa250f66acb886f08d08869d (patch)
tree61c8023d910fe201f1cb93496c3adef1dc0ea43a
parent6cdc8d9966f34103b157687a6a34d09bc9b8acc3 (diff)
downloadorg.eclipse.emf.compare-745ca4b14982b775fa250f66acb886f08d08869d.tar.gz
org.eclipse.emf.compare-745ca4b14982b775fa250f66acb886f08d08869d.tar.xz
org.eclipse.emf.compare-745ca4b14982b775fa250f66acb886f08d08869d.zip
[514079] Improve mirroring support
The changes introduced in https://git.eclipse.org/r/#/c/93726/ to support mirroring are incomplete and lead to a very confusing state. If the user swapped the sides in the CMV, the SMV tree continues to show diffs with the same directional overlays. Also the tool bar actions have the tooltips and operate in the original direction; thus, contradicting the side shown in the CMV. With this change, we also adapt the changes in the SMV, if the user switched the sides in the CMV. Moreover, this change also simplifies and improves the way how the mirroring support is implemented by creating a new viewer when the mirroring state changes instead of switching all the content and label providers within each implementation class. Thus, this commit partly reverts the previous change 93726 and replaces it with a more thorough and straight-forward implementation. Bug: 514079 Change-Id: Ia91454e421a6916fa8e7d62eded3180f7905b28a
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java40
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/internal/edit_messages.properties64
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java23
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/OverlayImageProvider.java35
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AbstractTooltipProvider.java554
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AttributeChangeTooltipProvider.java47
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ReferenceChangeTooltipProvider.java213
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceAttachmentChangeTooltipProvider.java128
-rw-r--r--plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceLocationChangeTooltipProvider.java6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/MirroredMergeActionTest.java12
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/EMFCompareConfiguration.java22
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/ForwardingCompareConfiguration.java18
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java152
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorManager.java218
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorUtil.java153
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/TextFallbackCompareViewerCreator.java4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/fallback/TextFallbackMergeViewer.java65
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabelContentViewer.java101
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabeledViewerCreator.java10
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesContentViewer.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesViewerCreator.java6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemContentViewer.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemViewerCreator.java6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemContentViewer.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemViewerCreator.java6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsContentViewer.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsViewerCreator.java6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/WaitContentViewer.java8
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/MirroredTableContentMergeViewerContentProvider.java124
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/TableContentMergeViewer.java40
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java75
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/MirroredEMFCompareTextMergeViewerContentProvider.java125
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/MirroredTreeContentMergeViewerContentProvider.java110
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/TreeContentMergeViewer.java65
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareToolBar.java25
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/DependencyData.java7
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java72
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java39
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/configuration/IEMFCompareConfiguration.java5
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractMergeViewer.java17
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java10
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/IMergeData.java17
-rw-r--r--plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/MergeDataImpl.java38
44 files changed, 1459 insertions, 1240 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
index 628971d5c..a8a49e858 100644
--- a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramContentMergeViewer.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
- * Philip Langer - adaptation for refactoring regarding SizeChange
+ * Philip Langer - adaptation for refactoring regarding SizeChange, bug 514079
* Simon Delisle - bug 511047
* Camille Letavernier - bug 529882
*******************************************************************************/
@@ -64,7 +64,6 @@ import org.eclipse.emf.compare.diagram.internal.extensions.Hide;
import org.eclipse.emf.compare.diagram.internal.extensions.Show;
import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.EMFCompareContentMergeViewer;
-import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree.MirroredTreeContentMergeViewerContentProvider;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree.TreeContentMergeViewerContentProvider;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer;
@@ -89,7 +88,6 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Composite;
@@ -555,8 +553,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
*/
protected IFigure getLayer(View referenceView, MergeViewerSide side) {
Diagram referenceDiagram = referenceView.getDiagram();
- MergeViewerSide matchSide = computeSide(side);
- Diagram targetDiagram = (Diagram)getMatchView(referenceDiagram, matchSide);
+ Diagram targetDiagram = (Diagram)getMatchView(referenceDiagram, getEffectiveSide(side));
DiagramMergeViewer targetViewer = getViewer(side);
EditPart editPart = targetViewer.getEditPart(targetDiagram);
if (editPart != null) {
@@ -1018,8 +1015,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
*/
private Phantom createPhantom(Diff diff, View referenceView, IFigure referenceFigure,
MergeViewerSide side) {
- MergeViewerSide targetSide = computeSide(side);
- IFigure targetLayer = getLayer(referenceView, targetSide);
+ IFigure targetLayer = getLayer(referenceView, side);
if (targetLayer != null) {
MergeViewerSide referenceSide = getSide(referenceView);
@@ -1748,12 +1744,6 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
/** The current "opened" difference. */
private Diff fCurrentSelectedDiff;
- /** Flag to indicate that the decorators should be refreshed. */
- private boolean fRefreshDecorators;
-
- /** The unmirrored content provider of this merge viewer. */
- private TreeContentMergeViewerContentProvider fContentProvider;
-
/** Flag to store whether this viewer synchronizes the zoom level of all diagrams. */
private boolean isSynchronizingZoom;
@@ -1777,8 +1767,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
public DiagramContentMergeViewer(Composite parent, EMFCompareConfiguration config) {
super(SWT.NONE, ResourceBundle.getBundle(BUNDLE_NAME), config);
buildControl(parent);
- fContentProvider = new TreeContentMergeViewerContentProvider(config);
- setMirrored(isMirrored());
+ setContentProvider(new TreeContentMergeViewerContentProvider(config));
}
/**
@@ -1877,12 +1866,11 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
Diff diff = input.getDiff(); // equivalent to getInput().getTarget()
- if (!isInTerminalState(diff) && (diff != fCurrentSelectedDiff || fRefreshDecorators)) {
+ if (!isInTerminalState(diff) && diff != fCurrentSelectedDiff) {
fDecoratorsManager.revealDecorators(diff);
}
fCurrentSelectedDiff = diff;
- fRefreshDecorators = false;
} else {
fCurrentSelectedDiff = null;
}
@@ -2060,7 +2048,7 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
} else if (match.getOrigin() == view) {
result = MergeViewerSide.ANCESTOR;
}
- return computeSide(result);
+ return getEffectiveSide(result);
}
/**
@@ -2103,20 +2091,4 @@ public class DiagramContentMergeViewer extends EMFCompareContentMergeViewer impl
return result;
}
- @Override
- protected void updateMirrored(boolean isMirrored) {
- fRefreshDecorators = true;
- super.updateMirrored(isMirrored);
- }
-
- @Override
- protected IContentProvider getUnmirroredContentProvider() {
- return fContentProvider;
- }
-
- @Override
- protected IContentProvider getMirroredContentProvider() {
- return new MirroredTreeContentMergeViewerContentProvider(getCompareConfiguration(), fContentProvider);
- }
-
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/internal/edit_messages.properties b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/internal/edit_messages.properties
index 1b1a483b6..3bd15055d 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/internal/edit_messages.properties
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/internal/edit_messages.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2013, 2016 Obeo and others.
+# Copyright (c) 2013, 2018 Obeo and others.
# 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
@@ -7,7 +7,7 @@
#
# Contributors:
# Obeo - initial API and implementation
-# Philip Langer - bug 488700
+# Philip Langer - bugs 488700, 514079
################################################################################
## ! note ! double the apostrophes if you need one in the printed String
conflict=Conflict
@@ -57,7 +57,9 @@ ResourceNameChangeItemProviderSpec.description.locationChanged = {0} {1} renamed
ContextualTooltip.acceptChange = Accept the change.
ContextualTooltip.rejectChange = Reject the change.
ContextualTooltip.readonly.leftUnchanged = The left-hand side will remain unchanged.
+ContextualTooltip.readonly.rightUnchanged = The right-hand side will remain unchanged.
ContextualTooltip.readonly.leftChanged = The left-hand side will be modified.
+ContextualTooltip.readonly.rightChanged = The right-hand side will be modified.
ContextualTooltip.editable.rightChanged = The left-hand side will remain unchanged.\nThe right-hand side will be modified.
ContextualTooltip.editable.rightUnchanged = The left-hand side will be modified.\nThe right-hand side will remain unchanged.
@@ -91,6 +93,35 @@ ContextualTooltip.delete.nonContainment.left.accept = Keep the deletion of ''{0}
ContextualTooltip.delete.containment.right.accept = Delete ''{0}'' in ''{1}'' on the left-hand side.
ContextualTooltip.delete.nonContainment.right.accept = Delete ''{0}'' on the left-hand side.
+# Accept contextual tooltips reversed
+ContextualTooltip.set.left.accept.leftToRight = Keep ''{0}'' in ''{1}'' of this ''{2}'' on the right-hand side.
+ContextualTooltip.set.right.accept.leftToRight = Set the ''{0}'' of this ''{1}'' to ''{2}'' (instead of ''{3}'') on the right-hand side.
+ContextualTooltip.set.right.accept.empty.leftToRight = Set the ''{0}'' of this ''{1}'' to ''{2}'' on the right-hand side.
+ContextualTooltip.unset.left.accept.leftToRight = Keep the ''{0}'' of this ''{1}'' unset on the right-hand side.
+ContextualTooltip.unset.right.accept.leftToRight = Unset the ''{0}'' of this ''{1}'' (currently ''{2}'') on the right-hand side.
+ContextualTooltip.rlc.left.accept.leftToRight = Keep the location of the resource to ''{0}'' on the right-hand side.
+ContextualTooltip.rlc.right.accept.leftToRight = Change right-hand side resource location to ''{0}''.
+ContextualTooltip.rac.control.left.accept.leftToRight = Keep ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.control.right.accept.leftToRight = Control ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.uncontrol.left.accept.leftToRight = Keep ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.uncontrol.right.accept.leftToRight = Reintegrate ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.move.container.left.accept.leftToRight = Keep ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.move.position.left.container.accept.leftToRight = Keep ''{0}'' at its current position in ''{1}'' on the right-hand side.
+ContextualTooltip.move.position.left.accept.leftToRight = Keep ''{0}'' at its current position on the right-hand side.
+ContextualTooltip.move.container.right.accept.leftToRight = Move ''{0}'' in ''{1}'' (currently in ''{2}'') on the right-hand side.
+ContextualTooltip.move.position.right.container.accept.leftToRight = Move the position of ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.move.position.right.accept.leftToRight = Move the position of ''{0}'' on the right-hand side.
+ContextualTooltip.add.containment.left.accept.leftToRight = Keep ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.add.nonContainment.left.accept.leftToRight = Keep ''{0}'' on the right-hand side.
+ContextualTooltip.add.attribute.left.accept.leftToRight = Keep ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.add.containment.right.accept.leftToRight = Add ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.add.nonContainment.right.accept.leftToRight = Add ''{0}'' on the right-hand side.
+ContextualTooltip.add.attribute.right.accept.leftToRight = Add ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.delete.containment.left.accept.leftToRight = Keep the deletion of ''{0}'' from ''{1}'' on the right-hand side.
+ContextualTooltip.delete.nonContainment.left.accept.leftToRight = Keep the deletion of ''{0}'' on the right-hand side.
+ContextualTooltip.delete.containment.right.accept.leftToRight = Delete ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.delete.nonContainment.right.accept.leftToRight = Delete ''{0}'' on the right-hand side.
+
# Reject contextual tooltips
ContextualTooltip.set.left.reject = Restore the ''{0}'' of this ''{1}'' to ''{2}'' (instead of ''{3}'') on the left-hand side.
ContextualTooltip.set.left.reject.empty = Clear the ''{0}'' of this ''{1}'' (currently ''{2}'') on the left-hand side.
@@ -120,6 +151,35 @@ ContextualTooltip.delete.nonContainment.left.reject = Restore ''{0}'' on the lef
ContextualTooltip.delete.containment.right.reject = Keep ''{0}'' in ''{1}'' on the left-hand side.
ContextualTooltip.delete.nonContainment.right.reject = Keep ''{0}'' on the left-hand side.
+# Reject contextual tooltips reversed
+ContextualTooltip.set.left.reject.leftToRight = Restore the ''{0}'' of this ''{1}'' to ''{2}'' (instead of ''{3}'') on the right-hand side.
+ContextualTooltip.set.left.reject.empty.leftToRight = Clear the ''{0}'' of this ''{1}'' (currently ''{2}'') on the right-hand side.
+ContextualTooltip.set.right.reject.leftToRight = Keep ''{0}'' in ''{1}'' of this ''{2}'' on the right-hand side.
+ContextualTooltip.set.right.reject.empty.leftToRight = Keep the ''{0}'' of this ''{1}'' empty on the right-hand side.
+ContextualTooltip.unset.left.reject.leftToRight = Restore the ''{0}'' of this ''{1}'' to ''{2}'' on the right-hand side.
+ContextualTooltip.unset.right.reject.leftToRight = Keep the ''{0}'' of this ''{1}'' set to ''{2}'' on the right-hand side.
+ContextualTooltip.rlc.left.reject.leftToRight = Restore the location of the resource to ''{0}'' on the right-hand side.
+ContextualTooltip.rlc.right.reject.leftToRight = Keep the location of the resource to ''{0}'' on the right-hand side.
+ContextualTooltip.rac.control.left.reject.leftToRight = Reintegrate ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.control.right.reject.leftToRight = Keep ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.uncontrol.left.reject.leftToRight = Control ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.rac.uncontrol.right.reject.leftToRight = Keep ''{0}'' in resource ''{1}'' on the right-hand side.
+ContextualTooltip.move.container.left.reject.leftToRight = Restore ''{0}'' in ''{1}'' (currently in ''{2}'') on the right-hand side.
+ContextualTooltip.move.position.left.reject.leftToRight = Restore the original position of ''{0}'' on the right-hand side.
+ContextualTooltip.move.container.right.reject.leftToRight = Keep ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.move.position.right.reject.leftToRight = Keep ''{0}'' at its current position on the right-hand side.
+ContextualTooltip.move.position.right.container.reject.leftToRight = Keep ''{0}'' at its current position under ''{1}'' on the right-hand side.
+ContextualTooltip.add.containment.left.reject.leftToRight = Delete ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.add.nonContainment.left.reject.leftToRight = Delete ''{0}'' on the right-hand side.
+ContextualTooltip.add.attribute.left.reject.leftToRight = Delete ''{0}'' from ''{1}'' on the right-hand side.
+ContextualTooltip.add.containment.right.reject.leftToRight = Do not add ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.add.nonContainment.right.reject.leftToRight = Do not add ''{0}'' on the right-hand side.
+ContextualTooltip.add.attribute.right.reject.leftToRight = Do not add ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.delete.containment.left.reject.leftToRight = Restore ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.delete.nonContainment.left.reject.leftToRight = Restore ''{0}'' on the right-hand side.
+ContextualTooltip.delete.containment.right.reject.leftToRight = Keep ''{0}'' in ''{1}'' on the right-hand side.
+ContextualTooltip.delete.nonContainment.right.reject.leftToRight = Keep ''{0}'' on the right-hand side.
+
# Copy from left to right contextual tooltips
ContextualTooltip.set.left.leftToRight = Set the ''{0}'' of this ''{1}'' to ''{2}'' on the right-hand side (currently ''{3}'').
ContextualTooltip.set.left.leftToRight.empty = Set the ''{0}'' of this ''{1}'' to ''{2}'' on the right-hand side.
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
index 274e28dcd..398e2ea84 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/MatchResourceItemProviderSpec.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 Obeo.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -7,7 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
- * Philip Langer (EclipseSource) - bug 488618
+ * Philip Langer (EclipseSource) - bugs 488618, 514079
*******************************************************************************/
package org.eclipse.emf.compare.provider.spec;
@@ -19,6 +19,7 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.MatchResource;
import org.eclipse.emf.compare.ResourceAttachmentChange;
+import org.eclipse.emf.compare.internal.merge.IMergeData;
import org.eclipse.emf.compare.provider.IItemDescriptionProvider;
import org.eclipse.emf.compare.provider.IItemStyledLabelProvider;
import org.eclipse.emf.compare.provider.MatchResourceItemProvider;
@@ -26,6 +27,7 @@ import org.eclipse.emf.compare.provider.SafeAdapterFactoryItemDelegator;
import org.eclipse.emf.compare.provider.utils.ComposedStyledString;
import org.eclipse.emf.compare.provider.utils.IStyledString;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
/**
@@ -92,10 +94,20 @@ public class MatchResourceItemProviderSpec extends MatchResourceItemProvider imp
@Override
public String getText(Object object) {
final MatchResource matchResource = (MatchResource)object;
- final String leftURI = matchResource.getLeftURI();
- final String rightURI = matchResource.getRightURI();
+ String leftURI = matchResource.getLeftURI();
+ String rightURI = matchResource.getRightURI();
+
+ // If the comparison is mirrored, swap left and right.
+ final IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(matchResource.getComparison(),
+ IMergeData.class);
+ if (mergeData != null && mergeData.isMirrored()) {
+ String effectiveLeftURI = rightURI;
+ String effectiveRightURI = leftURI;
+ leftURI = effectiveLeftURI;
+ rightURI = effectiveRightURI;
+ }
- final String commonBase = getCommonBase(leftURI, rightURI);
+ String commonBase = getCommonBase(leftURI, rightURI);
String text = ""; //$NON-NLS-1$
if (leftURI != null) {
@@ -109,6 +121,7 @@ public class MatchResourceItemProviderSpec extends MatchResourceItemProvider imp
&& ((Comparison)matchResource.eContainer()).isThreeWay()) {
final String originURI = matchResource.getOriginURI();
if (originURI != null) {
+ commonBase = getCommonBase(commonBase, originURI);
text += " (" + originURI.substring(commonBase.length()) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/OverlayImageProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/OverlayImageProvider.java
index 66c684bfc..7b9c75f43 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/OverlayImageProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/provider/spec/OverlayImageProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 Obeo.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.provider.spec;
@@ -166,7 +167,9 @@ public class OverlayImageProvider {
*/
private String getThreeWayOverlay(final Diff diff) {
DifferenceKind diffKind = diff.getKind();
- DifferenceSource source = diff.getSource();
+ Comparison comp = ComparisonUtil.getComparison(diff);
+ IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(comp, IMergeData.class);
+ DifferenceSource source = getEffectiveSource(diff, mergeData);
StringBuilder path = new StringBuilder();
if (hasDirectOrIndirectConflict(REAL).apply(diff)) {
// The diff or one of its refining diffs are in a pseudo conflict
@@ -221,10 +224,10 @@ public class OverlayImageProvider {
*/
// @CHECKSTYLE:OFF
private String getDiscardedOverlay(Diff diff) {
- DifferenceSource source = diff.getSource();
Comparison comp = ComparisonUtil.getComparison(diff);
IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(comp, IMergeData.class);
if (mergeData != null) {
+ DifferenceSource source = getEffectiveSource(diff, mergeData);
switch (source) {
case LEFT:
if (mergeData.isLeftEditable() && mergeData.isRightEditable()) {
@@ -256,10 +259,10 @@ public class OverlayImageProvider {
*/
// @CHECKSTYLE:OFF
private String getMergedOverlay(Diff diff) {
- DifferenceSource source = diff.getSource();
Comparison comp = ComparisonUtil.getComparison(diff);
IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(comp, IMergeData.class);
if (mergeData != null) {
+ DifferenceSource source = getEffectiveSource(diff, mergeData);
switch (source) {
case LEFT:
if (mergeData.isLeftEditable() && mergeData.isRightEditable()) {
@@ -320,6 +323,30 @@ public class OverlayImageProvider {
}
/**
+ * The source that's effective based on the {@link IMergeData#isMirrored() mirroring} state.
+ *
+ * @param diff
+ * the diff for which we want the effective source.
+ * @param mergeData
+ * the merge data that provides the mirroring state.
+ * @return the source that's effective based on the mirror state.
+ */
+ private DifferenceSource getEffectiveSource(Diff diff, IMergeData mergeData) {
+ DifferenceSource source = diff.getSource();
+ if (mergeData != null && mergeData.isMirrored()) {
+ switch (source) {
+ case LEFT:
+ return DifferenceSource.RIGHT;
+ case RIGHT:
+ return DifferenceSource.LEFT;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+ return source;
+ }
+
+ /**
* Extended {@link ComposedImage} that positionned the overlay properly for EMF Compare.
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AbstractTooltipProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AbstractTooltipProvider.java
index ba8111d91..4c815bb11 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AbstractTooltipProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AbstractTooltipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 Obeo and others.
+ * Copyright (c) 2015, 2018 Obeo and others.
* 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
@@ -7,24 +7,30 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.tooltip;
import static org.eclipse.emf.compare.internal.EMFCompareEditMessages.getString;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.DifferenceSource;
+import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.ResourceAttachmentChange;
import org.eclipse.emf.compare.ResourceLocationChange;
+import org.eclipse.emf.compare.internal.merge.IMergeData;
import org.eclipse.emf.compare.internal.merge.MergeMode;
+import org.eclipse.emf.compare.internal.utils.ComparisonUtil;
import org.eclipse.emf.compare.provider.ISemanticObjectLabelProvider;
import org.eclipse.emf.compare.provider.ITooltipLabelProvider;
import org.eclipse.emf.compare.utils.MatchUtil;
import org.eclipse.emf.compare.utils.ReferenceUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
@@ -71,10 +77,30 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
* @param value
* The body of the tooltip
* @return the complete tooltip
+ * @deprecated Override or call {@link #acceptAndChanged(String, boolean)} instead.
*/
+ @Deprecated
protected String acceptAndChanged(String value) {
+ return acceptAndChanged(value, false);
+ }
+
+ /**
+ * Create the final tooltip for an accepted change which leads to a modification of the specified side.
+ *
+ * @param value
+ * The body of the tooltip
+ * @param isLeftToRight
+ * the direction of the change.
+ * @return the complete tooltip
+ */
+ protected String acceptAndChanged(String value, boolean isLeftToRight) {
String accept = getString("ContextualTooltip.acceptChange"); //$NON-NLS-1$
- String modify = getString("ContextualTooltip.readonly.leftChanged"); //$NON-NLS-1$
+ String modify;
+ if (isLeftToRight) {
+ modify = getString("ContextualTooltip.readonly.rightChanged"); //$NON-NLS-1$
+ } else {
+ modify = getString("ContextualTooltip.readonly.leftChanged"); //$NON-NLS-1$
+ }
StringBuilder builder = new StringBuilder();
builder.append(accept).append(LINE_SEPARATOR).append(value).append(LINE_SEPARATOR).append(modify);
@@ -93,15 +119,79 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
}
/**
- * Create the final tooltip for an accepted change which don't lead to a modification of the left side.
+ * Returns whether the sides are logically mirrored when displayed.
+ *
+ * @param diff
+ * the diff to consider.
+ * @return whether the sides are logically mirrored when displayed.
+ */
+ protected boolean isMirrored(T diff) {
+ Comparison comparison = ComparisonUtil.getComparison(diff);
+ if (comparison != null) {
+ IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(comparison, IMergeData.class);
+ return mergeData != null && mergeData.isMirrored();
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns whether the mode will lead to merge to left to right depending whether left and/or right are
+ * editable.
+ *
+ * @param diff
+ * the diff is used to determine the {@link ComparisonUtil#getComparison(Diff) comparison}.
+ * @param mode
+ * the mode.
+ * @return if whether the mode will lead to merge to left to right depending whether left and/or right are
+ * editable.
+ */
+ protected boolean isLeftToRight(T diff, MergeMode mode) {
+ Comparison comparison = ComparisonUtil.getComparison(diff);
+ if (comparison != null) {
+ IMergeData mergeData = (IMergeData)EcoreUtil.getExistingAdapter(comparison, IMergeData.class);
+ if (mergeData != null) {
+ if (mergeData.isMirrored()) {
+ return mode.isLeftToRight(mergeData.isRightEditable(), mergeData.isLeftEditable());
+ } else {
+ return mode.isLeftToRight(mergeData.isLeftEditable(), mergeData.isRightEditable());
+ }
+ }
+ }
+ return mode.isLeftToRight(true, true);
+ }
+
+ /**
+ * Create the final tooltip for an accepted change which doesn't lead to a modification of the left side.
*
* @param value
* The body of the tooltip
* @return the complete tooltip
+ * @deprecated Override or call {@link #acceptAndUnchanged(String, boolean)} instead.
*/
+ @Deprecated
protected String acceptAndUnchanged(String value) {
+ return acceptAndUnchanged(value, false);
+ }
+
+ /**
+ * Create the final tooltip for an accepted change which don't lead to a modification of the specified
+ * side.
+ *
+ * @param value
+ * The body of the tooltip
+ * @param isLeftToRight
+ * the direction of the change.
+ * @return the complete tooltip
+ */
+ protected String acceptAndUnchanged(String value, boolean isLeftToRight) {
String accept = getString("ContextualTooltip.acceptChange"); //$NON-NLS-1$
- String modify = getString("ContextualTooltip.readonly.leftUnchanged"); //$NON-NLS-1$
+ String modify;
+ if (isLeftToRight) {
+ modify = getString("ContextualTooltip.readonly.rightUnchanged"); //$NON-NLS-1$
+ } else {
+ modify = getString("ContextualTooltip.readonly.leftUnchanged"); //$NON-NLS-1$
+ }
StringBuilder builder = new StringBuilder();
builder.append(accept).append(LINE_SEPARATOR).append(value).append(LINE_SEPARATOR).append(modify);
@@ -109,15 +199,35 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
}
/**
- * Create the final tooltip for a rejected change which lead to a modification of the left side.
+ * Create the final tooltip for a rejected change which leads to a modification of the left side.
*
* @param value
* The body of the tooltip
* @return the complete tooltip
+ * @deprecated Override or call {@link #rejectAndChanged(String, boolean)} instead.
*/
+ @Deprecated
protected String rejectAndChanged(String value) {
+ return rejectAndChanged(value, false);
+ }
+
+ /**
+ * Create the final tooltip for a rejected change which leads to a modification of the specified side.
+ *
+ * @param value
+ * The body of the tooltip
+ * @param isLeftToRight
+ * the direction of the change.
+ * @return the complete tooltip
+ */
+ protected String rejectAndChanged(String value, boolean isLeftToRight) {
String accept = getString("ContextualTooltip.rejectChange"); //$NON-NLS-1$
- String modify = getString("ContextualTooltip.readonly.leftChanged"); //$NON-NLS-1$
+ String modify;
+ if (isLeftToRight) {
+ modify = getString("ContextualTooltip.readonly.rightChanged"); //$NON-NLS-1$
+ } else {
+ modify = getString("ContextualTooltip.readonly.leftChanged"); //$NON-NLS-1$
+ }
StringBuilder builder = new StringBuilder();
builder.append(accept).append(LINE_SEPARATOR).append(value).append(LINE_SEPARATOR).append(modify);
@@ -125,15 +235,35 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
}
/**
- * Create the final tooltip for a rejected change which don't lead to a modification of the left side.
+ * Create the final tooltip for a rejected change which doesn't lead to a modification of the left side.
*
* @param value
* The body of the tooltip
* @return the complete tooltip
+ * @deprecated Override or call {@link #rejectAndUnchanged(String, boolean)} instead.
*/
+ @Deprecated
protected String rejectAndUnchanged(String value) {
+ return rejectAndUnchanged(value, false);
+ }
+
+ /**
+ * Create the final tooltip for a rejected change which don't lead to a modification of the left side.
+ *
+ * @param value
+ * The body of the tooltip
+ * @param isLeftToRight
+ * the direction of the change.
+ * @return the complete tooltip
+ */
+ protected String rejectAndUnchanged(String value, boolean isLeftToRight) {
String accept = getString("ContextualTooltip.rejectChange"); //$NON-NLS-1$
- String modify = getString("ContextualTooltip.readonly.leftUnchanged"); //$NON-NLS-1$
+ String modify;
+ if (isLeftToRight) {
+ modify = getString("ContextualTooltip.readonly.rightUnchanged"); //$NON-NLS-1$
+ } else {
+ modify = getString("ContextualTooltip.readonly.leftUnchanged"); //$NON-NLS-1$
+ }
StringBuilder builder = new StringBuilder();
builder.append(accept).append(LINE_SEPARATOR).append(value).append(LINE_SEPARATOR).append(modify);
@@ -245,10 +375,12 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
String value = getLabel(diff);
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.delete.nonContainment.left.leftToRight", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.delete.nonContainment.right.leftToRight", value); //$NON-NLS-1$
@@ -256,7 +388,7 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.delete.nonContainment.left.rightToLeft", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.delete.nonContainment.right.rightToLeft", value); //$NON-NLS-1$
@@ -264,21 +396,24 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.delete.nonContainment.left.accept", value); //$NON-NLS-1$
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.nonContainment.left.accept"), value); //$NON-NLS-1$
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.delete.nonContainment.right.accept", value); //$NON-NLS-1$
- tooltip = acceptAndChanged(body);
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.nonContainment.right.accept"), value); //$NON-NLS-1$
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
+ if (isFromLeft != isLeftToRight != mirrored) {
body = getString("ContextualTooltip.delete.nonContainment.left.reject", value); //$NON-NLS-1$
- tooltip = rejectAndChanged(body);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.delete.nonContainment.right.reject", value); //$NON-NLS-1$
- tooltip = rejectAndUnchanged(body);
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.nonContainment.right.reject"), value); //$NON-NLS-1$
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -302,10 +437,12 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
String value = getLabel(diff);
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.nonContainment.left.leftToRight", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.add.nonContainment.right.leftToRight", value); //$NON-NLS-1$
@@ -313,7 +450,7 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.nonContainment.left.rightToLeft", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.add.nonContainment.right.rightToLeft", value); //$NON-NLS-1$
@@ -321,21 +458,25 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.nonContainment.left.accept", value); //$NON-NLS-1$
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.nonContainment.left.accept"), value); //$NON-NLS-1$
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.nonContainment.right.accept", value); //$NON-NLS-1$
- tooltip = acceptAndChanged(body);
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.nonContainment.right.accept"), value); //$NON-NLS-1$
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.nonContainment.left.reject", value); //$NON-NLS-1$
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.nonContainment.left.reject"), value); //$NON-NLS-1$
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.nonContainment.right.reject", value); //$NON-NLS-1$
- tooltip = rejectAndUnchanged(body);
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.nonContainment.right.reject"), value); //$NON-NLS-1$
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -360,10 +501,12 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
String containerValue = getLabel(diff.getMatch());
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.move.position.left.leftToRight", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.move.position.right.leftToRight", value); //$NON-NLS-1$
@@ -371,7 +514,7 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.move.position.left.rightToLeft", value); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.move.position.right.rightToLeft", value); //$NON-NLS-1$
@@ -379,41 +522,52 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
+ if (isFromLeft != isLeftToRight != mirrored) {
// display container label only if the element is inside a container
if (diff instanceof ReferenceChange
&& ((ReferenceChange)diff).getReference().isContainment()) {
- body = getString("ContextualTooltip.move.position.left.container.accept", value, //$NON-NLS-1$
- containerValue);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.left.container.accept"), //$NON-NLS-1$
+ value, containerValue);
} else {
- body = getString("ContextualTooltip.move.position.left.accept", value); //$NON-NLS-1$
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.left.accept"), value); //$NON-NLS-1$
}
- tooltip = acceptAndUnchanged(body);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
if (diff instanceof ReferenceChange
&& ((ReferenceChange)diff).getReference().isContainment()) {
- body = getString("ContextualTooltip.move.position.right.container.accept", value, //$NON-NLS-1$
- containerValue);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.right.container.accept"), //$NON-NLS-1$
+ value, containerValue);
} else {
- body = getString("ContextualTooltip.move.position.right.accept", value); //$NON-NLS-1$
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.right.accept"), value); //$NON-NLS-1$
}
- tooltip = acceptAndChanged(body);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.move.position.left.reject", value); //$NON-NLS-1$
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.move.position.left.reject"), //$NON-NLS-1$
+ value);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
// display container label only if the element is inside a container
if (diff instanceof ReferenceChange
&& ((ReferenceChange)diff).getReference().isContainment()) {
- body = getString("ContextualTooltip.move.position.right.container.reject", value, //$NON-NLS-1$
- containerValue);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.right.container.reject"), //$NON-NLS-1$
+ value, containerValue);
} else {
- body = getString("ContextualTooltip.move.position.right.reject", value); //$NON-NLS-1$
+ body = getString(getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.move.position.right.reject"), value); //$NON-NLS-1$
}
- tooltip = rejectAndUnchanged(body);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -433,152 +587,126 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
* True if the modification come from the left side
* @return the tooltip
*/
+ // CHECKSTYLE:OFF
+ @SuppressWarnings("nls")
protected String setSetTooltip(MergeMode mode, T diff, boolean isFromLeft) {
- // compute the name of the structural feature modified
EStructuralFeature eStructuralFeature = MatchUtil.getStructuralFeature(diff);
+ Match match = diff.getMatch();
+ EObject left = match.getLeft();
+ EObject right = match.getRight();
+ String rightValue = getPreviousValue(eStructuralFeature, left);
+ String leftValue = getPreviousValue(eStructuralFeature, right);
- // The name of the container of the structural feature
- EObject left = diff.getMatch().getLeft();
- EObject right = diff.getMatch().getRight();
- String containerName = ""; //$NON-NLS-1$
- String rightValue = ""; //$NON-NLS-1$
- String leftValue = ""; //$NON-NLS-1$
-
+ String containerName = "";
if (isFromLeft && left != null) {
containerName = left.eClass().getName();
} else if (!isFromLeft && right != null) {
containerName = right.eClass().getName();
}
- if (left != null) {
- leftValue = getPreviousValue(eStructuralFeature, left);
- }
- if (right != null) {
- rightValue = getPreviousValue(eStructuralFeature, right);
- }
-
- return doSetTooltip(mode, isFromLeft, rightValue, leftValue, containerName, eStructuralFeature, diff);
- }
-
- /**
- * This method compute the tooltip with the given parameters.
- *
- * @param mode
- * The merge mode
- * @param isFromLeft
- * True if the change comes from left
- * @param rightValue
- * The value of the right element
- * @param leftValue
- * The value of the left element
- * @param containerName
- * The name of the container of the Set diff
- * @param eStructuralFeature
- * The structural feature set
- * @param diff
- * The diff
- * @return the tooltip
- */
- private String doSetTooltip(MergeMode mode, boolean isFromLeft, String rightValue, String leftValue,
- String containerName, EStructuralFeature eStructuralFeature, T diff) {
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
String tooltip;
String body;
String structuralFeatureName = eStructuralFeature.getName();
+ String effectiveLeft;
+ String effectiveRight;
+
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
- if ("".equals(rightValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.left.leftToRight.empty", //$NON-NLS-1$
- structuralFeatureName, containerName, leftValue);
-
+ case RIGHT_TO_LEFT:
+ String key = "ContextualTooltip.set.";
+ boolean isLeftToRightMode = mode == MergeMode.LEFT_TO_RIGHT;
+ String singleSideValue = null;
+ effectiveLeft = getDirectionalValue(mirrored != isLeftToRightMode, leftValue, rightValue);
+ effectiveRight = getDirectionalValue(mirrored != isLeftToRightMode, rightValue, leftValue);
+ if (isFromLeft != mirrored) {
+ if (isLeftToRightMode) {
+ key += "left.leftToRight";
} else {
- body = getString("ContextualTooltip.set.left.leftToRight", structuralFeatureName, //$NON-NLS-1$
- containerName, leftValue, rightValue);
+ key += "left.rightToLeft";
}
} else {
- // if previous value cannot be displayed
- if ("".equals(leftValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.right.leftToRight.empty", //$NON-NLS-1$
- structuralFeatureName, containerName, rightValue);
+ if (isLeftToRightMode) {
+ key += "right.leftToRight";
} else {
- body = getString("ContextualTooltip.set.right.leftToRight", structuralFeatureName, //$NON-NLS-1$
- containerName, leftValue, rightValue);
+ key += "right.rightToLeft";
}
}
- tooltip = rightChanged(body);
- break;
- case RIGHT_TO_LEFT:
- if (isFromLeft) {
- // if previous value cannot be displayed
- if ("".equals(rightValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.left.rightToLeft.empty", //$NON-NLS-1$
- structuralFeatureName, containerName, leftValue);
- } else {
- body = getString("ContextualTooltip.set.left.rightToLeft", structuralFeatureName, //$NON-NLS-1$
- containerName, rightValue, leftValue);
- }
+ if (effectiveLeft.isEmpty()) {
+ key += ".empty";
+ singleSideValue = effectiveRight;
+ } else if (effectiveRight.isEmpty()) {
+ key += ".empty";
+ singleSideValue = effectiveLeft;
+ }
+ if (singleSideValue != null) {
+ body = getString(key, structuralFeatureName, containerName, singleSideValue);
} else {
- if ("".equals(leftValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.right.rightToLeft.empty", //$NON-NLS-1$
- structuralFeatureName, containerName, rightValue);
- } else {
- body = getString("ContextualTooltip.set.right.rightToLeft", structuralFeatureName, //$NON-NLS-1$
- containerName, rightValue, leftValue);
- }
+ body = getString(key, structuralFeatureName, containerName, effectiveLeft,
+ effectiveRight);
+ }
+ if (isLeftToRightMode) {
+ tooltip = rightChanged(body);
+ } else {
+ tooltip = rightUnchanged(body);
}
- tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.set.left.accept", leftValue, structuralFeatureName, //$NON-NLS-1$
- containerName);
- tooltip = acceptAndUnchanged(body);
+ effectiveLeft = getDirectionalValue(isLeftToRight == mirrored, leftValue, rightValue);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.set.left.accept"),
+ effectiveLeft, structuralFeatureName, containerName);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- if ("".equals(leftValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.right.accept.empty", structuralFeatureName, //$NON-NLS-1$
- containerName, rightValue);
+ effectiveRight = getDirectionalValue(isLeftToRight == mirrored, rightValue, leftValue);
+ if (effectiveLeft.isEmpty()) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.right.accept.empty"),
+ structuralFeatureName, containerName, effectiveRight);
} else {
- body = getString("ContextualTooltip.set.right.accept", structuralFeatureName, //$NON-NLS-1$
- containerName, rightValue, leftValue);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.right.accept"),
+ structuralFeatureName, containerName, effectiveRight, effectiveLeft);
}
- tooltip = acceptAndChanged(body);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- // get the value of the structural feature in the origin side if it is a three way comparison,
- // get the value of the left side otherwise
- String previousValue;
- if (diff.getMatch().getComparison().isThreeWay()) {
- previousValue = getPreviousValue(eStructuralFeature, diff.getMatch().getOrigin());
- } else {
- previousValue = rightValue;
+ effectiveLeft = getDirectionalValue(isLeftToRight == mirrored, leftValue, rightValue);
+ effectiveRight = getDirectionalValue(isLeftToRight == mirrored, rightValue, leftValue);
+ String previousValue = null;
+ if (match.getComparison().isThreeWay()) {
+ previousValue = getPreviousValue(eStructuralFeature, match.getOrigin());
}
-
- if (isFromLeft) {
- // if previous value cannot be displayed
- if ("".equals(previousValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.left.reject.empty", structuralFeatureName, //$NON-NLS-1$
- containerName, leftValue);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ if (previousValue == null) {
+ previousValue = effectiveRight;
+ }
+ if (previousValue.isEmpty()) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.left.reject.empty"),
+ structuralFeatureName, containerName, effectiveLeft);
} else {
- body = getString("ContextualTooltip.set.left.reject", structuralFeatureName, //$NON-NLS-1$
- containerName, previousValue, leftValue);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.left.reject"),
+ structuralFeatureName, containerName, previousValue, effectiveLeft);
}
- tooltip = rejectAndChanged(body);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- if (diff.getMatch().getComparison().isThreeWay()) {
- previousValue = getPreviousValue(eStructuralFeature, diff.getMatch().getOrigin());
- } else {
- previousValue = leftValue;
+ if (previousValue == null) {
+ previousValue = effectiveLeft;
}
- // if previous value cannot be displayed
- if ("".equals(previousValue)) { //$NON-NLS-1$
- body = getString("ContextualTooltip.set.right.reject.empty", structuralFeatureName, //$NON-NLS-1$
- containerName);
- } else {
- body = getString("ContextualTooltip.set.right.reject", previousValue, //$NON-NLS-1$
+ if (previousValue.isEmpty()) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.right.reject.empty"),
structuralFeatureName, containerName);
+ } else {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.set.right.reject"),
+ previousValue, structuralFeatureName, containerName);
}
- tooltip = rejectAndUnchanged(body);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -586,6 +714,43 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
}
return tooltip;
}
+ // CHECKSTYLE:ON
+
+ /**
+ * Augments the key with a directional indicator to look up the correct message.
+ *
+ * @param isLeftToRight
+ * the direction of the change.
+ * @param key
+ * the key to augment.
+ * @return the appropriate key for the direction.
+ */
+ protected String getDirectionalKey(boolean isLeftToRight, String key) {
+ if (isLeftToRight) {
+ return key + ".leftToRight"; //$NON-NLS-1$
+ } else {
+ return key;
+ }
+ }
+
+ /**
+ * Returns either the left or right value, depending on the direction.
+ *
+ * @param isLeftToRight
+ * the direction.
+ * @param leftValue
+ * the left value.
+ * @param rightValue
+ * the right value.
+ * @return either the left or right value, depending on the direction.
+ */
+ protected String getDirectionalValue(boolean isLeftToRight, String leftValue, String rightValue) {
+ if (isLeftToRight) {
+ return rightValue;
+ } else {
+ return leftValue;
+ }
+ }
/**
* Compute the tooltip for the unset of a value.
@@ -607,17 +772,20 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
// The name of the container of the structural feature
String containerName = ""; //$NON-NLS-1$
- if (isFromLeft && diff.getMatch().getLeft() != null) {
- containerName = diff.getMatch().getLeft().eClass().getName();
- } else if (!isFromLeft && diff.getMatch().getRight() != null) {
- containerName = diff.getMatch().getRight().eClass().getName();
+ Match match = diff.getMatch();
+ if (isFromLeft && match.getLeft() != null) {
+ containerName = match.getLeft().eClass().getName();
+ } else if (!isFromLeft && match.getRight() != null) {
+ containerName = match.getRight().eClass().getName();
}
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.unset.left.leftToRight", structuralFeatureName, //$NON-NLS-1$
containerName, value);
} else {
@@ -627,7 +795,7 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.unset.left.rightToLeft", structuralFeatureName, //$NON-NLS-1$
containerName, value);
} else {
@@ -637,25 +805,25 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.unset.left.accept", structuralFeatureName, //$NON-NLS-1$
- containerName);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.unset.left.accept"), //$NON-NLS-1$
+ structuralFeatureName, containerName);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.unset.right.accept", structuralFeatureName, //$NON-NLS-1$
- containerName, value);
- tooltip = acceptAndChanged(body);
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.unset.right.accept"), //$NON-NLS-1$
+ structuralFeatureName, containerName, value);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.unset.left.reject", structuralFeatureName, //$NON-NLS-1$
- containerName, value);
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.unset.left.reject"), //$NON-NLS-1$
+ structuralFeatureName, containerName, value);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.unset.right.reject", structuralFeatureName, //$NON-NLS-1$
- containerName, value);
- tooltip = rejectAndUnchanged(body);
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.unset.right.reject"), //$NON-NLS-1$
+ structuralFeatureName, containerName, value);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -693,9 +861,11 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
String body;
String tooltip;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rlc.left.leftToRight", newValue); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.rlc.right.leftToRight", oldValue); //$NON-NLS-1$
@@ -703,7 +873,7 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rlc.left.rightToLeft", oldValue); //$NON-NLS-1$
} else {
body = getString("ContextualTooltip.rlc.right.rightToLeft", newValue); //$NON-NLS-1$
@@ -711,21 +881,25 @@ public abstract class AbstractTooltipProvider<T extends Diff> extends AdapterImp
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.rlc.left.accept", newValue); //$NON-NLS-1$
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.rlc.left.accept"), //$NON-NLS-1$
+ newValue);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.rlc.right.accept", newValue); //$NON-NLS-1$
- tooltip = acceptAndChanged(body);
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.rlc.right.accept"), //$NON-NLS-1$
+ newValue);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.rlc.left.reject", oldValue); //$NON-NLS-1$
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.rlc.left.reject"), //$NON-NLS-1$
+ oldValue);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.rlc.right.reject", oldValue); //$NON-NLS-1$
- tooltip = rejectAndUnchanged(body);
+ body = getString(getDirectionalKey(isLeftToRight, "ContextualTooltip.rlc.right.reject"), //$NON-NLS-1$
+ oldValue);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AttributeChangeTooltipProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AttributeChangeTooltipProvider.java
index e7b8d518e..e3da69725 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AttributeChangeTooltipProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/AttributeChangeTooltipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 Obeo.
+ * Copyright (c) 2015, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.tooltip;
@@ -95,7 +96,11 @@ public class AttributeChangeTooltipProvider extends AbstractTooltipProvider<Attr
if (changedContainer == null) {
return null;
}
- return String.valueOf(safeEGet(changedContainer, attribute));
+ Object value = safeEGet(changedContainer, attribute);
+ if (value == null) {
+ return null;
+ }
+ return value.toString();
}
/**
@@ -131,9 +136,11 @@ public class AttributeChangeTooltipProvider extends AbstractTooltipProvider<Attr
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.attribute.left.leftToRight", value, //$NON-NLS-1$
containerValue);
} else {
@@ -143,7 +150,7 @@ public class AttributeChangeTooltipProvider extends AbstractTooltipProvider<Attr
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.attribute.left.rightToLeft", value, //$NON-NLS-1$
containerValue);
} else {
@@ -153,25 +160,29 @@ public class AttributeChangeTooltipProvider extends AbstractTooltipProvider<Attr
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.attribute.left.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.attribute.left.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.attribute.right.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.attribute.right.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.attribute.left.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.attribute.left.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.attribute.right.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.attribute.right.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ReferenceChangeTooltipProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ReferenceChangeTooltipProvider.java
index 3305473b5..9f92ab6ec 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ReferenceChangeTooltipProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ReferenceChangeTooltipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.tooltip;
@@ -137,22 +138,30 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
*/
private boolean isContainerMove(boolean isFromLeft, EObject origin, EObject right, EObject left) {
boolean isContainerMove = false;
- if (isFromLeft) {
- if (left != null && origin != null) {
+ if (origin == null) {
+ if (left != null && right != null) {
+ if (left.eContainingFeature() != right.eContainingFeature()
+ || !getLabelFromObject(left.eContainer())
+ .equals(getLabelFromObject(right.eContainer()))) {
+ isContainerMove = true;
+ }
+ }
+ } else if (isFromLeft) {
+ if (left != null) {
// if the label of the container of an element is different of the label of its ancestor
// or if the containing feature between an element and its container are different
// We consider that it is a container move
- if (!getLabelFromObject(left.eContainer()).equals(getLabelFromObject(origin.eContainer()))
- || left.eContainingFeature() != origin.eContainingFeature()) {
+ if (left.eContainingFeature() != origin.eContainingFeature()
+ || !getLabelFromObject(left.eContainer())
+ .equals(getLabelFromObject(origin.eContainer()))) {
isContainerMove = true;
}
}
- } else {
- if (right != null && origin != null) {
- if (!getLabelFromObject(right.eContainer()).equals(getLabelFromObject(origin.eContainer()))
- || right.eContainingFeature() != origin.eContainingFeature()) {
- isContainerMove = true;
- }
+ } else if (right != null) {
+ if (right.eContainingFeature() != origin.eContainingFeature()
+ || !getLabelFromObject(right.eContainer())
+ .equals(getLabelFromObject(origin.eContainer()))) {
+ isContainerMove = true;
}
}
return isContainerMove;
@@ -175,69 +184,95 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
* The modified element in the left model
* @return the tooltip
*/
+ @SuppressWarnings("nls")
private String setMoveContainerTooltip(MergeMode mode, ReferenceChange diff, boolean isFromLeft,
EObject left, EObject right, EObject ancestor) {
String value = getLabel(diff);
- String leftContainerValue = ""; //$NON-NLS-1$
+ String leftContainerValue = "";
if (left != null) {
leftContainerValue = getLabelFromObject(left.eContainer());
}
- String rightContainerValue = ""; //$NON-NLS-1$
+ String rightContainerValue = "";
if (right != null) {
rightContainerValue = getLabelFromObject(right.eContainer());
}
- String ancestorContainerValue;
- if (diff.getMatch().getComparison().isThreeWay() && ancestor != null) {
- ancestorContainerValue = getLabelFromObject(ancestor.eContainer());
- } else {
- ancestorContainerValue = rightContainerValue;
- }
-
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
+ String effectiveLeft;
+ String effectiveRight;
+
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.move.container.left.leftToRight", value, //$NON-NLS-1$
- leftContainerValue, rightContainerValue);
+ case RIGHT_TO_LEFT:
+ String key = "ContextualTooltip.move.container.";
+ boolean isLeftToRightMode = mode == MergeMode.LEFT_TO_RIGHT;
+ effectiveLeft = getDirectionalValue(mirrored == isLeftToRightMode, leftContainerValue,
+ rightContainerValue);
+ effectiveRight = getDirectionalValue(mirrored == isLeftToRightMode, rightContainerValue,
+ leftContainerValue);
+ if (isFromLeft != mirrored) {
+ if (isLeftToRightMode) {
+ key += "left.leftToRight";
+ } else {
+ key += "left.rightToLeft";
+ }
} else {
- body = getString("ContextualTooltip.move.container.right.leftToRight", value, //$NON-NLS-1$
- leftContainerValue, rightContainerValue);
+ if (isLeftToRightMode) {
+ key += "right.leftToRight";
+ } else {
+ key += "right.rightToLeft";
+ }
}
- tooltip = rightChanged(body);
- break;
- case RIGHT_TO_LEFT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.move.container.left.rightToLeft", value, //$NON-NLS-1$
- rightContainerValue, leftContainerValue);
+ body = getString(key, value, effectiveLeft, effectiveRight);
+ if (isLeftToRightMode) {
+ tooltip = rightChanged(body);
} else {
- body = getString("ContextualTooltip.move.container.right.rightToLeft", value, //$NON-NLS-1$
- rightContainerValue, leftContainerValue);
+ tooltip = rightUnchanged(body);
}
- tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.move.container.left.accept", value, //$NON-NLS-1$
- leftContainerValue);
- tooltip = acceptAndUnchanged(body);
+ effectiveLeft = getDirectionalValue(isLeftToRight == mirrored, leftContainerValue,
+ rightContainerValue);
+ effectiveRight = getDirectionalValue(isLeftToRight == mirrored, rightContainerValue,
+ leftContainerValue);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.move.container.left.accept"),
+ value, effectiveRight);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.move.container.right.accept", value, //$NON-NLS-1$
- rightContainerValue, leftContainerValue);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.move.container.right.accept"),
+ value, effectiveLeft, effectiveRight);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.move.container.left.reject", value, //$NON-NLS-1$
- ancestorContainerValue, leftContainerValue);
- tooltip = rejectAndChanged(body);
+ effectiveLeft = getDirectionalValue(isLeftToRight == mirrored, leftContainerValue,
+ rightContainerValue);
+ effectiveRight = getDirectionalValue(isLeftToRight == mirrored, rightContainerValue,
+ leftContainerValue);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ String previousValue = null;
+ if (diff.getMatch().getComparison().isThreeWay() && ancestor != null) {
+ previousValue = getLabelFromObject(ancestor.eContainer());
+ } else {
+ previousValue = effectiveLeft;
+ }
+
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.move.container.left.reject"),
+ value, previousValue, effectiveRight);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.move.container.right.reject", value, //$NON-NLS-1$
- leftContainerValue);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.move.container.right.reject"),
+ value, effectiveRight);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -263,9 +298,11 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.delete.containment.left.leftToRight", value, //$NON-NLS-1$
containerValue);
} else {
@@ -275,7 +312,7 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.delete.containment.left.rightToLeft", value, //$NON-NLS-1$
containerValue);
} else {
@@ -285,25 +322,33 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.delete.containment.left.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.containment.left.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.delete.containment.right.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.containment.right.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.delete.containment.left.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.containment.left.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.delete.containment.right.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.delete.containment.right.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -329,9 +374,11 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.containment.left.leftToRight", value, //$NON-NLS-1$
containerValue);
} else {
@@ -341,7 +388,7 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.add.containment.left.rightToLeft", value, //$NON-NLS-1$
containerValue);
} else {
@@ -351,25 +398,31 @@ public class ReferenceChangeTooltipProvider extends AbstractTooltipProvider<Refe
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.containment.left.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.containment.left.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.containment.right.accept", value, //$NON-NLS-1$
- containerValue);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.containment.right.accept"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.add.containment.left.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndChanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.add.containment.left.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.add.containment.right.reject", value, //$NON-NLS-1$
- containerValue);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight,
+ "ContextualTooltip.add.containment.right.reject"), //$NON-NLS-1$
+ value, containerValue);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceAttachmentChangeTooltipProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceAttachmentChangeTooltipProvider.java
index 4510b1669..d69eddbce 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceAttachmentChangeTooltipProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceAttachmentChangeTooltipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 Obeo.
+ * Copyright (c) 2015, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.tooltip;
@@ -86,70 +87,69 @@ public class ResourceAttachmentChangeTooltipProvider extends AbstractTooltipProv
EObject right = diff.getMatch().getRight();
EObject origin = diff.getMatch().getOrigin();
- String leftUri = ""; //$NON-NLS-1$
- if (left != null) {
- leftUri = left.eResource().getURI().toString();
- }
-
- String rightUri = ""; //$NON-NLS-1$
- if (right != null) {
- rightUri = right.eResource().getURI().toString();
- }
-
- String originUri = ""; //$NON-NLS-1$
- if (origin != null) {
- originUri = origin.eResource().getURI().toString();
- }
+ String leftUri = getResourceUri(left);
+ String rightUri = getResourceUri(right);
+ String originUri = getResourceUri(origin);
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
+ String effectiveLeft;
+ String effectiveRight;
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ effectiveLeft = getDirectionalValue(mirrored, leftUri, rightUri);
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rac.control.left.leftToRight", value, //$NON-NLS-1$
- leftUri);
+ effectiveLeft);
} else {
body = getString("ContextualTooltip.rac.control.right.leftToRight", value, //$NON-NLS-1$
- leftUri);
+ effectiveLeft);
}
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ effectiveRight = getDirectionalValue(mirrored, rightUri, leftUri);
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rac.control.left.rightToLeft", value, //$NON-NLS-1$
- rightUri);
+ effectiveRight);
} else {
body = getString("ContextualTooltip.rac.control.right.rightToLeft", value, //$NON-NLS-1$
- rightUri);
+ effectiveRight);
}
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.rac.control.left.accept", value, //$NON-NLS-1$
- leftUri);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.control.left.accept"), //$NON-NLS-1$
+ value, leftUri);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.rac.control.right.accept", value, //$NON-NLS-1$
- rightUri);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.control.right.accept"), //$NON-NLS-1$
+ value, rightUri);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
- if (isFromLeft) {
- if (originUri == null || "".equals(originUri)) { //$NON-NLS-1$
+ if (isFromLeft != isLeftToRight != mirrored) {
+ if (originUri.isEmpty()) {
originUri = leftUri;
}
- body = getString("ContextualTooltip.rac.control.left.reject", value, //$NON-NLS-1$
- originUri);
- tooltip = rejectAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.control.left.reject"), //$NON-NLS-1$
+ value, originUri);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- if (originUri == null || "".equals(originUri)) { //$NON-NLS-1$
+ if (originUri.isEmpty()) {
originUri = rightUri;
}
- body = getString("ContextualTooltip.rac.control.right.reject", value, //$NON-NLS-1$
- originUri);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.control.right.reject"), //$NON-NLS-1$
+ value, originUri);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
@@ -181,54 +181,64 @@ public class ResourceAttachmentChangeTooltipProvider extends AbstractTooltipProv
String tooltip;
String body;
+ boolean mirrored = isMirrored(diff);
+ boolean isLeftToRight = isLeftToRight(diff, mode);
+ String effectiveLeft;
+ String effectiveRight;
switch (mode) {
case LEFT_TO_RIGHT:
- if (isFromLeft) {
+ effectiveLeft = getDirectionalValue(mirrored, leftUri, rightUri);
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rac.uncontrol.left.leftToRight", value, //$NON-NLS-1$
- leftUri);
+ effectiveLeft);
} else {
body = getString("ContextualTooltip.rac.uncontrol.right.leftToRight", value, //$NON-NLS-1$
- leftUri);
+ effectiveLeft);
}
tooltip = rightChanged(body);
break;
case RIGHT_TO_LEFT:
- if (isFromLeft) {
+ effectiveRight = getDirectionalValue(mirrored, rightUri, leftUri);
+ if (isFromLeft != mirrored) {
body = getString("ContextualTooltip.rac.uncontrol.left.rightToLeft", value, //$NON-NLS-1$
- rightUri);
+ effectiveRight);
} else {
body = getString("ContextualTooltip.rac.uncontrol.right.rightToLeft", value, //$NON-NLS-1$
- rightUri);
+ effectiveRight);
}
tooltip = rightUnchanged(body);
break;
case ACCEPT:
- if (isFromLeft) {
- body = getString("ContextualTooltip.rac.uncontrol.left.accept", value, //$NON-NLS-1$
- leftUri);
- tooltip = acceptAndUnchanged(body);
+ if (isFromLeft != isLeftToRight != mirrored) {
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.uncontrol.left.accept"), //$NON-NLS-1$
+ value, leftUri);
+ tooltip = acceptAndUnchanged(body, isLeftToRight);
} else {
- body = getString("ContextualTooltip.rac.uncontrol.right.accept", value, //$NON-NLS-1$
- rightUri);
- tooltip = acceptAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.uncontrol.right.accept"), //$NON-NLS-1$
+ value, rightUri);
+ tooltip = acceptAndChanged(body, isLeftToRight);
}
break;
case REJECT:
String originUri = getResourceUri(origin);
- if (isFromLeft) {
- if ("".equals(originUri)) { //$NON-NLS-1$
+ if (isFromLeft != isLeftToRight != mirrored) {
+ if (originUri.isEmpty()) {
originUri = rightUri;
}
- body = getString("ContextualTooltip.rac.uncontrol.left.reject", value, //$NON-NLS-1$
- originUri);
- tooltip = rejectAndChanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.uncontrol.left.reject"), //$NON-NLS-1$
+ value, originUri);
+ tooltip = rejectAndChanged(body, isLeftToRight);
} else {
- if ("".equals(originUri)) { //$NON-NLS-1$
+ if (originUri.isEmpty()) {
originUri = leftUri;
}
- body = getString("ContextualTooltip.rac.uncontrol.right.reject", value, //$NON-NLS-1$
- originUri);
- tooltip = rejectAndUnchanged(body);
+ body = getString(
+ getDirectionalKey(isLeftToRight, "ContextualTooltip.rac.uncontrol.right.reject"), //$NON-NLS-1$
+ value, originUri);
+ tooltip = rejectAndUnchanged(body, isLeftToRight);
}
break;
default:
diff --git a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceLocationChangeTooltipProvider.java b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceLocationChangeTooltipProvider.java
index fd3a09971..7d531e1d6 100644
--- a/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceLocationChangeTooltipProvider.java
+++ b/plugins/org.eclipse.emf.compare.edit/src/org/eclipse/emf/compare/tooltip/ResourceLocationChangeTooltipProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015, 2016 Obeo.
+ * Copyright (c) 2015, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.tooltip;
@@ -42,7 +43,8 @@ public class ResourceLocationChangeTooltipProvider extends AbstractTooltipProvid
public String getTooltip(MergeMode mode) throws IllegalArgumentException {
String tooltip = ""; //$NON-NLS-1$
ResourceLocationChange diff = (ResourceLocationChange)target;
- if (diff.getKind().equals(DifferenceKind.CHANGE) || diff.getKind().equals(DifferenceKind.MOVE)) {
+ DifferenceKind kind = diff.getKind();
+ if (kind == DifferenceKind.CHANGE || kind == DifferenceKind.MOVE) {
tooltip = setResourceLocationChangeTooltip(mode, diff, isFromLeft(diff));
} else {
throw new IllegalArgumentException();
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/MirroredMergeActionTest.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/MirroredMergeActionTest.java
index dbd7fdc8c..050cbfb79 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/MirroredMergeActionTest.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/structuremergeviewer/actions/MirroredMergeActionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
+ * Copyright (c) 2017, 2018 EclipseSource Services GmbH and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Tobias Ortmayr - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions;
@@ -90,9 +91,8 @@ public class MirroredMergeActionTest {
IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, originResource);
Comparison comparision = EMFCompare.builder().build().compare(scope);
- // create merge action and set the mirror state to true
+ // create merge action
final MockMergeAction mergeAction = new MockMergeAction(emfCC, mergerRegistry, actionMergeMode, null);
- mergeAction.setMirrored(true);
// get the first left difference from the comparison, ensure that its unresolved and invoke the
// action.
@@ -122,9 +122,8 @@ public class MirroredMergeActionTest {
IComparisonScope scope = new DefaultComparisonScope(leftResource, rightResource, originResource);
Comparison comparision = EMFCompare.builder().build().compare(scope);
- // create merge action and set the mirror state to true
+ // create merge action
final MockMergeAction mergeAction = new MockMergeAction(emfCC, mergerRegistry, actionMergeMode, null);
- mergeAction.setMirrored(true);
// get the first left difference from the comparison, ensure that its unresolved and invoke the
// action.
@@ -146,7 +145,6 @@ public class MirroredMergeActionTest {
final MergeAllNonConflictingAction mergeAcion = new MergeAllNonConflictingAction(emfCC, comparison,
mergerRegistry, actionMergeMode);
- mergeAcion.setMirrored(true);
// get amount of unresolved left & right diffs
int leftDiffAmount = size(filter(comparison.getDifferences(),
@@ -173,7 +171,6 @@ public class MirroredMergeActionTest {
final MergeAllNonConflictingAction mergeAcion = new MergeAllNonConflictingAction(emfCC, comparison,
mergerRegistry, actionMergeMode);
- mergeAcion.setMirrored(true);
// get amount of unresolved left & right diffs
int leftDiffAmount = size(filter(comparison.getDifferences(),
@@ -240,6 +237,7 @@ public class MirroredMergeActionTest {
private IEMFCompareConfiguration createConfiguration(boolean leftEditable, boolean rightEditable) {
CompareConfiguration cc = new CompareConfiguration();
+ cc.setProperty(EMFCompareConfiguration.MIRRORED, Boolean.TRUE);
cc.setLeftEditable(leftEditable);
cc.setRightEditable(rightEditable);
EMFCompareConfiguration emfCC = new EMFCompareConfiguration(cc);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/plugin.properties b/plugins/org.eclipse.emf.compare.ide.ui/plugin.properties
index 2bc181690..0b77e3b29 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/plugin.properties
+++ b/plugins/org.eclipse.emf.compare.ide.ui/plugin.properties
@@ -23,6 +23,7 @@ emf.compare.wait.viewer= Please wait...
emf.compare.no.selected.item.viewer= No selected item
emf.compare.no.differences.viewer= No differences
emf.compare.no.visible.item.viewer= No visible item
+emf.compare.only.pseudo.conflicts.viewer= Only Pseudo-conflicts
command.each.other.in.dialog = Each Other <EObject> (in Dialog)
command.each.other.in.editor = Each Other <EObject> (in Editor)
command.each.other.emfComparisonSource = Each Other (EMF Compare)
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/EMFCompareConfiguration.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/EMFCompareConfiguration.java
index e58a36565..5eb77a753 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/EMFCompareConfiguration.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/EMFCompareConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 Obeo and others.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -11,6 +11,7 @@
* Martin Fleck - bug 483798
* Martin Fleck - bug 514415
* Tobias Ortmayr - bug 516248
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.configuration;
@@ -90,6 +91,13 @@ public class EMFCompareConfiguration extends ForwardingCompareConfiguration impl
public static final String DISPLAY_SELECT_UNRESOLVED_DIFF_ACTIONS = EMFCompareIDEUIPlugin.PLUGIN_ID
+ ".DISPLAY_SELECT_UNRESOLVED_DIFF_ACTIONS";//$NON-NLS-1$
+ /**
+ * This property name is equivalent to {@link CompareConfiguration#MIRRORED} however we redefine it for
+ * backwards compatibility.
+ */
+ @SuppressWarnings("hiding")
+ public static final String MIRRORED = "MIRRORED"; //$NON-NLS-1$
+
private final PropertyChangeListener propertyChangeListener;
private final CompareConfiguration compareConfiguration;
@@ -166,7 +174,7 @@ public class EMFCompareConfiguration extends ForwardingCompareConfiguration impl
@Override
public void dispose() {
super.dispose();
- compareConfiguration.removePropertyChangeListener(propertyChangeListener);
+ disposeSelf();
// CompareConfiguration does not clear its properties list...
// Lets clean our own mess ourselves
// EVENT_BUS must not be set to null
@@ -184,6 +192,16 @@ public class EMFCompareConfiguration extends ForwardingCompareConfiguration impl
compareConfiguration.setProperty(DISPLAY_SELECT_UNRESOLVED_DIFF_ACTIONS, null);
}
+ /**
+ * {@link #dispose()} is only called when the comparison editor is closed, whereas EMFCompareConfiguration
+ * are created and discarded on each change of the ContentMergeViewer input. This will be called to
+ * dispose of the specific setup that was made by the EMFCompareConfiguration wrapper to its underlying
+ * CompareConfiguration.
+ */
+ public void disposeSelf() {
+ compareConfiguration.removePropertyChangeListener(propertyChangeListener);
+ }
+
public boolean getBooleanProperty(String key, boolean dflt) {
final boolean ret;
Object value = getProperty(key);
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/ForwardingCompareConfiguration.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/ForwardingCompareConfiguration.java
index 9375ac3ed..2fffee0df 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/ForwardingCompareConfiguration.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/configuration/ForwardingCompareConfiguration.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.configuration;
@@ -247,7 +248,22 @@ public abstract class ForwardingCompareConfiguration extends CompareConfiguratio
*/
// @Override -- remove annotation for backwards-compatibility
public boolean isMirrored() {
- Object property = getProperty("MIRRORED"); //$NON-NLS-1$
+ Object property = getProperty(EMFCompareConfiguration.MIRRORED);
return property instanceof Boolean && ((Boolean)property).booleanValue();
}
+
+ /**
+ * A property change listener that listens specifically for the property indicating that compare
+ * configuration's {@link ForwardingCompareConfiguration#isMirrored()isMirrored} value has changed.
+ */
+ public abstract static class MirroredPropertyChangeListener implements IPropertyChangeListener {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (EMFCompareConfiguration.MIRRORED.equals(event.getProperty())) {
+ Object newValue = event.getNewValue();
+ mirroredPropertyChanged(Boolean.TRUE.equals(newValue));
+ }
+ }
+
+ protected abstract void mirroredPropertyChanged(boolean mirrored);
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java
index 351f2eda0..97d14e3a6 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/EMFCompareContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 Obeo and others.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -9,7 +9,7 @@
* Obeo - initial API and implementation
* Michael Borkowski - bug 462863
* Stefan Dirix - bug 473985
- * Philip Langer - bug 516645, 521948, 527567
+ * Philip Langer - bug 516645, 521948, 527567, 514079
* Martin Fleck - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer;
@@ -24,6 +24,8 @@ import java.util.Map;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
import org.eclipse.compare.internal.CompareHandlerService;
import org.eclipse.core.runtime.IAdaptable;
@@ -64,11 +66,12 @@ import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -139,7 +142,9 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
private MergeResolutionManager mergeResolutionManager;
- private Boolean fIsMirrored;
+ private IPropertyChangeListener propertyChangeListener;
+
+ private MirrorManager mirrorManager;
/**
* @param style
@@ -164,6 +169,25 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
mergeResolutionManager = new MergeResolutionManager(
EMFCompareIDEUIPlugin.getDefault().getMergeResolutionListenerRegistry());
+
+ propertyChangeListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ handlePropertyChangeEvent(event);
+ }
+ };
+
+ getCompareConfiguration().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
+
+ mirrorManager = new MirrorManager(cc);
+ }
+
+ @Override
+ public void setContentProvider(IContentProvider contentProvider) {
+ if (mirrorManager != null) {
+ super.setContentProvider(mirrorManager.getContentProvider(contentProvider));
+ } else {
+ super.setContentProvider(contentProvider);
+ }
}
@Subscribe
@@ -316,10 +340,10 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
fAncestor = createMergeViewer(composite, MergeViewerSide.ANCESTOR);
fAncestor.addSelectionChangedListener(this);
- fLeft = createMergeViewer(composite, MergeViewerSide.LEFT);
+ fLeft = createMergeViewer(composite, getEffectiveSide(MergeViewerSide.LEFT));
fLeft.addSelectionChangedListener(this);
- fRight = createMergeViewer(composite, MergeViewerSide.RIGHT);
+ fRight = createMergeViewer(composite, getEffectiveSide(MergeViewerSide.RIGHT));
fRight.addSelectionChangedListener(this);
final ITheme currentTheme = getCurrentTheme();
@@ -340,6 +364,20 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
}
/**
+ * Returns the effective side taking into account {@link CompareConfiguration#isMirrored()} to switch left
+ * and right.
+ *
+ * @param side
+ * @return the effective side with respect to mirroring.
+ */
+ protected MergeViewerSide getEffectiveSide(MergeViewerSide side) {
+ if (side != null && getCompareConfiguration().isMirrored()) {
+ return side.opposite();
+ }
+ return side;
+ }
+
+ /**
* Determines the current used theme.
*
* @return The currently used theme if available, {@code null} otherwise.
@@ -364,12 +402,6 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
getHandlerService().setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction);
getHandlerService().setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction);
- // switch left and right view action, may be null -> set the initial toggle state of the button
- Action switchLeftAndRightAction = MirrorUtil.getAction(this);
- if (switchLeftAndRightAction != null) {
- switchLeftAndRightAction.setChecked(isMirrored());
- }
-
IContributionItem[] items = toolBarManager.getItems();
for (IContributionItem iContributionItem : items) {
if (iContributionItem instanceof ActionContributionItem) {
@@ -388,6 +420,12 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
IServiceLocator workbench = PlatformUI.getWorkbench();
final IMenuService menuService = (IMenuService)workbench.getService(IMenuService.class);
if (menuService != null) {
+
+ // This is kind of a hack, but the code below will materialize all the SWT tool items and
+ // unless the check state is set on the actions, the right style of tool item won't be
+ // created.
+ updateToolItems();
+
menuService.populateContributionManager(toolBarManager,
"toolbar:org.eclipse.emf.compare.contentmergeviewer.toolbar"); //$NON-NLS-1$
toolBarManager.getControl().addDisposeListener(new DisposeListener() {
@@ -469,9 +507,11 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
final Collection<?> affectedObjects = command.getAffectedObjects();
if (affectedObjects != null && !affectedObjects.isEmpty()) {
Object firstAffectedObject = affectedObjects.iterator().next();
- if (firstAffectedObject.equals(getElement(leftSelection, MergeViewerSide.LEFT))) {
+ if (firstAffectedObject
+ .equals(getElement(leftSelection, getEffectiveSide(MergeViewerSide.LEFT)))) {
viewer = leftMergeViewer;
- } else if (firstAffectedObject.equals(getElement(leftSelection, MergeViewerSide.RIGHT))) {
+ } else if (firstAffectedObject
+ .equals(getElement(leftSelection, getEffectiveSide(MergeViewerSide.RIGHT)))) {
viewer = this.getRightMergeViewer();
} else if (firstAffectedObject.equals(getElement(leftSelection, MergeViewerSide.ANCESTOR))) {
viewer = this.getAncestorMergeViewer();
@@ -826,8 +866,11 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
*/
@Override
protected void handleDispose(DisposeEvent event) {
- editingDomainChange(getCompareConfiguration().getEditingDomain(), null);
- getCompareConfiguration().getEventBus().unregister(this);
+ EMFCompareConfiguration compareConfiguration = getCompareConfiguration();
+ editingDomainChange(compareConfiguration.getEditingDomain(), null);
+ compareConfiguration.getEventBus().unregister(this);
+ compareConfiguration.getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
+ compareConfiguration.disposeSelf();
differenceGroupProvider = null;
undoAction = null;
redoAction = null;
@@ -863,64 +906,37 @@ public abstract class EMFCompareContentMergeViewer extends ContentMergeViewer im
}
/**
- * Queries the compare configuration whether the left and right side of the viewer should be mirrored.
- *
- * @return true if the left and right side of the viewer should be mirrored, false otherwise
- */
- protected boolean isMirrored() {
- return MirrorUtil.isMirrored(getCompareConfiguration());
- }
-
- /**
- * Returns the correctly mirrored side for this viewer based on the current {@link #isMirrored() mirrored
- * state}. If this viewer is not mirrored, the side is returned as is, otherwise its opposite site is
- * returned.
- *
- * @param side
- * merge viewer side
- * @return side to be used based on the current mirror state.
- */
- protected MergeViewerSide computeSide(MergeViewerSide side) {
- if (isMirrored()) {
- return side.opposite();
- }
- return side;
- }
-
- /**
- * Returns the content provider that should be used when this viewer is NOT {@link #isMirrored()
- * mirrored}.
- *
- * @return unmirrored content provider
- */
- protected abstract IContentProvider getUnmirroredContentProvider();
-
- /**
- * Returns the content provider that should be used when this viewer is {@link #isMirrored() mirrored}.
- *
- * @return mirrored content provider
- */
- protected abstract IContentProvider getMirroredContentProvider();
-
- /**
- * Sets the viewers {@link #isMirrored() mirrored} state and triggers an {@link #updateMirrored(boolean)
- * update}, if necessary.
+ * {@inheritDoc}
+ * <p>
+ * This override uses a {@link MirrorManager} to intercept switches to the swap preference for controlling
+ * the mirror mode. When that preference property changes, {@link #handleMirroredChanged()} is called.
+ * </p>
*/
- protected void setMirrored(boolean isMirrored) {
- if (fIsMirrored == null || fIsMirrored.booleanValue() != isMirrored) {
- fIsMirrored = Boolean.valueOf(isMirrored);
- updateMirrored(isMirrored);
+ @Override
+ protected void handlePropertyChangeEvent(PropertyChangeEvent event) {
+ if (mirrorManager != null && mirrorManager.handlePropertyChangeEvent(event)) {
+ handleMirroredChanged();
+ } else {
+ super.handlePropertyChangeEvent(event);
}
}
/**
- * Updates the viewer based on its {@link #isMirrored() mirrored} state.
+ * This does the processing
*/
- protected void updateMirrored(boolean isMirrored) {
- if (isMirrored) {
- setContentProvider(getMirroredContentProvider());
- } else {
- setContentProvider(getUnmirroredContentProvider());
+ protected void handleMirroredChanged() {
+ Composite parent = getControl().getParent();
+ if (parent instanceof CompareViewerSwitchingPane) {
+ // Disable painting during the switching to avoid flicker of the toolbar and other controls.
+ parent.setRedraw(false);
+ try {
+ CompareViewerSwitchingPane switchingPane = (CompareViewerSwitchingPane)parent;
+ Object input = switchingPane.getInput();
+ switchingPane.setInput(null);
+ switchingPane.setInput(input);
+ } finally {
+ parent.setRedraw(true);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorManager.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorManager.java
new file mode 100644
index 000000000..72dddd4ae
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorManager.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2018 EclipseSource and others.
+ * 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:
+ * Philip Langer - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
+import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.MergeViewerContentProvider;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A manager class for handling the switching of the mirrored mode for each specialized
+ * {@link ContentMergeViewer} and {@link TextMergeViewer} in EMF Compare,
+ */
+public class MirrorManager {
+ /**
+ * The compare configuration used by the merge viewer.
+ */
+ private final EMFCompareConfiguration configuration;
+
+ /**
+ * The first content provider that's set while this manager is managing the content providers. We keep
+ * track of this because org.eclipse.compare.contentmergeviewer.ContentMergeViewer.updateContentProvider()
+ * replace our content provider with a default one.
+ */
+ private IContentProvider managedContentProvider;
+
+ /**
+ * The mirror of the first content provider that's set while this manager is managing the content
+ * providers.
+ */
+ private IContentProvider mirroredManagedContentProvider;
+
+ /**
+ * Creates an instance for this confirmation.
+ *
+ * @param configuration
+ * the EMF compare configuration.
+ */
+ public MirrorManager(EMFCompareConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ /**
+ * Returns the appropriate content provider based on the current state of
+ * {@link EMFCompareConfiguration#isMirrored()}.
+ * <p>
+ * This method should be used in overrides of
+ * {@link ContentMergeViewer#setContentProvider(IContentProvider)} to automatically set the correctly
+ * mirrored content provider.
+ * </p>
+ *
+ * @param contentProvider
+ * the current content provider.
+ * @return the appropriate content provider based on the current mirroring state.
+ */
+ public IContentProvider getContentProvider(IContentProvider contentProvider) {
+ Assert.isTrue(contentProvider instanceof IMergeViewerContentProvider);
+ if (managedContentProvider == null) {
+ managedContentProvider = contentProvider;
+ }
+
+ if (configuration.isMirrored()) {
+ if (mirroredManagedContentProvider == null) {
+ mirroredManagedContentProvider = new MirroredContentProvider(configuration,
+ (IMergeViewerContentProvider)managedContentProvider);
+ }
+ return mirroredManagedContentProvider;
+ } else {
+ return managedContentProvider;
+ }
+ }
+
+ /**
+ * Called from a derived {@link ContentMergeViewer#handlePropertyChangeEvent(PropertyChangeEvent)} method
+ * to intercept the preference change for swapping, i.e., mirroring the sides.
+ * <p>
+ * If this method returns true, the caller should not call
+ * <code>super.handlePropertyChangeEvent(event)</code> but rather should do the processing themselves to
+ * avoid calls to {@link ContentMergeViewer#updateContentProvider()} which will set the bogus default
+ * content provider. The method sets the MIRRORED property of the configuration as is normally done when
+ * calling super.
+ * </p>
+ *
+ * @param event
+ * the event to handle.
+ * @return true, if the property change is the property for the preference switching of sides, false
+ * otherwise.
+ */
+ public boolean handlePropertyChangeEvent(PropertyChangeEvent event) {
+ // For backward compatibility, instead of using ComparePreferencePage.SWAPPED,
+ // we compute the value.
+ if (event.getProperty().equals(CompareUIPlugin.PLUGIN_ID + ".Swapped")) { //$NON-NLS-1$
+ configuration.setProperty(EMFCompareConfiguration.MIRRORED, event.getNewValue());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * A merge viewer content provider that mirrors all the directional methods. It's implemented by extending
+ * MergeViewerContentProvider because {@link TextMergeViewer#isUsingDefaultContentProvider()} tests for
+ * that. If that's false, the viewer created by
+ * {@link TextFallbackCompareViewerCreator#createViewer(Composite, CompareConfiguration)} will not be able
+ * to use shared documents while mirrored.
+ */
+ private static class MirroredContentProvider extends MergeViewerContentProvider {
+ private final IMergeViewerContentProvider delegate;
+
+ public MirroredContentProvider(EMFCompareConfiguration configuration,
+ IMergeViewerContentProvider delegate) {
+ super(configuration);
+ this.delegate = delegate;
+ }
+
+ @Override
+ public boolean showAncestor(Object input) {
+ return delegate.showAncestor(input);
+ }
+
+ @Override
+ public void saveRightContent(Object input, byte[] bytes) {
+ delegate.saveLeftContent(input, bytes);
+ }
+
+ @Override
+ public void saveLeftContent(Object input, byte[] bytes) {
+ delegate.saveRightContent(input, bytes);
+ }
+
+ @Override
+ public boolean isRightEditable(Object input) {
+ return delegate.isLeftEditable(input);
+ }
+
+ @Override
+ public boolean isLeftEditable(Object input) {
+ return delegate.isRightEditable(input);
+ }
+
+ @Override
+ public String getRightLabel(Object input) {
+ return delegate.getLeftLabel(input);
+ }
+
+ @Override
+ public Image getRightImage(Object input) {
+ return delegate.getLeftImage(input);
+ }
+
+ @Override
+ public Object getRightContent(Object input) {
+ return delegate.getLeftContent(input);
+ }
+
+ @Override
+ public String getLeftLabel(Object input) {
+ return delegate.getRightLabel(input);
+ }
+
+ @Override
+ public Image getLeftImage(Object input) {
+ return delegate.getRightImage(input);
+ }
+
+ @Override
+ public Object getLeftContent(Object input) {
+ return delegate.getRightContent(input);
+ }
+
+ @Override
+ public String getAncestorLabel(Object input) {
+ return delegate.getAncestorLabel(input);
+ }
+
+ @Override
+ public Image getAncestorImage(Object input) {
+ return delegate.getAncestorImage(input);
+ }
+
+ @Override
+ public Object getAncestorContent(Object input) {
+ return delegate.getAncestorContent(input);
+ }
+
+ @Override
+ public void setLeftError(String errorMessage) {
+ super.setRightError(errorMessage);
+ }
+
+ @Override
+ public void setRightError(String errorMessage) {
+ super.setLeftError(errorMessage);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ delegate.dispose();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorUtil.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorUtil.java
deleted file mode 100644
index 08c99a993..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/MirrorUtil.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
- * 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:
- * Martin Fleck - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer;
-
-import java.lang.reflect.Field;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
-import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-
-/**
- * A utility class to handle the common functionality of mirroring the content merge viewer sides, i.e.,
- * swapping the left and right viewer. The mirroring functionality was introduced in Eclipse Compare v3.7 and
- * therefore needs to be handled reflectively to avoid backwards compatibility issues.
- *
- * @author Martin Fleck <mfleck@eclipsesource.com>
- */
-public class MirrorUtil {
- /** Mirrored: Compare configuration property key. */
- public static final String CONFIG_MIRRORED = "MIRRORED"; //$NON-NLS-1$
-
- /** Mirrored: Compare preference store key. */
- public static final String PREF_MIRRORED = "org.eclipse.compare.Swapped"; //$NON-NLS-1$
-
- /** Mirrored: Name of the 'Switch Left and Right' action field in {@link ContentMergeViewer}. */
- public static final String SWITCH_LEFT_RIGHT_ACTION = "fSwitchLeftAndRight"; //$NON-NLS-1$
-
- /**
- * Reflectively returns the action for switching the left and right side of the viewer. The returned
- * action may be null, if it is not available or cannot be retrieved.
- *
- * @param contentMergeViewer
- * content merge viewer
- * @return switch left and right action or null
- */
- public static Action getAction(ContentMergeViewer contentMergeViewer) {
- if (contentMergeViewer == null) {
- return null;
- }
-
- try {
- Field declaredField = ContentMergeViewer.class.getDeclaredField(SWITCH_LEFT_RIGHT_ACTION);
- declaredField.setAccessible(true);
- Object action = declaredField.get(contentMergeViewer);
- if (action != null && action instanceof Action) {
- return (Action)action;
- }
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException
- | IllegalAccessException e) {
- // ignore as the action is not available on all platforms
- }
- return null;
- }
-
- /**
- * Removes the action for switching the left and right side of the viewer from the toolbar, if it is
- * available.
- *
- * @param contentMergeViewer
- * content merge viewer
- * @param toolBarManager
- * tool bar manager of the content merge viewer
- * @return the removed action or null, if the action was not available
- * @see #getAction(ContentMergeViewer)
- */
- public static Action removeFromToolBar(ContentMergeViewer contentMergeViewer,
- ToolBarManager toolBarManager) {
- // switch left and right view action, may be null -> remove as it destroys the view
- Action switchLeftAndRightAction = getAction(contentMergeViewer);
- if (switchLeftAndRightAction != null && toolBarManager != null) {
- IContributionItem[] items = toolBarManager.getItems();
- for (IContributionItem iContributionItem : items) {
- if (iContributionItem instanceof ActionContributionItem) {
- IAction action = ((ActionContributionItem)iContributionItem).getAction();
- if (switchLeftAndRightAction == action) {
- toolBarManager.remove(iContributionItem);
- }
- }
- }
- }
- return switchLeftAndRightAction;
- }
-
- /**
- * Evaluates whether the left and right side of the viewer should be mirrored.
- *
- * @param compareConfiguration
- * compare configuration holding the mirrored property
- * @return true if the left and right side of the viewer should be mirrored. Default is false.
- */
- public static boolean isMirrored(CompareConfiguration compareConfiguration) {
- if (compareConfiguration == null) {
- return false;
- }
-
- boolean isMirrored = false;
- Object value = compareConfiguration.getProperty(CONFIG_MIRRORED);
- if (value instanceof Boolean) {
- isMirrored = ((Boolean)value).booleanValue();
- }
- return isMirrored;
- }
-
- /**
- * Sets the mirrored property for the given compare configuration.
- *
- * @param compareConfiguration
- * compare configuration holding the mirrored property
- * @param mirrored
- * true if the left and right side of the viewer should be mirrored, false otherwise.
- */
- public static void setMirrored(EMFCompareConfiguration compareConfiguration, boolean mirrored) {
- compareConfiguration.setProperty(CONFIG_MIRRORED, Boolean.valueOf(mirrored));
- }
-
- /**
- * Returns true if the given property is used to store the mirrored value in the compare configuration,
- * false otherwise.
- *
- * @param configProperty
- * compare configuration property
- * @return true if the given property is the mirrored property, false otherwise
- */
- public static boolean isMirroredProperty(String configProperty) {
- return CONFIG_MIRRORED.equals(configProperty);
- }
-
- /**
- * Returns true if the given property is used to store the mirrored value in the preference store, false
- * otherwise.
- *
- * @param preferenceProperty
- * preference property
- * @return true if the given property is the mirrored property, false otherwise
- */
- public static boolean isMirroredPreference(String preferenceProperty) {
- return PREF_MIRRORED.equals(preferenceProperty);
- }
-
-}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/TextFallbackCompareViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/TextFallbackCompareViewerCreator.java
index 92586e9b6..bb371f807 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/TextFallbackCompareViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/TextFallbackCompareViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2017 Obeo and others.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,7 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
- * Philip Langer - bug 508526
+ * Philip Langer - bugs 508526, 514079, 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer;
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/fallback/TextFallbackMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/fallback/TextFallbackMergeViewer.java
index 1b2916d5c..a053ebc28 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/fallback/TextFallbackMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/fallback/TextFallbackMergeViewer.java
@@ -19,6 +19,7 @@ import org.eclipse.compare.CompareViewerSwitchingPane;
import org.eclipse.compare.ISharedDocumentAdapter;
import org.eclipse.compare.SharedDocumentAdapter;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
+import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.Utilities;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
@@ -36,6 +37,7 @@ import org.eclipse.emf.compare.domain.ICompareEditingDomain;
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.configuration.EMFCompareConfiguration;
+import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.MirrorManager;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.CompareInputAdapter;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.ForwardingCompareInput;
import org.eclipse.emf.compare.internal.utils.ComparisonUtil;
@@ -118,6 +120,12 @@ public class TextFallbackMergeViewer extends TextMergeViewer {
private SourceViewer rightViewer;
/**
+ * The mirror manager used to control the {@link #setContentProvider(IContentProvider) content provider}
+ * and when {@link #handlePropertyChangeEvent(PropertyChangeEvent) handling mirror state changes}.
+ */
+ private MirrorManager mirrorManager;
+
+ /**
* Controls whether {@link #setContentProvider(IContentProvider) content provider changes} are respected
* or ignored.
*
@@ -172,6 +180,9 @@ public class TextFallbackMergeViewer extends TextMergeViewer {
// Hook up the command stack listener to the editing domain's command stack.
editingDomainChange(null, getCompareConfiguration().getEditingDomain());
+ // Create a mirror manager to help manage the mirror state.
+ mirrorManager = new MirrorManager(configuration);
+
// Set our content provider, ensuring that it's not ignored during the update.
ignoreContentProvideChanges = false;
setContentProvider(new TextFallbackMergeViewerContentProvider(this));
@@ -435,7 +446,11 @@ public class TextFallbackMergeViewer extends TextMergeViewer {
@Override
public void setContentProvider(IContentProvider contentProvider) {
if (!ignoreContentProvideChanges) {
- super.setContentProvider(contentProvider);
+ if (mirrorManager != null) {
+ super.setContentProvider(mirrorManager.getContentProvider(contentProvider));
+ } else {
+ super.setContentProvider(contentProvider);
+ }
}
}
@@ -660,12 +675,60 @@ public class TextFallbackMergeViewer extends TextMergeViewer {
// Disconnect from the event bus.
configuration.getEventBus().unregister(this);
+ // Stop using this configuration.
+ configuration.disposeSelf();
+
// Clean up the inputs.
setOriginalInput(null);
setEffectiveInput(null);
}
/**
+ * {@inheritDoc}
+ * <p>
+ * This implementation uses the {@link #mirrorManager mirror manager} to subvert {@code super's} handling
+ * of mirror state changes so that it can handle the state change in a better way than does the base
+ * class.
+ * </p>
+ *
+ * @see TextMergeViewer#handlePropertyChangeEvent(PropertyChangeEvent)
+ */
+ @Override
+ protected void handlePropertyChangeEvent(PropertyChangeEvent event) {
+ if (mirrorManager != null && mirrorManager.handlePropertyChangeEvent(event)) {
+ // Connect to both left and right document providers so the documents aren't released during
+ // the switching process.
+ Object oldInput = getInput();
+ IMergeViewerContentProvider oldContentProvider = (IMergeViewerContentProvider)getContentProvider();
+ Runnable leftDocumentConnection = connectDocumentProvider(
+ oldContentProvider.getLeftContent(oldInput));
+ Runnable rightDocumentConnection = connectDocumentProvider(
+ oldContentProvider.getRightContent(oldInput));
+ try {
+ ignoreContentProvideChanges = false;
+ setContentProvider(mirrorManager.getContentProvider(oldContentProvider));
+
+ // Update the title image because it may include a directional overlay that has changed.
+ updateTitleImage();
+ } finally {
+ ignoreContentProvideChanges = true;
+ // Disconnect them again.
+ if (leftDocumentConnection != null) {
+ leftDocumentConnection.run();
+ }
+ if (rightDocumentConnection != null) {
+ rightDocumentConnection.run();
+ }
+ }
+
+ // Update the tool items, many of which include directional indication.
+ updateToolItems();
+ } else {
+ super.handlePropertyChangeEvent(event);
+ }
+ }
+
+ /**
* Opens a connection to the document provider and returns a runnable that will disconnect it.
*
* @param element
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabelContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabelContentViewer.java
index c12552614..440040a3f 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabelContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabelContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2017 Obeo and others.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,18 +7,34 @@
*
* Contributors:
* Obeo - initial API and implementation
- * Philip Langer - bug 522422
+ * Philip Langer - bug 522422, 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
+import com.google.common.eventbus.Subscribe;
+
+import java.util.EventObject;
+
+import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.IPropertyChangeNotifier;
+import org.eclipse.compare.internal.Utilities;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.compare.command.ICompareCommandStack;
+import org.eclipse.emf.compare.domain.ICompareEditingDomain;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
+import org.eclipse.emf.compare.rcp.ui.internal.configuration.ICompareEditingDomainChange;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -30,20 +46,30 @@ import org.eclipse.swt.widgets.Label;
*
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class LabelContentViewer extends Viewer {
+public class LabelContentViewer extends Viewer implements IPropertyChangeNotifier, CommandStackListener {
/** The Control as returned by {@link #getControl()}. */
private final Composite control;
+ @SuppressWarnings("rawtypes") // Doesn't use generic type for back-ward compatibility
+ private final ListenerList listenerList;
+
private Object input;
+ private final EMFCompareConfiguration configuration;
+
+ private boolean dirty;
+
/**
* Creates a new viewer and its controls.
*
* @param parent
* the parent of the {@link #getControl() control} of this viewer.
*/
- public LabelContentViewer(Composite parent, String title, String message) {
+ @SuppressWarnings("rawtypes")
+ public LabelContentViewer(Composite parent, String title, String message,
+ EMFCompareConfiguration configuration) {
+ this.configuration = configuration;
control = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(1, true);
control.setLayout(layout);
@@ -57,6 +83,18 @@ public class LabelContentViewer extends Viewer {
if (toolBarManager != null) {
toolBarManager.removeAll();
}
+
+ listenerList = new ListenerList();
+
+ editingDomainChange(null, configuration.getEditingDomain());
+
+ configuration.getEventBus().register(this);
+
+ control.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ handleDisposed();
+ }
+ });
}
/**
@@ -116,4 +154,59 @@ public class LabelContentViewer extends Viewer {
public Control getControl() {
return control;
}
+
+ @SuppressWarnings("unchecked")
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ listenerList.add(listener);
+ }
+
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ listenerList.remove(listener);
+ }
+
+ /**
+ * @param oldValue
+ * @param newValue
+ */
+ @Subscribe
+ public void editingDomainChange(ICompareEditingDomainChange event) {
+ ICompareEditingDomain oldValue = event.getOldValue();
+ ICompareEditingDomain newValue = event.getNewValue();
+ editingDomainChange(oldValue, newValue);
+ }
+
+ public void editingDomainChange(ICompareEditingDomain oldValue, ICompareEditingDomain newValue) {
+ if (oldValue != null) {
+ ICompareCommandStack commandStack = oldValue.getCommandStack();
+ commandStack.removeCommandStackListener(this);
+ }
+ if (newValue != oldValue) {
+ if (newValue != null) {
+ ICompareCommandStack commandStack = newValue.getCommandStack();
+ commandStack.addCommandStackListener(this);
+ setDirty(commandStack.isLeftSaveNeeded() || commandStack.isRightSaveNeeded());
+ }
+ }
+ }
+
+ protected void setDirty(boolean dirty) {
+ if (this.dirty != dirty) {
+ this.dirty = dirty;
+ Utilities.firePropertyChange(listenerList, this, CompareEditorInput.DIRTY_STATE, null,
+ Boolean.valueOf(dirty));
+ }
+ }
+
+ public void commandStackChanged(EventObject event) {
+ if (configuration.getEditingDomain() != null) {
+ ICompareCommandStack commandStack = configuration.getEditingDomain().getCommandStack();
+ setDirty(commandStack.isLeftSaveNeeded() || commandStack.isRightSaveNeeded());
+ }
+ }
+
+ protected void handleDisposed() {
+ configuration.getEventBus().unregister(this);
+ configuration.disposeSelf();
+ editingDomainChange(configuration.getEditingDomain(), null);
+ }
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabeledViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabeledViewerCreator.java
index 5e8111e64..8e608bc16 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabeledViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/LabeledViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,12 +7,14 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
@@ -31,12 +33,12 @@ public class LabeledViewerCreator implements IViewerCreator {
* org.eclipse.compare.CompareConfiguration)
*/
public Viewer createViewer(final Composite parent, CompareConfiguration config) {
+ EMFCompareConfiguration compareConfiguration = new EMFCompareConfiguration(config);
if (config != null
&& config.getProperty(EMFCompareIDEUIPlugin.PLUGIN_ID + ".COMPARE_RESULT") != null) { //$NON-NLS-1$
- return new NoSelectedItemContentViewer(parent);
+ return new NoSelectedItemContentViewer(parent, compareConfiguration);
} else {
- return new WaitContentViewer(parent);
+ return new WaitContentViewer(parent, compareConfiguration);
}
}
-
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesContentViewer.java
index 70ce2f415..7dd227016 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.swt.widgets.Composite;
/**
@@ -26,8 +28,8 @@ public class NoDifferencesContentViewer extends LabelContentViewer {
* @param parent
* the parent of the control of this viewer.
*/
- public NoDifferencesContentViewer(Composite parent) {
+ public NoDifferencesContentViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, EMFCompareIDEUIMessages.getString("no.differences.viewer.title"), //$NON-NLS-1$
- EMFCompareIDEUIMessages.getString("no.differences.viewer.desc")); //$NON-NLS-1$
+ EMFCompareIDEUIMessages.getString("no.differences.viewer.desc"), configuration); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesViewerCreator.java
index d78f68bb0..28e2809d6 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoDifferencesViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,11 +7,13 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
@@ -29,6 +31,6 @@ public class NoDifferencesViewerCreator implements IViewerCreator {
* org.eclipse.compare.CompareConfiguration)
*/
public Viewer createViewer(final Composite parent, CompareConfiguration config) {
- return new NoDifferencesContentViewer(parent);
+ return new NoDifferencesContentViewer(parent, new EMFCompareConfiguration(config));
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemContentViewer.java
index 08bb0dddc..b5258e7c3 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.swt.widgets.Composite;
/**
@@ -26,8 +28,8 @@ public class NoSelectedItemContentViewer extends LabelContentViewer {
* @param parent
* the parent of the control of this viewer.
*/
- public NoSelectedItemContentViewer(Composite parent) {
+ public NoSelectedItemContentViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, EMFCompareIDEUIMessages.getString("no.selected.item.viewer.title"), //$NON-NLS-1$
- EMFCompareIDEUIMessages.getString("no.selected.item.viewer.desc")); //$NON-NLS-1$
+ EMFCompareIDEUIMessages.getString("no.selected.item.viewer.desc"), configuration); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemViewerCreator.java
index 921837ff1..e629a167d 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoSelectedItemViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
+ * Copyright (c) 2017, 2018 EclipseSource Services GmbH and others.
* 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
@@ -7,11 +7,13 @@
*
* Contributors:
* Martin Fleck - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
@@ -29,7 +31,7 @@ public class NoSelectedItemViewerCreator implements IViewerCreator {
* org.eclipse.compare.CompareConfiguration)
*/
public Viewer createViewer(final Composite parent, CompareConfiguration config) {
- return new NoSelectedItemContentViewer(parent);
+ return new NoSelectedItemContentViewer(parent, new EMFCompareConfiguration(config));
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemContentViewer.java
index ccf9bd759..7d50acced 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.swt.widgets.Composite;
/**
@@ -26,8 +28,8 @@ public class NoVisibleItemContentViewer extends LabelContentViewer {
* @param parent
* the parent of the control of this viewer.
*/
- public NoVisibleItemContentViewer(Composite parent) {
+ public NoVisibleItemContentViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, EMFCompareIDEUIMessages.getString("no.visible.item.viewer.title"), //$NON-NLS-1$
- EMFCompareIDEUIMessages.getString("no.visible.item.viewer.desc")); //$NON-NLS-1$
+ EMFCompareIDEUIMessages.getString("no.visible.item.viewer.desc"), configuration); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemViewerCreator.java
index ee6cf27f5..5ce691a49 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/NoVisibleItemViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,11 +7,13 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
@@ -29,6 +31,6 @@ public class NoVisibleItemViewerCreator implements IViewerCreator {
* org.eclipse.compare.CompareConfiguration)
*/
public Viewer createViewer(final Composite parent, CompareConfiguration config) {
- return new NoVisibleItemContentViewer(parent);
+ return new NoVisibleItemContentViewer(parent, new EMFCompareConfiguration(config));
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsContentViewer.java
index b9db6f77d..ceeaa4185 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 EclipseSource Muenchen GmbH and others.
+ * Copyright (c) 2015, 2018 EclipseSource Muenchen GmbH and others.
* 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Michael Borkowski - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.swt.widgets.Composite;
/**
@@ -26,8 +28,8 @@ public class OnlyPseudoConflictsContentViewer extends LabelContentViewer {
* @param parent
* the parent of the control of this viewer.
*/
- public OnlyPseudoConflictsContentViewer(Composite parent) {
+ public OnlyPseudoConflictsContentViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, EMFCompareIDEUIMessages.getString("only.pseudo.conflicts.viewer.title"), //$NON-NLS-1$
- EMFCompareIDEUIMessages.getString("only.pseudo.conflicts.viewer.desc")); //$NON-NLS-1$
+ EMFCompareIDEUIMessages.getString("only.pseudo.conflicts.viewer.desc"), configuration); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsViewerCreator.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsViewerCreator.java
index 71f1c5374..04f22284c 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsViewerCreator.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/OnlyPseudoConflictsViewerCreator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 EclipseSource Muenchen GmbH and others.
+ * Copyright (c) 2015, 2018 EclipseSource Muenchen GmbH and others.
* 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
@@ -7,11 +7,13 @@
*
* Contributors:
* Michael Borkowski - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IViewerCreator;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
@@ -30,6 +32,6 @@ public class OnlyPseudoConflictsViewerCreator implements IViewerCreator {
* org.eclipse.compare.CompareConfiguration)
*/
public Viewer createViewer(final Composite parent, CompareConfiguration config) {
- return new OnlyPseudoConflictsContentViewer(parent);
+ return new OnlyPseudoConflictsContentViewer(parent, new EMFCompareConfiguration(config));
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/WaitContentViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/WaitContentViewer.java
index f50fc5040..040bd4c20 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/WaitContentViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/label/WaitContentViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Obeo.
+ * Copyright (c) 2014, 2018 Obeo and others.
* 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.swt.widgets.Composite;
/**
@@ -26,8 +28,8 @@ public class WaitContentViewer extends LabelContentViewer {
* @param parent
* the parent of the control of this viewer.
*/
- public WaitContentViewer(Composite parent) {
+ public WaitContentViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, EMFCompareIDEUIMessages.getString("wait.viewer.title"), //$NON-NLS-1$
- EMFCompareIDEUIMessages.getString("wait.viewer.desc")); //$NON-NLS-1$
+ EMFCompareIDEUIMessages.getString("wait.viewer.desc"), configuration); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/MirroredTableContentMergeViewerContentProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/MirroredTableContentMergeViewerContentProvider.java
deleted file mode 100644
index 9282ca2e3..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/MirroredTableContentMergeViewerContentProvider.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
- * 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:
- * Martin Fleck - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.table;
-
-import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Mirrored implementation of {@link TableContentMergeViewerContentProvider} that swaps the left and right
- * side.
- *
- * @author Martin Fleck <mfleck@eclipsesource.com>
- */
-public class MirroredTableContentMergeViewerContentProvider extends TableContentMergeViewerContentProvider {
-
- private TableContentMergeViewerContentProvider delegate;
-
- public MirroredTableContentMergeViewerContentProvider(EMFCompareConfiguration cc,
- TableContentMergeViewerContentProvider delegate) {
- super(cc);
- this.delegate = delegate;
- }
-
- @Override
- public String getLeftLabel(Object element) {
- return delegate.getRightLabel(element);
- }
-
- @Override
- public Image getLeftImage(Object element) {
- return delegate.getRightImage(element);
- }
-
- @Override
- public Object getLeftContent(Object element) {
- return delegate.getRightContent(element);
- }
-
- @Override
- public boolean isLeftEditable(Object element) {
- return delegate.isRightEditable(element);
- }
-
- @Override
- public void saveLeftContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveLeftContent(element, bytes);
- }
-
- @Override
- public String getRightLabel(Object element) {
- return delegate.getLeftLabel(element);
- }
-
- @Override
- public Image getRightImage(Object element) {
- return delegate.getLeftImage(element);
- }
-
- @Override
- public Object getRightContent(Object element) {
- return delegate.getLeftContent(element);
- }
-
- @Override
- public boolean isRightEditable(Object element) {
- return delegate.isLeftEditable(element);
- }
-
- @Override
- public void saveRightContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveRightContent(element, bytes);
- }
-
- @Override
- public void inputChanged(Viewer v, Object o1, Object o2) {
- delegate.inputChanged(v, o1, o2);
- }
-
- @Override
- public void setAncestorError(String errorMessage) {
- delegate.setAncestorError(errorMessage);
- }
-
- @Override
- public String getAncestorLabel(Object element) {
- return delegate.getAncestorLabel(element);
- }
-
- @Override
- public Image getAncestorImage(Object element) {
- return delegate.getAncestorImage(element);
- }
-
- @Override
- public Object getAncestorContent(Object element) {
- return delegate.getAncestorContent(element);
- }
-
- @Override
- public boolean showAncestor(Object element) {
- return delegate.showAncestor(element);
- }
-
- @Override
- public void setLeftError(String errorMessage) {
- delegate.setRightError(errorMessage);
- }
-
- @Override
- public void setRightError(String errorMessage) {
- delegate.setLeftError(errorMessage);
- }
-}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/TableContentMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/TableContentMergeViewer.java
index 703866cb0..79a1f811b 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/TableContentMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/table/TableContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 Obeo and others.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -8,7 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
* Martin Fleck - bug 483798
- * Philip Langer - bug 527567
+ * Philip Langer - bug 527567, 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.table;
@@ -45,8 +45,6 @@ import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -81,12 +79,6 @@ public class TableContentMergeViewer extends EMFCompareContentMergeViewer {
private double[] fBasicCenterCurve;
- private TableContentMergeViewerContentProvider fContentProvider;
-
- private IBaseLabelProvider fLeftLabelProvider;
-
- private IBaseLabelProvider fRightLabelProvider;
-
/**
* Call the super constructor.
*
@@ -104,10 +96,7 @@ public class TableContentMergeViewer extends EMFCompareContentMergeViewer {
fAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
buildControl(parent);
- fContentProvider = new TableContentMergeViewerContentProvider(config);
- fLeftLabelProvider = getLeftMergeViewer().getLabelProvider();
- fRightLabelProvider = getRightMergeViewer().getLabelProvider();
- setMirrored(isMirrored());
+ setContentProvider(new TableContentMergeViewerContentProvider(config));
}
/**
@@ -394,27 +383,4 @@ public class TableContentMergeViewer extends EMFCompareContentMergeViewer {
fBasicCenterCurve[i] = Math.cos(Math.PI * r);
}
}
-
- @Override
- protected IContentProvider getUnmirroredContentProvider() {
- return fContentProvider;
- }
-
- @Override
- protected IContentProvider getMirroredContentProvider() {
- return new MirroredTableContentMergeViewerContentProvider(getCompareConfiguration(),
- fContentProvider);
- }
-
- @Override
- protected void updateMirrored(boolean isMirrored) {
- if (isMirrored) {
- getLeftMergeViewer().setLabelProvider(fRightLabelProvider);
- getRightMergeViewer().setLabelProvider(fLeftLabelProvider);
- } else {
- getLeftMergeViewer().setLabelProvider(fLeftLabelProvider);
- getRightMergeViewer().setLabelProvider(fRightLabelProvider);
- }
- super.updateMirrored(isMirrored);
- }
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
index b34deed2b..4cc22c9cd 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/EMFCompareTextMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 Obeo and others.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -8,9 +8,8 @@
* Contributors:
* Obeo - initial API and implementation
* Alexandra Buzila - Bug 457117
- * Philip Langer - bug 457839, 516489, 521948
+ * Philip Langer - bug 457839, 516489, 521948, 514079
* Michael Borkowski - Bug 462863
- * Martin Fleck - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.text;
@@ -53,7 +52,7 @@ import org.eclipse.emf.compare.domain.ICompareEditingDomain;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.EMFCompareContentMergeViewerResourceBundle;
-import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.MirrorUtil;
+import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.MirrorManager;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util.DynamicObject;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util.RedoAction;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util.UndoAction;
@@ -69,6 +68,8 @@ import org.eclipse.emf.edit.command.ChangeCommand;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.FocusEvent;
@@ -95,10 +96,7 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
private DelayedTextChangeRunnable delayedTextChangeRunnable;
- /** The unmirrored content provider. */
- private EMFCompareTextMergeViewerContentProvider fContentProvider;
-
- private Boolean fIsMirrored;
+ private MirrorManager mirrorManager;
/**
* @param parent
@@ -106,15 +104,25 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
*/
public EMFCompareTextMergeViewer(Composite parent, EMFCompareConfiguration configuration) {
super(parent, configuration);
- setContentProvider(new EMFCompareTextMergeViewerContentProvider(configuration));
- fContentProvider = new EMFCompareTextMergeViewerContentProvider(configuration);
- setMirrored(MirrorUtil.isMirrored(getCompareConfiguration()));
+
editingDomainChange(null, configuration.getEditingDomain());
configuration.getEventBus().register(this);
mergeResolutionManager = new MergeResolutionManager(
EMFCompareIDEUIPlugin.getDefault().getMergeResolutionListenerRegistry());
+
+ mirrorManager = new MirrorManager(configuration);
+ setContentProvider(new EMFCompareTextMergeViewerContentProvider(configuration));
+ }
+
+ @Override
+ public void setContentProvider(IContentProvider contentProvider) {
+ if (mirrorManager != null) {
+ super.setContentProvider(mirrorManager.getContentProvider(contentProvider));
+ } else {
+ super.setContentProvider(contentProvider);
+ }
}
/**
@@ -397,7 +405,10 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
* @return The content of the viewer on the given {@code side}.
*/
private String getCurrentValueFromViewer(MergeViewerSide side) {
- final boolean isLeft = MergeViewerSide.LEFT.equals(side);
+ boolean isLeft = MergeViewerSide.LEFT == side;
+ if (getCompareConfiguration().isMirrored()) {
+ isLeft = MergeViewerSide.RIGHT == side;
+ }
final GetContentRunnable runnable = new GetContentRunnable(isLeft);
Display.getDefault().syncExec(runnable);
return (String)runnable.getResult();
@@ -468,9 +479,10 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
*/
@Override
protected void handleDispose(DisposeEvent event) {
- getCompareConfiguration().getEventBus().unregister(this);
-
- editingDomainChange(getCompareConfiguration().getEditingDomain(), null);
+ EMFCompareConfiguration compareConfiguration = getCompareConfiguration();
+ compareConfiguration.getEventBus().unregister(this);
+ editingDomainChange(compareConfiguration.getEditingDomain(), null);
+ compareConfiguration.disposeSelf();
fRedoAction = null;
fUndoAction = null;
@@ -478,6 +490,16 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
super.handleDispose(event);
}
+ @Override
+ protected void handlePropertyChangeEvent(PropertyChangeEvent event) {
+ if (mirrorManager != null && mirrorManager.handlePropertyChangeEvent(event)) {
+ setContentProvider(mirrorManager.getContentProvider(getContentProvider()));
+ updateToolItems();
+ } else {
+ super.handlePropertyChangeEvent(event);
+ }
+ }
+
/**
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
@@ -660,29 +682,6 @@ public class EMFCompareTextMergeViewer extends TextMergeViewer implements Comman
}
/**
- * Sets the viewers {@link #isMirrored() mirrored} state and triggers an {@link #updateMirrored(boolean)
- * update}, if necessary.
- */
- protected void setMirrored(boolean isMirrored) {
- if (fIsMirrored == null || fIsMirrored.booleanValue() != isMirrored) {
- fIsMirrored = Boolean.valueOf(isMirrored);
- updateMirrored(isMirrored);
- }
- }
-
- /**
- * Updates the viewer based on its {@link #isMirrored() mirrored} state.
- */
- protected void updateMirrored(boolean isMirrored) {
- if (isMirrored) {
- setContentProvider(new MirroredEMFCompareTextMergeViewerContentProvider(getCompareConfiguration(),
- fContentProvider));
- } else {
- setContentProvider(fContentProvider);
- }
- }
-
- /**
* A class for delayed processing of the changes made in the text viewer.
*/
private class DelayedTextChangeRunnable implements Runnable {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/MirroredEMFCompareTextMergeViewerContentProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/MirroredEMFCompareTextMergeViewerContentProvider.java
deleted file mode 100644
index eb800e0aa..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/text/MirroredEMFCompareTextMergeViewerContentProvider.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
- * 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:
- * Martin Fleck - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.text;
-
-import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Mirrored implementation of {@link EMFCompareTextMergeViewerContentProvider} that swaps the left and right
- * side.
- *
- * @author Martin Fleck <mfleck@eclipsesource.com>
- */
-public class MirroredEMFCompareTextMergeViewerContentProvider extends EMFCompareTextMergeViewerContentProvider {
-
- private EMFCompareTextMergeViewerContentProvider delegate;
-
- public MirroredEMFCompareTextMergeViewerContentProvider(EMFCompareConfiguration cc,
- EMFCompareTextMergeViewerContentProvider delegate) {
- super(cc);
- this.delegate = delegate;
- }
-
- @Override
- public void inputChanged(Viewer v, Object o1, Object o2) {
- delegate.inputChanged(v, o1, o2);
- }
-
- @Override
- public void setAncestorError(String errorMessage) {
- delegate.setAncestorError(errorMessage);
- }
-
- @Override
- public String getAncestorLabel(Object element) {
- return delegate.getAncestorLabel(element);
- }
-
- @Override
- public Image getAncestorImage(Object element) {
- return delegate.getAncestorImage(element);
- }
-
- @Override
- public Object getAncestorContent(Object element) {
- return delegate.getAncestorContent(element);
- }
-
- @Override
- public boolean showAncestor(Object element) {
- return delegate.showAncestor(element);
- }
-
- @Override
- public void setLeftError(String errorMessage) {
- delegate.setRightError(errorMessage);
- }
-
- @Override
- public String getLeftLabel(Object element) {
- return delegate.getRightLabel(element);
- }
-
- @Override
- public Image getLeftImage(Object element) {
- return delegate.getRightImage(element);
- }
-
- @Override
- public Object getLeftContent(Object element) {
- return delegate.getRightContent(element);
- }
-
- @Override
- public boolean isLeftEditable(Object element) {
- return delegate.isRightEditable(element);
- }
-
- @Override
- public void saveLeftContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveLeftContent(element, bytes);
- }
-
- @Override
- public void setRightError(String errorMessage) {
- delegate.setLeftError(errorMessage);
- }
-
- @Override
- public String getRightLabel(Object element) {
- return delegate.getLeftLabel(element);
- }
-
- @Override
- public Image getRightImage(Object element) {
- return delegate.getLeftImage(element);
- }
-
- @Override
- public Object getRightContent(Object element) {
- return delegate.getLeftContent(element);
- }
-
- @Override
- public boolean isRightEditable(Object element) {
- return delegate.isLeftEditable(element);
- }
-
- @Override
- public void saveRightContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveRightContent(element, bytes);
- }
-
-}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/MirroredTreeContentMergeViewerContentProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/MirroredTreeContentMergeViewerContentProvider.java
deleted file mode 100644
index e88c86bbf..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/MirroredTreeContentMergeViewerContentProvider.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 EclipseSource Services GmbH and others.
- * 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:
- * Martin Fleck - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree;
-
-import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Mirrored implementation of {@link TreeContentMergeViewerContentProvider} that swaps the left and right
- * side.
- *
- * @author Martin Fleck <mfleck@eclipsesource.com>
- */
-public class MirroredTreeContentMergeViewerContentProvider extends TreeContentMergeViewerContentProvider {
-
- private TreeContentMergeViewerContentProvider delegate;
-
- public MirroredTreeContentMergeViewerContentProvider(EMFCompareConfiguration cc,
- TreeContentMergeViewerContentProvider delegate) {
- super(cc);
- this.delegate = delegate;
- }
-
- @Override
- public String getLeftLabel(Object element) {
- return delegate.getRightLabel(element);
- }
-
- @Override
- public Image getLeftImage(Object element) {
- return delegate.getRightImage(element);
- }
-
- @Override
- public Object getLeftContent(Object element) {
- return delegate.getRightContent(element);
- }
-
- @Override
- public boolean isLeftEditable(Object element) {
- return delegate.isRightEditable(element);
- }
-
- @Override
- public void saveLeftContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveLeftContent(element, bytes);
- }
-
- @Override
- public String getRightLabel(Object element) {
- return delegate.getLeftLabel(element);
- }
-
- @Override
- public Image getRightImage(Object element) {
- return delegate.getLeftImage(element);
- }
-
- @Override
- public Object getRightContent(Object element) {
- return delegate.getLeftContent(element);
- }
-
- @Override
- public boolean isRightEditable(Object element) {
- return delegate.isLeftEditable(element);
- }
-
- @Override
- public void saveRightContent(Object element, byte[] bytes) {
- // The EMFCompareStructurededMergeViewer already "unswaps" the sides before saving-> keep sides
- delegate.saveRightContent(element, bytes);
- }
-
- @Override
- public void inputChanged(Viewer v, Object o1, Object o2) {
- delegate.inputChanged(v, o1, o2);
- }
-
- @Override
- public String getAncestorLabel(Object element) {
- return delegate.getAncestorLabel(element);
- }
-
- @Override
- public Image getAncestorImage(Object element) {
- return delegate.getAncestorImage(element);
- }
-
- @Override
- public Object getAncestorContent(Object element) {
- return delegate.getAncestorContent(element);
- }
-
- @Override
- public boolean showAncestor(Object element) {
- return delegate.showAncestor(element);
- }
-
-}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/TreeContentMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/TreeContentMergeViewer.java
index 39095e0f7..54a1b35c5 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/TreeContentMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/TreeContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 Obeo and others.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -9,7 +9,7 @@
* Obeo - initial API and implementation
* Stefan Dirix - bugs 487595, 510442
* Martin Fleck - bug 483798
- * Philip Langer - bug 527567
+ * Philip Langer - bugs 527567, 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree;
@@ -19,8 +19,10 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Lists.newArrayList;
import static org.eclipse.emf.compare.utils.EMFComparePredicates.ofKind;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -44,6 +46,7 @@ import org.eclipse.emf.compare.rcp.EMFCompareRCPPlugin;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.impl.AbstractMergeViewer;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.impl.TreeMergeViewer;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
+import org.eclipse.emf.compare.rcp.ui.internal.util.SWTUtil;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.IMergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.provider.IMergeViewerItemProviderConfiguration;
@@ -54,7 +57,6 @@ import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -87,14 +89,7 @@ public class TreeContentMergeViewer extends AbstractTreeContentMergeViewer {
private AtomicBoolean fSyncExpandedState;
- /** The unmirrored content provider of this merge viewer. */
- protected TreeContentMergeViewerContentProvider fContentProvider;
-
- /** Label provider remembered for swapping sides in the viewer. */
- protected IBaseLabelProvider fLeftLabelProvider, fRightLabelProvider;
-
- /** Content provider remembered for swapping sides in the viewer. */
- protected IContentProvider fLeftContentProvider, fRightContentProvider;
+ private Collection<Diff> moveDifferences;
/**
* Creates a new {@link TreeContentMergeViewer} by calling the super constructor with the given
@@ -129,12 +124,7 @@ public class TreeContentMergeViewer extends AbstractTreeContentMergeViewer {
fSyncExpandedState = new AtomicBoolean();
buildControl(parent);
- fContentProvider = new TreeContentMergeViewerContentProvider(config);
- fLeftContentProvider = getLeftMergeViewer().getContentProvider();
- fRightContentProvider = getRightMergeViewer().getContentProvider();
- fLeftLabelProvider = getLeftMergeViewer().getLabelProvider();
- fRightLabelProvider = getRightMergeViewer().getLabelProvider();
- setMirrored(isMirrored());
+ setContentProvider(new TreeContentMergeViewerContentProvider(config));
}
protected ComposedAdapterFactory getAdapterFactory() {
@@ -283,12 +273,18 @@ public class TreeContentMergeViewer extends AbstractTreeContentMergeViewer {
} else if (parent instanceof EObject) {
Match match = comparison.getMatch((EObject)parent);
if (match != null) {
- // We get all move differencies in order to detect the move of an element with an original
+ // We get all move differences in order to detect the move of an element with an original
// position outside the actual match of the diff. We have to do that since move
- // differencies are registered only under one container (left or right depending on the
+ // differences are registered only under one container (left or right depending on the
// situation)
- for (Diff referenceChange : filter(comparison.getDifferences(),
- and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.MOVE)))) {
+ // This is relatively expensive, so cache the result once for sharing across all the
+ // listeners.
+ if (moveDifferences == null) {
+ moveDifferences = Lists.newArrayList(filter(comparison.getDifferences(),
+ and(instanceOf(ReferenceChange.class), ofKind(DifferenceKind.MOVE))));
+ }
+
+ for (Diff referenceChange : moveDifferences) {
Match matchOfValue = comparison
.getMatch(((ReferenceChange)referenceChange).getValue());
if (matchOfValue != null) {
@@ -336,7 +332,7 @@ public class TreeContentMergeViewer extends AbstractTreeContentMergeViewer {
}
}
} finally {
- getCenterControl().redraw();
+ SWTUtil.safeRedraw(getCenterControl(), true);
fSyncExpandedState.set(false);
}
}
@@ -389,29 +385,4 @@ public class TreeContentMergeViewer extends AbstractTreeContentMergeViewer {
}
- @Override
- protected IContentProvider getUnmirroredContentProvider() {
- return fContentProvider;
- }
-
- @Override
- protected IContentProvider getMirroredContentProvider() {
- return new MirroredTreeContentMergeViewerContentProvider(getCompareConfiguration(), fContentProvider);
- }
-
- @Override
- protected void updateMirrored(boolean isMirrored) {
- if (isMirrored) {
- getLeftMergeViewer().setContentProvider(fRightContentProvider);
- getLeftMergeViewer().setLabelProvider(fRightLabelProvider);
- getRightMergeViewer().setContentProvider(fLeftContentProvider);
- getRightMergeViewer().setLabelProvider(fLeftLabelProvider);
- } else {
- getLeftMergeViewer().setContentProvider(fLeftContentProvider);
- getLeftMergeViewer().setLabelProvider(fLeftLabelProvider);
- getRightMergeViewer().setContentProvider(fRightContentProvider);
- getRightMergeViewer().setLabelProvider(fRightLabelProvider);
- }
- super.updateMirrored(isMirrored);
- }
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareToolBar.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareToolBar.java
index 8d35abab5..a08df65b9 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareToolBar.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/CompareToolBar.java
@@ -10,6 +10,7 @@
* Stefan Dirix - bug 473985
* Conor O'Mahony - bug 507465
* Martin Fleck - bug 483798
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
@@ -34,7 +35,6 @@ import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIPlugin;
import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
-import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.MirrorUtil;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.CollapseAllModelAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.DropDownMergeMenuAction;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions.ExpandAllModelAction;
@@ -68,8 +68,6 @@ import org.eclipse.jface.bindings.TriggerSequence;
import org.eclipse.jface.bindings.keys.KeyBinding;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -86,7 +84,7 @@ import org.eclipse.ui.menus.IMenuService;
/**
* @author <a href="mailto:mikael.barbero@obeo.fr">Mikael Barbero</a>
*/
-public class CompareToolBar implements ISelectionChangedListener, IPropertyChangeListener {
+public class CompareToolBar implements ISelectionChangedListener {
private static final String COMPARE_EDITOR_SCOPE_ID = "org.eclipse.compare.compareEditorScope"; //$NON-NLS-1$
@@ -163,7 +161,6 @@ public class CompareToolBar implements ISelectionChangedListener, IPropertyChang
CompareHandlerService handlerService) {
if (!this.doOnce) {
compareConfiguration.getEventBus().register(this);
- compareConfiguration.addPropertyChangeListener(this);
// Add extension point contributions to the structure merge viewer toolbar
if (PlatformUI.isWorkbenchRunning()) {
@@ -246,13 +243,11 @@ public class CompareToolBar implements ISelectionChangedListener, IPropertyChang
toolbarManager.add(new SaveComparisonModelAction(compareConfiguration));
}
- setMirrored(MirrorUtil.isMirrored(compareConfiguration));
Arrays.stream(toolbarManager.getItems())
.filter(item -> item instanceof ActionContributionItem
&& ((ActionContributionItem)item).getAction().getActionDefinitionId() != null)
.map(ActionContributionItem.class::cast)
.forEach(item -> registerBinding(item, viewer, handlerService));
-
toolbarManager.update(true);
this.doOnce = true;
@@ -469,21 +464,6 @@ public class CompareToolBar implements ISelectionChangedListener, IPropertyChang
}
}
- public void setMirrored(boolean mirrored) {
- for (MergeAction action : mergeActions) {
- action.setMirrored(mirrored);
- }
- for (MergeAllNonConflictingAction action : mergeAllNonConflictingActions) {
- action.setMirrored(mirrored);
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (MirrorUtil.isMirroredProperty(event.getProperty())) {
- setMirrored(MirrorUtil.isMirrored(compareConfiguration));
- }
- }
-
private final class ActionWrapper extends Action {
private final AbstractTreeViewer viewer;
@@ -545,5 +525,4 @@ public class CompareToolBar implements ISelectionChangedListener, IPropertyChang
ToolBar toolbar = toolbarManager.getControl();
return toolbar != null && toolbar.isEnabled();
}
-
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/DependencyData.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/DependencyData.java
index 2ad486ebe..6c0d3dfce 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/DependencyData.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/DependencyData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 Obeo and others.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -9,6 +9,7 @@
* Obeo - initial API and implementation
* Martin Fleck - bug 514767
* Martin Fleck - bug 514415
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer;
@@ -84,6 +85,10 @@ public class DependencyData {
Iterable<Diff> selectedDiffs = filter(getSelectedComparisonObjects(selection), Diff.class);
MergeMode mergePreviewMode = compareConfiguration.getMergePreviewMode();
+ if (compareConfiguration.isMirrored() && (mergePreviewMode == MergeMode.LEFT_TO_RIGHT
+ || mergePreviewMode == MergeMode.RIGHT_TO_LEFT)) {
+ mergePreviewMode = mergePreviewMode.inverse();
+ }
requires = newHashSet();
rejectedDiffs = newHashSet();
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 5e65f09c3..cf5e05b1f 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 Obeo and others.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -8,7 +8,7 @@
* Contributors:
* Obeo - initial API and implementation
* Michael Borkowski - bug 467191
- * Philip Langer - bug 462884, 516576, 521948, 522372
+ * Philip Langer - bug 462884, 516576, 521948, 522372, 514079
* Stefan Dirix - bugs 473985, 474030
* Martin Fleck - bug 497066, 483798, 514767, 514415
* Alexandra Buzila - bug 513931
@@ -91,7 +91,7 @@ import org.eclipse.emf.compare.ide.internal.utils.NotLoadingResourceSet;
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.configuration.EMFCompareConfiguration;
-import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.MirrorUtil;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.ForwardingCompareConfiguration;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label.NoDifferencesCompareInput;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label.NoSelectedItemCompareInput;
import org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.label.NoVisibleItemCompareInput;
@@ -379,12 +379,10 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
private boolean cascadingDifferencesFilterEnabled;
- private IPropertyChangeListener fPreferenceChangeListener;
-
- private IPreferenceStore fPreferenceStore;
-
private boolean inChange;
+ private final ForwardingCompareConfiguration.MirroredPropertyChangeListener mirroredPropertyChangeListener;
+
/**
* Constructor.
*
@@ -496,33 +494,18 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
instanceOf(CascadingDifferencesFilter.class));
setCascadingDifferencesFilterEnabled(enabled);
- fPreferenceChangeListener = new IPropertyChangeListener() {
+ mirroredPropertyChangeListener = new ForwardingCompareConfiguration.MirroredPropertyChangeListener() {
@Override
- public void propertyChange(PropertyChangeEvent event) {
- EMFCompareStructureMergeViewer.this.handlePreferenceChangeEvent(event);
+ protected void mirroredPropertyChanged(boolean mirrored) {
+ EMFCompareConfiguration compareConfiguration = getCompareConfiguration();
+ MergeMode mergePreviewMode = compareConfiguration.getMergePreviewMode();
+ if (mergePreviewMode == MergeMode.LEFT_TO_RIGHT
+ || mergePreviewMode == MergeMode.RIGHT_TO_LEFT) {
+ compareConfiguration.setMergePreviewMode(mergePreviewMode.inverse());
+ }
}
};
-
- fPreferenceStore = getCompareConfiguration().getPreferenceStore();
- if (fPreferenceStore != null) {
- fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
- }
- }
-
- protected void handlePreferenceChangeEvent(PropertyChangeEvent event) {
- if (MirrorUtil.isMirroredPreference(event.getProperty())) {
- MirrorUtil.setMirrored(getCompareConfiguration(),
- Boolean.parseBoolean(event.getNewValue().toString()));
- // Since the content merge viewer will only be recreated, we simulate a selection change to
- // re-create the content merge viewer with correct sides
- ISelection originalSelection = getSelection();
-
- setSelection(null);
- getViewer().handleOpen(null); // parameter not used in super implementation -> null ok
-
- setSelection(originalSelection);
- getViewer().handleOpen(null);
- }
+ getCompareConfiguration().addPropertyChangeListener(mirroredPropertyChangeListener);
}
/**
@@ -1108,6 +1091,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
fHandlerService.dispose();
}
getCompareConfiguration().getEventBus().unregister(this);
+ getCompareConfiguration().removePropertyChangeListener(mirroredPropertyChangeListener);
getViewer().removeTreeListener(fWrappedTreeListener);
Object input = getInput();
if (input instanceof ICompareInput) {
@@ -1131,13 +1115,6 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
fDiffRelationshipComputer.invalidate();
toolBar.dispose();
fColors.dispose();
-
- if (fPreferenceChangeListener != null) {
- if (fPreferenceStore != null) {
- fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
- }
- fPreferenceChangeListener = null;
- }
super.handleDispose(event);
}
@@ -1587,8 +1564,9 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
// org.eclipse.team.internal.ui.mapping.ResourceCompareInputChangeNotifier$CompareInputLabelProvider
// who doesn't check a cast in its getAncestorLabel(), getLeftLabel() and getRightLabel() methods,
// we can't allow to add side label provider in case of an input of type ResourceDiffCompareInput.
+ EMFCompareConfiguration compareConfiguration = getCompareConfiguration();
if (!(input instanceof ResourceDiffCompareInput)) {
- ICompareInputLabelProvider labelProvider = getCompareConfiguration().getLabelProvider();
+ ICompareInputLabelProvider labelProvider = compareConfiguration.getLabelProvider();
SideLabelProvider sideLabelProvider = new SideLabelProvider(labelProvider.getAncestorLabel(input),
labelProvider.getLeftLabel(input), labelProvider.getRightLabel(input),
labelProvider.getAncestorImage(input), labelProvider.getLeftImage(input),
@@ -1599,8 +1577,20 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
new MatchOfContainmentReferenceChangeProcessor().execute(compareResult);
// Add a MergeData to handle status decorations on Diffs
- MergeDataImpl mergeData = new MergeDataImpl(getCompareConfiguration().isLeftEditable(),
- getCompareConfiguration().isRightEditable());
+ final MergeDataImpl mergeData = new MergeDataImpl(compareConfiguration.isLeftEditable(),
+ compareConfiguration.isRightEditable(), compareConfiguration.isMirrored());
+ compareConfiguration.addPropertyChangeListener(
+ new ForwardingCompareConfiguration.MirroredPropertyChangeListener() {
+ @Override
+ protected void mirroredPropertyChanged(boolean mirrored) {
+ mergeData.setMirrored(mirrored);
+ WrappableTreeViewer viewer = getViewer();
+ viewer.refresh();
+
+ // So that tool bar actions can update.
+ viewer.fireSelectionChanged(new SelectionChangedEvent(viewer, viewer.getSelection()));
+ }
+ });
compareResult.eAdapters().add(mergeData);
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
index 32b44fe1d..8ef978db9 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/actions/MergeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 Obeo and others.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -9,7 +9,7 @@
* Obeo - initial API and implementation
* Michael Borkowski - bug 462237
* Martin Fleck - bug 483798
- * Philip Langer - bugs 521948, 527567
+ * Philip Langer - bugs 521948, 527567, 514079
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.actions;
@@ -128,8 +128,6 @@ public class MergeAction extends BaseSelectionListenerAction {
private IEMFCompareConfiguration compareConfiguration;
- private boolean isMirrored;
-
/**
* Constructor.
*
@@ -216,18 +214,23 @@ public class MergeAction extends BaseSelectionListenerAction {
protected void contextualizeTooltip() {
if (this.selectedDifferences.size() > 1) {
// multiple selection
- setMultipleTooltip(this.selectedMode);
+ setMultipleTooltip(selectedMode);
} else if (this.selectedDifferences.isEmpty()) {
// no selection
- initToolTipAndImage(this.selectedMode);
+ initToolTipAndImage(selectedMode);
} else {
Diff diff = this.selectedDifferences.get(0);
- Object adapter = adapterFactory.adapt(diff, ITooltipLabelProvider.class);
- if (adapter instanceof ITooltipLabelProvider) {
- String tooltip = ((ITooltipLabelProvider)adapter).getTooltip(this.selectedMode);
- setToolTipText(tooltip);
+ // Only if the diff is unresolved will the current value of the model be meaningful.
+ if (diff.getState() == DifferenceState.UNRESOLVED) {
+ Object adapter = adapterFactory.adapt(diff, ITooltipLabelProvider.class);
+ if (adapter instanceof ITooltipLabelProvider) {
+ String tooltip = ((ITooltipLabelProvider)adapter).getTooltip(selectedMode);
+ setToolTipText(tooltip);
+ } else {
+ initToolTipAndImage(selectedMode);
+ }
} else {
- initToolTipAndImage(this.selectedMode);
+ initToolTipAndImage(selectedMode);
}
}
}
@@ -668,18 +671,6 @@ public class MergeAction extends BaseSelectionListenerAction {
}
/**
- * Refreshes the merge action by re-creating the necessary elements based on the current compare
- * configuration.
- */
- public void setMirrored(boolean mirrored) {
- if (selectedMode == ACCEPT || selectedMode == REJECT) {
- return;
- }
-
- this.isMirrored = mirrored;
- }
-
- /**
* @return the leftToRight
*/
protected final boolean isLeftToRight() {
@@ -716,6 +707,6 @@ public class MergeAction extends BaseSelectionListenerAction {
}
protected boolean isMirrored() {
- return isMirrored;
+ return compareConfiguration.isMirrored();
}
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/configuration/IEMFCompareConfiguration.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/configuration/IEMFCompareConfiguration.java
index 6beff7ef5..c3c661494 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/configuration/IEMFCompareConfiguration.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/configuration/IEMFCompareConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2015 Obeo.
+ * Copyright (c) 2013, 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.configuration;
@@ -64,4 +65,6 @@ public interface IEMFCompareConfiguration {
void setDiffRelationshipComputer(IDiffRelationshipComputer diffRelationshipComputer);
boolean getBooleanProperty(String key, boolean dflt);
+
+ boolean isMirrored();
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractMergeViewer.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractMergeViewer.java
index c19571ccb..4639f835b 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2014 Obeo.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 514079
*******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.impl;
@@ -67,6 +68,20 @@ public abstract class AbstractMergeViewer extends ContentViewer implements IMerg
}
/**
+ * Returns the effective side taking into account {@link CompareConfiguration#isMirrored()} to switch left
+ * and right.
+ *
+ * @param side
+ * @return the effective side with respect to mirroring.
+ */
+ protected MergeViewerSide getEffectiveSide() {
+ if (getCompareConfiguration().isMirrored()) {
+ return getSide().opposite();
+ }
+ return getSide();
+ }
+
+ /**
* Returns the compare configuration object used by this viewer.
*
* @return the compare configuration object used by this viewer.
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
index efbeb30e2..decd275a5 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/mergeviewer/impl/AbstractTableOrTreeMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2017 Obeo and others.
+ * Copyright (c) 2012, 2018 Obeo and others.
* 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
@@ -7,11 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
-<<<<<<< master
- * Philip Langer - bug 527858
-=======
- * Philip Langer - bug 527567
->>>>>>> dde9ebc [527567] Generalize the table and tree merge viewer framework
+ * Philip Langer - bug 527858, 514079, 527567
*******************************************************************************/
package org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.impl;
@@ -198,7 +194,7 @@ public abstract class AbstractTableOrTreeMergeViewer extends AbstractStructuredM
g.setLineStyle(SWT.LINE_SOLID);
}
- switch (getSide()) {
+ switch (getEffectiveSide()) {
case LEFT:
drawLineFromBoxToCenter(itemWrapper, bounds, g);
break;
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/IMergeData.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/IMergeData.java
index 69722ed46..57df3c759 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/IMergeData.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/IMergeData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 527567
*******************************************************************************/
package org.eclipse.emf.compare.internal.merge;
@@ -50,4 +51,18 @@ public interface IMergeData extends Adapter {
*/
void setRightEditable(boolean rightEditable);
+ /**
+ * Returns whether the left and right sides are swapped, i.e., mirrored.
+ *
+ * @return true if the left and right sides are swapped, i.e., mirrored, false otherwise.
+ */
+ boolean isMirrored();
+
+ /**
+ * Sets whether the left and right sides are swapped, i.e., mirrored.
+ *
+ * @param mirrored
+ * whether the left and right sides are swapped, i.e., mirrored, false otherwise.
+ */
+ void setMirrored(boolean mirrored);
}
diff --git a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/MergeDataImpl.java b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/MergeDataImpl.java
index 2a9c666b0..814b2408a 100644
--- a/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/MergeDataImpl.java
+++ b/plugins/org.eclipse.emf.compare/src/org/eclipse/emf/compare/internal/merge/MergeDataImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Obeo.
+ * Copyright (c) 2013, 2018 Obeo and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Philip Langer - bug 527567
*******************************************************************************/
package org.eclipse.emf.compare.internal.merge;
@@ -26,6 +27,9 @@ public class MergeDataImpl extends AdapterImpl implements IMergeData {
/** Right side is editable. */
private boolean rightEditable;
+ /** Left and right sides are swapped, i.e., mirrored. */
+ private boolean mirrored;
+
/**
* Constructor.
*
@@ -35,8 +39,23 @@ public class MergeDataImpl extends AdapterImpl implements IMergeData {
* Right side editable.
*/
public MergeDataImpl(boolean leftEditable, boolean rightEditable) {
+ this(leftEditable, rightEditable, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param leftEditable
+ * Left side editable.
+ * @param rightEditable
+ * Right side editable.
+ * @param mirrored
+ * Left and right side are swapped, i.e., mirrored.
+ */
+ public MergeDataImpl(boolean leftEditable, boolean rightEditable, boolean mirrored) {
this.leftEditable = leftEditable;
this.rightEditable = rightEditable;
+ this.mirrored = mirrored;
}
/**
@@ -80,4 +99,21 @@ public class MergeDataImpl extends AdapterImpl implements IMergeData {
this.rightEditable = rightEditable;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.internal.merge.IMergeData#isMirrored()
+ */
+ public boolean isMirrored() {
+ return mirrored;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.emf.compare.internal.merge.IMergeData#setMirrored(boolean)
+ */
+ public void setMirrored(boolean mirrored) {
+ this.mirrored = mirrored;
+ }
}

Back to the top