Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Groth2016-08-06 09:06:05 +0000
committerSergey Prigogin2016-10-02 19:53:05 +0000
commitd12c403fa89f023f6e29425649bab0780712002c (patch)
treef735432de0c6a79d799dc68461cdf463bb349b0c
parent64fa7e494663df59669e29209f632b51756fc170 (diff)
downloadeclipse.platform.team-d12c403fa89f023f6e29425649bab0780712002c.tar.gz
eclipse.platform.team-d12c403fa89f023f6e29425649bab0780712002c.tar.xz
eclipse.platform.team-d12c403fa89f023f6e29425649bab0780712002c.zip
Bug 213780 - Compare With direction should be configurable
add a preference to swap the left and right side of the merge viewer. This fix just swaps the left and right input for display. The model values for left and right are not changed. Change-Id: I4aa47e2e0389a0f1e8745e89b964296eb0b67678 Signed-off-by: Conrad Groth <info@conrad-groth.de>
-rw-r--r--bundles/org.eclipse.compare/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java95
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java194
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java416
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties5
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java33
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java38
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties6
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java113
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java55
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java146
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java11
-rw-r--r--bundles/org.eclipse.compare/icons/full/dlcl16/switch.pngbin0 -> 401 bytes
-rw-r--r--bundles/org.eclipse.compare/icons/full/elcl16/switch.pngbin0 -> 558 bytes
-rw-r--r--bundles/org.eclipse.compare/plugin.properties3
-rw-r--r--bundles/org.eclipse.compare/pom.xml2
-rw-r--r--examples/org.eclipse.compare.examples.xml/src/org/eclipse/compare/examples/xml/XMLStructureViewer.java1
17 files changed, 670 insertions, 450 deletions
diff --git a/bundles/org.eclipse.compare/META-INF/MANIFEST.MF b/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
index 823e37d40..b5b0c15f9 100644
--- a/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.compare/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.compare; singleton:=true
-Bundle-Version: 3.6.0.qualifier
+Bundle-Version: 3.7.0.qualifier
Bundle-Activator: org.eclipse.compare.internal.CompareUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
index aba9779de..6066657bb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation 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,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Alex Blewitt <alex.blewitt@gmail.com> - replace new Boolean with Boolean.valueOf - https://bugs.eclipse.org/470344
+ * Conrad Groth - Bug 213780 - Compare With direction should be configurable
*******************************************************************************/
package org.eclipse.compare;
@@ -42,7 +43,7 @@ import org.eclipse.swt.graphics.Image;
* A <code>CompareConfiguration</code> object
* controls various UI aspects of compare/merge viewers like
* title labels and images, or whether a side of a merge viewer is editable.
- * In addition to these fixed properties <code>ICompareConfiguration</code> provides
+ * In addition to these fixed properties <code>CompareConfiguration</code> provides
* API for an open ended set of properties. Different viewers which share the same
* configuration can communicate via this mechanism. E.g. if a compare editor
* has a button for controlling whether compare viewers ignore white space,
@@ -71,38 +72,46 @@ public class CompareConfiguration {
* @since 3.0
*/
public static final String USE_OUTLINE_VIEW= "USE_OUTLINE_VIEW"; //$NON-NLS-1$
-
- private static ImageDescriptor[] fgImages= new ImageDescriptor[16];
- private static boolean fLeftIsLocal= true;
-
- static {
- if (fLeftIsLocal) {
- fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_inadd_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outadd_ov.gif"); //$NON-NLS-1$
+ /**
+ * Name of the mirrored property, i.e. if left input is shown on the right side and vice versa.
+ * @since 3.7
+ */
+ public static final String MIRRORED = "MIRRORED"; //$NON-NLS-1$
- fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_indel_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outdel_ov.gif"); //$NON-NLS-1$
+ private static ImageDescriptor[] fgImages= new ImageDescriptor[32];
- fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_inchg_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_outchg_ov.gif"); //$NON-NLS-1$
- } else {
- fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/inadd_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/outadd_ov.gif"); //$NON-NLS-1$
+ static {
+ // Not swapped (a.k.a. left is local)
+ fgImages[Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_inadd_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outadd_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/indel_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/outdel_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_indel_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/r_outdel_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/inchg_ov.gif"); //$NON-NLS-1$
- fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/outchg_ov.gif"); //$NON-NLS-1$
- }
+ fgImages[Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_inchg_ov.gif"); //$NON-NLS-1$
+ fgImages[Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/r_outchg_ov.gif"); //$NON-NLS-1$
fgImages[Differencer.CONFLICTING + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/confadd_ov.gif"); //$NON-NLS-1$
fgImages[Differencer.CONFLICTING + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/confdel_ov.gif"); //$NON-NLS-1$
fgImages[Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.gif"); //$NON-NLS-1$
+
+ // Mirrored (a.k.a. right is local)
+ fgImages[16 + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/add_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.LEFT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/inadd_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.RIGHT + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/outadd_ov.gif"); //$NON-NLS-1$
+
+ fgImages[16 + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/del_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.LEFT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/indel_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.RIGHT + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/outdel_ov.gif"); //$NON-NLS-1$
+
+ fgImages[16 + Differencer.LEFT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/inchg_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.RIGHT + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/outchg_ov.gif"); //$NON-NLS-1$
+
+ fgImages[16 + Differencer.CONFLICTING + Differencer.ADDITION]= CompareUIPlugin.getImageDescriptor("ovr16/confadd_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.CONFLICTING + Differencer.DELETION]= CompareUIPlugin.getImageDescriptor("ovr16/confdel_ov.gif"); //$NON-NLS-1$
+ fgImages[16 + Differencer.CONFLICTING + Differencer.CHANGE]= CompareUIPlugin.getImageDescriptor("ovr16/confchg_ov.gif"); //$NON-NLS-1$
}
private IPreferenceStore fPreferenceStore;
@@ -251,25 +260,25 @@ public class CompareConfiguration {
* suitable default labels, and no images.
* The given preference store is used to connect this configuration
* with the Compare preference page properties <code>ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE</code>,
- * and <code>CompareConfiguration.IGNORE_WHITESPACE</code>.
+ * <code>CompareConfiguration.IGNORE_WHITESPACE</code> and {@link #MIRRORED}
*
* @param prefStore the preference store which this configuration holds onto.
* @since 2.0
*/
public CompareConfiguration(IPreferenceStore prefStore) {
-
- setProperty("LEFT_IS_LOCAL", Boolean.valueOf(fLeftIsLocal)); //$NON-NLS-1$
-
fPreferenceStore= prefStore;
if (fPreferenceStore != null) {
boolean b= fPreferenceStore.getBoolean(ComparePreferencePage.INITIALLY_SHOW_ANCESTOR_PANE);
setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, Boolean.valueOf(b));
-
+
b= fPreferenceStore.getBoolean(ComparePreferencePage.IGNORE_WHITESPACE);
setProperty(CompareConfiguration.IGNORE_WHITESPACE, Boolean.valueOf(b));
+
+ b= fPreferenceStore.getBoolean(ComparePreferencePage.SWAPPED);
+ setProperty(CompareConfiguration.MIRRORED, Boolean.valueOf(b));
}
- }
-
+ }
+
/**
* Creates a new configuration with editable left and right sides,
* suitable default labels, and no images.
@@ -303,7 +312,7 @@ public class CompareConfiguration {
public Image getImage(int kind) {
if (fDisposed)
return null;
- ImageDescriptor id= fgImages[kind & 15];
+ ImageDescriptor id= getImageDescriptor(kind);
ResourceManager rm = getResourceManager();
return rm.createImage(id);
}
@@ -331,11 +340,25 @@ public class CompareConfiguration {
public Image getImage(Image base, int kind) {
if (fDisposed)
return null;
- kind &= 15;
- ImageDescriptor id = new DiffImageDescriptor(base, fgImages[kind], ICompareUIConstants.COMPARE_IMAGE_WIDTH, !fLeftIsLocal);
+ ImageDescriptor id = new DiffImageDescriptor(base, getImageDescriptor(kind), ICompareUIConstants.COMPARE_IMAGE_WIDTH, false);
ResourceManager rm = getResourceManager();
return rm.createImage(id);
}
+
+ /**
+ * <b>Only the views are mirrored. All model values for left and right are not changed!</b>
+ *
+ * @return true if the left and right side of the viewer are mirrored. Default is false.
+ * @since 3.7
+ */
+ public boolean isMirrored() {
+ Object property = getProperty(MIRRORED);
+ return property instanceof Boolean && (Boolean) property;
+ }
+
+ private ImageDescriptor getImageDescriptor(int kind) {
+ return fgImages[(kind & 15) + (isMirrored() ? 16 : 0)];
+ }
/**
* Dispose of this compare configuration.
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index 81cd5603b..5587587eb 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation 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,10 +9,12 @@
* IBM Corporation - initial API and implementation
* Alex Blewitt <alex.blewitt@gmail.com> - replace new Boolean with Boolean.valueOf - https://bugs.eclipse.org/470344
* Stefan Xenos <sxenos@gmail.com> (Google) - bug 448968 - Add diagnostic logging
+ * Conrad Groth - Bug 213780 - Compare With direction should be configurable
*******************************************************************************/
package org.eclipse.compare.contentmergeviewer;
+import java.io.IOException;
import java.util.ResourceBundle;
import org.eclipse.compare.CompareConfiguration;
@@ -26,11 +28,13 @@ import org.eclipse.compare.internal.ChangePropertyAction;
import org.eclipse.compare.internal.CompareEditor;
import org.eclipse.compare.internal.CompareHandlerService;
import org.eclipse.compare.internal.CompareMessages;
+import org.eclipse.compare.internal.ComparePreferencePage;
import org.eclipse.compare.internal.CompareUIPlugin;
import org.eclipse.compare.internal.ICompareUIConstants;
import org.eclipse.compare.internal.IFlushable2;
import org.eclipse.compare.internal.ISavingSaveable;
import org.eclipse.compare.internal.MergeViewerContentProvider;
+import org.eclipse.compare.internal.MirroredMergeViewerContentProvider;
import org.eclipse.compare.internal.Policy;
import org.eclipse.compare.internal.Utilities;
import org.eclipse.compare.internal.ViewerSwitchingCancelled;
@@ -49,6 +53,8 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ContentViewer;
@@ -116,10 +122,12 @@ public abstract class ContentMergeViewer extends ContentViewer
private class ContentMergeViewerLayout extends Layout {
+ @Override
public Point computeSize(Composite c, int w, int h, boolean force) {
return new Point(100, 100);
}
+ @Override
public void layout(Composite composite, boolean force) {
if (fLeftLabel == null) {
@@ -131,7 +139,7 @@ public abstract class ContentMergeViewer extends ContentViewer
logTrace("found bad label. Layout = " + System.identityHashCode(this) + ". composite = " //$NON-NLS-1$//$NON-NLS-2$
+ System.identityHashCode(composite) + ". fComposite = " //$NON-NLS-1$
+ System.identityHashCode(fComposite) + ". fComposite.isDisposed() = " //$NON-NLS-1$
- + fComposite.isDisposed()); //$NON-NLS-2$
+ + fComposite.isDisposed());
logStackTrace();
}
// Help to find out the cause for bug 449558
@@ -233,6 +241,7 @@ public abstract class ContentMergeViewer extends ContentViewer
fControl.addMouseMoveListener(this);
fControl.addDisposeListener(
new DisposeListener() {
+ @Override
public void widgetDisposed(DisposeEvent e) {
fControl= null;
}
@@ -240,6 +249,7 @@ public abstract class ContentMergeViewer extends ContentViewer
);
}
+ @Override
public void mouseDoubleClick(MouseEvent e) {
if ((fDirection & HORIZONTAL) != 0)
fHSplit= -1;
@@ -248,6 +258,7 @@ public abstract class ContentMergeViewer extends ContentViewer
fComposite.layout(true);
}
+ @Override
public void mouseDown(MouseEvent e) {
Composite parent= fControl.getParent();
@@ -266,12 +277,14 @@ public abstract class ContentMergeViewer extends ContentViewer
fIsDown= true;
}
+ @Override
public void mouseUp(MouseEvent e) {
fIsDown= false;
if (!fLiveResize)
resize(e);
}
+ @Override
public void mouseMove(MouseEvent e) {
if (fIsDown && fLiveResize)
resize(e);
@@ -317,14 +330,17 @@ public abstract class ContentMergeViewer extends ContentViewer
private boolean fAncestorVisible; // whether the ancestor pane is visible
private ActionContributionItem fAncestorItem;
- private Action fCopyLeftToRightAction; // copy from left to right
- private Action fCopyRightToLeftAction; // copy from right to left
+ private ActionContributionItem copyLeftToRightItem; // copy from left to right
+ private ActionContributionItem copyRightToLeftItem; // copy from right to left
private boolean fIsLeftDirty;
private boolean fIsRightDirty;
private CompareHandlerService fHandlerService;