Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConrad Groth2016-06-24 22:01:32 +0000
committerSergey Prigogin2016-07-11 04:55:04 +0000
commitec30f62a24da6e8e47dbb3a566049c628bb74f05 (patch)
tree47e6a155895fbd9b4a99f96d969e50715d5c9e80
parent3b06c860315edfe76f726daffefe3b4377cf3226 (diff)
downloadeclipse.platform.team-ec30f62a24da6e8e47dbb3a566049c628bb74f05.tar.gz
eclipse.platform.team-ec30f62a24da6e8e47dbb3a566049c628bb74f05.tar.xz
eclipse.platform.team-ec30f62a24da6e8e47dbb3a566049c628bb74f05.zip
Bug 213780 - Compare With direction should be configurable
Added a preference to toggle the left and right side of the merge viewer. This fix just toggles the left and right input for display. The model values for left and right are not changed. Change-Id: I771407d511ff5af36fe694426e3f265c2fd7c3c3 Signed-off-by: Conrad Groth <info@conrad-groth.de>
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java42
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java37
-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/ComparePreferencePage.java79
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java3
-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.java97
-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
10 files changed, 227 insertions, 45 deletions
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..2537a6577 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;
@@ -71,34 +72,21 @@ 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$
-
- 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$
+ 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$
- 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$
-
- 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/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$
- 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$
@@ -264,12 +252,14 @@ public class CompareConfiguration {
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));
+
+ setProperty(ComparePreferencePage.LAYOUT, fPreferenceStore.getString(ComparePreferencePage.LAYOUT));
}
- }
-
+ }
+
/**
* Creates a new configuration with editable left and right sides,
* suitable default labels, and no images.
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..58ae50ac2 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,6 +9,7 @@
* 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;
@@ -26,11 +27,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;
@@ -354,6 +357,8 @@ public abstract class ContentMergeViewer extends ContentViewer
}
}
};
+ private final MergeViewerContentProvider defaultContentProvider;
+ private boolean leftToRight;
//---- end
@@ -378,7 +383,10 @@ public abstract class ContentMergeViewer extends ContentViewer
fAncestorVisible= Utilities.getBoolean(cc, ICompareUIConstants.PROP_ANCESTOR_VISIBLE, fAncestorVisible);
fConfirmSave= Utilities.getBoolean(cc, CompareEditor.CONFIRM_SAVE_PROPERTY, fConfirmSave);
- setContentProvider(new MergeViewerContentProvider(cc));
+ defaultContentProvider = new MergeViewerContentProvider(cc);
+ leftToRight = ICompareUIConstants.PREF_VALUE_LEFT_TO_RIGHT
+ .equals(cc.getProperty(ComparePreferencePage.LAYOUT));
+ updateContentProvider();
fCompareInputChangeListener= new ICompareInputChangeListener() {
public void compareInputChanged(ICompareInput input) {
@@ -535,6 +543,12 @@ public abstract class ContentMergeViewer extends ContentViewer
super.setContentProvider(contentProvider);
}
+ private void updateContentProvider() {
+ setContentProvider(leftToRight
+ ? new MirroredMergeViewerContentProvider(defaultContentProvider)
+ : defaultContentProvider);
+ }
+
/* package */ IMergeViewerContentProvider getMergeContentProvider() {
return (IMergeViewerContentProvider) getContentProvider();
}
@@ -586,6 +600,13 @@ public abstract class ContentMergeViewer extends ContentViewer
setAncestorVisibility(false, !Utilities.getBoolean(getCompareConfiguration(), ICompareUIConstants.PROP_IGNORE_ANCESTOR, false));
return;
}
+
+ if (key.equals(ComparePreferencePage.LAYOUT)) {
+ leftToRight = ICompareUIConstants.PREF_VALUE_LEFT_TO_RIGHT
+ .equals(event.getNewValue());
+ updateContentProvider();
+ return;
+ }
}
void updateCursor(Control c, int dir) {
@@ -920,6 +941,16 @@ public abstract class ContentMergeViewer extends ContentViewer
tbm.appendToGroup("merge", fCopyRightToLeftAction); //$NON-NLS-1$
fHandlerService.registerAction(fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); //$NON-NLS-1$
}
+
+ Action switchLeftAndRight = new Action() {
+ @Override
+ public void run() {
+ leftToRight = !leftToRight;
+ updateContentProvider();
+ }
+ };
+ Utilities.initAction(switchLeftAndRight, getResourceBundle(), "action.SwitchLeftAndRight."); //$NON-NLS-1$
+ tbm.appendToGroup("modes", switchLeftAndRight); //$NON-NLS-1$
final ChangePropertyAction a= new ChangePropertyAction(fBundle, getCompareConfiguration(), "action.EnableAncestor.", ICompareUIConstants.PROP_ANCESTOR_VISIBLE); //$NON-NLS-1$
a.setChecked(fAncestorVisible);
@@ -927,7 +958,7 @@ public abstract class ContentMergeViewer extends ContentViewer
fAncestorItem.setVisible(false);
tbm.appendToGroup("modes", fAncestorItem); //$NON-NLS-1$
tbm.getControl().addDisposeListener(a);
-
+
createToolItems(tbm);
updateToolItems();
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
index a459d147f..fa02b6778 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewerResources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 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
@@ -73,6 +73,9 @@ action.IgnoreAncestor.description.unchecked=Two-Way Compare (Ignore Ancestor)
action.IgnoreAncestor.description.checked=Three-Way Compare
action.IgnoreAncestor.image=twowaycompare_co.gif
+action.SwitchLeftAndRight.label=Switch Left and Right View
+action.SwitchLeftAndRight.tooltip=Switch Left and Right View
+action.SwitchLeftAndRight.image=switch.png
#####################################################
# Context menu actions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 8fe2bee11..f536729e1 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.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,13 +8,16 @@
* 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.internal;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
@@ -25,6 +28,8 @@ import org.eclipse.compare.internal.core.ComparePlugin;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
@@ -98,13 +103,14 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public static final String PATH_FILTER= PREFIX + "PathFilter"; //$NON-NLS-1$
public static final String ADDED_LINES_REGEX= PREFIX + "AddedLinesRegex"; //$NON-NLS-1$
public static final String REMOVED_LINES_REGEX= PREFIX + "RemovedLinesRegex"; //$NON-NLS-1$
+ public static final String LAYOUT = PREFIX + "Layout"; //$NON-NLS-1$
-
+
private TextMergeViewer fPreviewViewer;
private IPropertyChangeListener fPreferenceChangeListener;
private CompareConfiguration fCompareConfiguration;
private OverlayPreferenceStore fOverlayStore;
- private Map fCheckBoxes= new HashMap();
+ private Map<Button, String> fCheckBoxes = new HashMap<>();
private Text fFilters;
private Text addedLinesRegex;
private Text removedLinesRegex;
@@ -129,8 +135,9 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PATH_FILTER),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, LAYOUT),
};
- private RadioGroupFieldEditor editor;
+ private List<FieldEditor> editors = new ArrayList<>();
private TabItem fTextCompareTab;
private Button fDisableCappingCheckBox;
@@ -153,6 +160,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
store.setDefault(PATH_FILTER, ""); //$NON-NLS-1$
store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION, ICompareUIConstants.PREF_VALUE_PROMPT);
store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL, ICompareUIConstants.PREF_VALUE_LOOP);
+ store.setDefault(LAYOUT, ICompareUIConstants.PREF_VALUE_LEFT_TO_RIGHT);
}
public ComparePreferencePage() {
@@ -190,7 +198,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.setValue(ADDED_LINES_REGEX, addedLinesRegex.getText());
fOverlayStore.setValue(REMOVED_LINES_REGEX, removedLinesRegex.getText());
- editor.store();
+ editors.forEach(editor -> editor.store());
fOverlayStore.propagate();
ComparePlugin.getDefault().setCappingDisabled(
@@ -206,7 +214,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.loadDefaults();
initializeFields();
-
+
+ // Workaround for Bug 497619
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.setProperty(LAYOUT, fOverlayStore.getString(LAYOUT));
+ }
+
super.performDefaults();
}
@@ -356,10 +369,13 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
addCheckBox(composite, "ComparePreferencePage.highlightTokenChanges.label", HIGHLIGHT_TOKEN_CHANGES, 0); //$NON-NLS-1$
//addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$
fDisableCappingCheckBox = addCheckBox(composite, "ComparePreferencePage.disableCapping.label", CAPPING_DISABLED, 0); //$NON-NLS-1$
+ addLayoutCombo(composite);
Composite radioGroup = new Composite(composite, SWT.NULL);
radioGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- editor = new RadioGroupFieldEditor(ICompareUIConstants.PREF_NAVIGATION_END_ACTION, CompareMessages.ComparePreferencePage_0, 1,
+ RadioGroupFieldEditor editor = new RadioGroupFieldEditor(
+ ICompareUIConstants.PREF_NAVIGATION_END_ACTION,
+ CompareMessages.ComparePreferencePage_0, 1,
new String[][] {
new String[] { CompareMessages.ComparePreferencePage_1, ICompareUIConstants.PREF_VALUE_PROMPT },
new String[] { CompareMessages.ComparePreferencePage_2, ICompareUIConstants.PREF_VALUE_LOOP },
@@ -369,6 +385,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
radioGroup, true);
editor.setPreferenceStore(fOverlayStore);
editor.fillIntoGrid(radioGroup, 1);
+ editors.add(editor);
// a spacer
Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
@@ -427,10 +444,10 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
private void initializeFields() {
- Iterator e= fCheckBoxes.keySet().iterator();
+ Iterator<Button> e = fCheckBoxes.keySet().iterator();
while (e.hasNext()) {
- Button b= (Button) e.next();
- String key= (String) fCheckBoxes.get(b);
+ Button b = e.next();
+ String key= fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key));
}
@@ -441,7 +458,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
if (removedLinesRegex != null)
removedLinesRegex.setText(fOverlayStore.getString(REMOVED_LINES_REGEX));
- editor.load();
+ editors.forEach(editor -> editor.load());
}
// overlay stuff
@@ -455,14 +472,13 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
checkBox.setLayoutData(gd);
if (fCheckBoxListener == null) {
fCheckBoxListener= new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button= (Button) e.widget;
- fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
+ fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection());
}
};
}
@@ -472,7 +488,42 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
return checkBox;
}
-
+
+ private void addLayoutCombo(Composite parent) {
+ Composite c2 = new Composite(parent, SWT.NONE);
+ c2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ c2.setLayout(layout);
+
+ ComboFieldEditor layoutEditor = new ComboFieldEditor(LAYOUT,
+ Utilities.getString("ComparePreferencePage.layout.label"), //$NON-NLS-1$
+ new String[][]{
+ getLayoutEntry(
+ ICompareUIConstants.PREF_VALUE_RIGHT_TO_LEFT),
+ getLayoutEntry(
+ ICompareUIConstants.PREF_VALUE_LEFT_TO_RIGHT)},
+ c2);
+
+ layoutEditor.fillIntoGrid(c2, 2);
+ layoutEditor.setPreferenceStore(fOverlayStore);
+ editors.add(layoutEditor);
+
+ layoutEditor.setPropertyChangeListener(new IPropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (fCompareConfiguration != null) {
+ fCompareConfiguration.setProperty(LAYOUT, event.getNewValue());
+ }
+ }
+ });
+ }
+
+ private String[] getLayoutEntry(String value) {
+ String labelKey = "ComparePreferencePage.layout." + value; //$NON-NLS-1$
+ return new String[]{Utilities.getString(labelKey), value};
+ }
+
private String loadPreviewContentFromFile(String key) {
String preview= Utilities.getString(key);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
index 8c0641678..0cbf825e0 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareUIConstants.java
@@ -50,4 +50,7 @@ public interface ICompareUIConstants {
public static final String PREF_VALUE_DO_NOTHING = "doNothing"; //$NON-NLS-1$
public static final String COMMAND_IGNORE_WHITESPACE = PREFIX + "ignoreWhiteSpace"; //$NON-NLS-1$
+
+ public static final String PREF_VALUE_LEFT_TO_RIGHT = "leftToRight"; //$NON-NLS-1$
+ public static final String PREF_VALUE_RIGHT_TO_LEFT = "rightToLeft"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties
index 3e733b451..439603d3e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ImageMergeViewerResources.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 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
@@ -30,3 +30,7 @@ action.CopyRightToLeft.image= elcl16/copy_l_co.gif
action.EnableAncestor.label= Enable Ancestor Pane
action.EnableAncestor.tooltip= Control Visibility of Ancestor Pane
action.EnableAncestor.image= elcl16/ancestorpane_co.gif
+
+action.SwitchLeftAndRight.label=Switch Left and Right View
+action.SwitchLeftAndRight.tooltip=Switch Left and Right View
+action.SwitchLeftAndRight.image=switch.png
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java
new file mode 100644
index 000000000..864c1953d
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/MirroredMergeViewerContentProvider.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Conrad Groth 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:
+ * Conrad Groth - Bug 213780 - Compare With direction should be configurable
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * This class just swaps the left and right input for display.
+ * The model values for left and right are not changed.
+ */
+public class MirroredMergeViewerContentProvider implements IMergeViewerContentProvider {
+
+ private IMergeViewerContentProvider delegate;
+
+ public MirroredMergeViewerContentProvider(IMergeViewerContentProvider delegate) {
+ this.delegate = delegate;
+ }
+
+ @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 boolean isLeftEditable(Object input) {
+ return delegate.isRightEditable(input);
+ }
+
+ @Override
+ public void saveLeftContent(Object input, byte[] bytes) {
+ delegate.saveRightContent(input, bytes);
+ }
+
+ @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 boolean isRightEditable(Object input) {
+ return delegate.isLeftEditable(input);
+ }
+
+ @Override
+ public void saveRightContent(Object input, byte[] bytes) {
+ delegate.saveLeftContent(input, bytes);
+ }
+
+ @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 boolean showAncestor(Object input) {
+ return delegate.showAncestor(input);
+ }
+}
diff --git a/bundles/org.eclipse.compare/icons/full/dlcl16/switch.png b/bundles/org.eclipse.compare/icons/full/dlcl16/switch.png
new file mode 100644
index 000000000..f3132b9dc
--- /dev/null
+++ b/bundles/org.eclipse.compare/icons/full/dlcl16/switch.png
Binary files differ
diff --git a/bundles/org.eclipse.compare/icons/full/elcl16/switch.png b/bundles/org.eclipse.compare/icons/full/elcl16/switch.png
new file mode 100644
index 000000000..96cef47ee
--- /dev/null
+++ b/bundles/org.eclipse.compare/icons/full/elcl16/switch.png
Binary files differ
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index 9335310b5..55e120c35 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -132,6 +132,9 @@ ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between
ComparePreferencePage.useSingleLine.label= Connect &ranges with single line
ComparePreferencePage.highlightTokenChanges.label=&Highlight individual changes
ComparePreferencePage.disableCapping.label=Disable &capping when comparing large documents
+ComparePreferencePage.layout.label=La&yout:
+ComparePreferencePage.layout.rightToLeft=Right to left
+ComparePreferencePage.layout.leftToRight=Left to right
ComparePreferencePage.preview.label= Previe&w:
ComparePreferencePage.ancestor.label= Common Ancestor

Back to the top