Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2007-03-27 16:05:49 +0000
committerMichael Valenta2007-03-27 16:05:49 +0000
commit441047722497380c34bda93a874deb9954e12310 (patch)
treeab934f04133ae3284817dfcbb5636e48af45f59a /bundles/org.eclipse.compare
parent09763d62d94ac561bd3cae616d807cb4c1c43103 (diff)
downloadeclipse.platform.team-441047722497380c34bda93a874deb9954e12310.tar.gz
eclipse.platform.team-441047722497380c34bda93a874deb9954e12310.tar.xz
eclipse.platform.team-441047722497380c34bda93a874deb9954e12310.zip
Bug 89648 [Edit] Provide option to revert to Text compare
Diffstat (limited to 'bundles/org.eclipse.compare')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java29
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java58
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties1
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java25
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java22
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java29
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java58
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties1
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java25
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java22
10 files changed, 238 insertions, 32 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 1c6f3e8c4..bc4133d5d 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -11,8 +11,7 @@
package org.eclipse.compare;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.ResourceBundle;
+import java.util.*;
import org.eclipse.compare.contentmergeviewer.IFlushable;
import org.eclipse.compare.internal.*;
@@ -164,6 +163,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
private String fHelpContextId;
private InternalOutlineViewerCreator fOutlineView;
+ private ICompareAsText fCompareAsText;
private class InternalOutlineViewerCreator extends OutlineViewerCreator {
private OutlineViewerCreator getWrappedCreator() {
@@ -196,6 +196,12 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
return null;
}
}
+
+ private class CompareAsText implements ICompareAsText {
+ public void compareAsText(Object input) {
+ internalCompareAsText(input);
+ }
+ }
/**
* Creates a <code>CompareEditorInput</code> which is initialized with the given
@@ -233,6 +239,20 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
configuration.setContainer(this);
}
+ /* package */ void internalCompareAsText(Object input) {
+ Set set = (Set)getCompareConfiguration().getProperty(ICompareAsText.PROP_TEXT_INPUTS);
+ if (set == null) {
+ set = new HashSet();
+ getCompareConfiguration().setProperty(ICompareAsText.PROP_TEXT_INPUTS, set);
+ }
+ set.add(input);
+ if (fContentInputPane.getInput().equals(input)) {
+ // We need to null the input and then reset it so we get the text merge viewer
+ fContentInputPane.setInput(null);
+ fContentInputPane.setInput(input);
+ }
+ }
+
private boolean structureCompareOnSingleClick() {
return fStructureCompareOnSingleClick;
}
@@ -265,6 +285,11 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
return fOutlineView;
}
}
+ if (adapter == ICompareAsText.class) {
+ if (fCompareAsText == null)
+ fCompareAsText = new CompareAsText();
+ return fCompareAsText;
+ }
return null;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
index f9bd97342..01e54e12c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
@@ -15,6 +15,10 @@ import java.util.ResourceBundle;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.PlatformUI;
import org.eclipse.core.runtime.CoreException;
@@ -30,30 +34,67 @@ public class BinaryCompareViewer extends AbstractViewer {
private static final String BUNDLE_NAME= "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$
private static final int EOF= -1;
- private Label fControl;
private ICompareInput fInput;
private ResourceBundle fBundle;
private boolean fLeftIsLocal;
+
+ private Composite fComposite;
+ private Label fMessage;
+ private Button fTextButton;
- public BinaryCompareViewer(Composite parent, CompareConfiguration cc) {
+ public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW);
fBundle= ResourceBundle.getBundle(BUNDLE_NAME);
+
+ fComposite= new Composite(parent, SWT.NONE);
+ RowLayout rowLayout = new RowLayout();
+ rowLayout.type = SWT.VERTICAL;
+ fComposite.setLayout(rowLayout);
- fControl= new Label(parent, SWT.WRAP);
- fControl.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
+ fMessage= new Label(fComposite, SWT.WRAP);
+ fMessage.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
+
+ if (canShowAsText(cc)) {
+ fTextButton = new Button(fComposite, SWT.PUSH);
+ fTextButton.setText(Utilities.getString(fBundle, "compareAsText")); //$NON-NLS-1$
+ fTextButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
+ public void run() {
+ handleShowAsText(cc);
+ }
+ });
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+ });
+ fTextButton.setEnabled(false);
+ }
+ }
+
+ private boolean canShowAsText(CompareConfiguration cc) {
+ if (cc == null)
+ return false;
+ return Utilities.getAdapter(cc.getContainer(), ICompareAsText.class) != null;
+ }
+
+ protected void handleShowAsText(CompareConfiguration cc) {
+ ICompareAsText comparer = (ICompareAsText)Utilities.getAdapter(cc.getContainer(), ICompareAsText.class);
+ comparer.compareAsText(getInput());
}
public Control getControl() {
- return fControl;
+ return fComposite;
}
public void setInput(Object input) {
- if (fControl != null && input instanceof ICompareInput) {
+ if (fComposite != null && input instanceof ICompareInput) {
fInput= (ICompareInput) input;
InputStream left= null;
@@ -100,7 +141,10 @@ public class BinaryCompareViewer extends AbstractViewer {
Utilities.close(right);
}
if (message != null)
- fControl.setText(message);
+ fMessage.setText(message);
+ if (fTextButton != null)
+ fTextButton.setEnabled(true);
+ fComposite.layout();
}
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
index 6d61c8ab1..3f839e136 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
@@ -20,3 +20,4 @@ deleteConflictMessage= Delete Conflict
addedMessage= Added Resource
deletedMessage= Removed Resource
errorMessage= Internal Error
+compareAsText= Compare as Text
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index dd6f26e2d..6aa1f096c 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -25,8 +25,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.*;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
@@ -58,9 +58,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$
- private HashMap fIdMap; // maps ids to datas
- private HashMap fExtensionMap; // maps extensions to datas
- private HashMap fContentTypeBindings; // maps content type bindings to datas
+ private HashMap fIdMap; // maps ids to data
+ private HashMap fExtensionMap; // maps extensions to data
+ private HashMap fContentTypeBindings; // maps content type bindings to data
void register(IConfigurationElement element, Object data) {
@@ -300,7 +300,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fStructureCreators.createBinding(element, STRUCTURE_CREATOR_ID_ATTRIBUTE);
}
- // collect all viewers which define the structure mergeviewer extension point
+ // collect all viewers which define the structure merge viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGE_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
@@ -317,7 +317,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fStructureMergeViewers.createBinding(element, STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE);
}
- // collect all viewers which define the content mergeviewer extension point
+ // collect all viewers which define the content merge viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGE_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
@@ -805,8 +805,12 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
ICompareInput input= (ICompareInput) in;
+
IContentType ctype= getCommonType(input);
+ if (isCompareAsText(input, cc)) {
+ ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
+ }
if (ctype != null) {
initializeRegistries();
Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc);
@@ -861,6 +865,13 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
}
+ private boolean isCompareAsText(ICompareInput input, CompareConfiguration cc) {
+ Set set = (Set)cc.getProperty(ICompareAsText.PROP_TEXT_INPUTS);
+ if (set == null)
+ return false;
+ return set.contains(input);
+ }
+
private static Viewer getViewer(Object descriptor, Viewer oldViewer, Composite parent, CompareConfiguration cc) {
if (descriptor instanceof IViewerDescriptor)
return ((IViewerDescriptor)descriptor).createViewer(oldViewer, parent, cc);
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java
new file mode 100644
index 000000000..1476a6fb1
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+public interface ICompareAsText {
+
+ /**
+ * Property key for the set of test inputs (instance of Set)
+ */
+ public static final String PROP_TEXT_INPUTS = "org.eclipse.compare.TextInputs"; //$NON-NLS-1$
+
+ public void compareAsText(Object input);
+
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
index 1c6f3e8c4..bc4133d5d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java
@@ -11,8 +11,7 @@
package org.eclipse.compare;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.ResourceBundle;
+import java.util.*;
import org.eclipse.compare.contentmergeviewer.IFlushable;
import org.eclipse.compare.internal.*;
@@ -164,6 +163,7 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
private String fHelpContextId;
private InternalOutlineViewerCreator fOutlineView;
+ private ICompareAsText fCompareAsText;
private class InternalOutlineViewerCreator extends OutlineViewerCreator {
private OutlineViewerCreator getWrappedCreator() {
@@ -196,6 +196,12 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
return null;
}
}
+
+ private class CompareAsText implements ICompareAsText {
+ public void compareAsText(Object input) {
+ internalCompareAsText(input);
+ }
+ }
/**
* Creates a <code>CompareEditorInput</code> which is initialized with the given
@@ -233,6 +239,20 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
configuration.setContainer(this);
}
+ /* package */ void internalCompareAsText(Object input) {
+ Set set = (Set)getCompareConfiguration().getProperty(ICompareAsText.PROP_TEXT_INPUTS);
+ if (set == null) {
+ set = new HashSet();
+ getCompareConfiguration().setProperty(ICompareAsText.PROP_TEXT_INPUTS, set);
+ }
+ set.add(input);
+ if (fContentInputPane.getInput().equals(input)) {
+ // We need to null the input and then reset it so we get the text merge viewer
+ fContentInputPane.setInput(null);
+ fContentInputPane.setInput(input);
+ }
+ }
+
private boolean structureCompareOnSingleClick() {
return fStructureCompareOnSingleClick;
}
@@ -265,6 +285,11 @@ public abstract class CompareEditorInput implements IEditorInput, IPropertyChang
return fOutlineView;
}
}
+ if (adapter == ICompareAsText.class) {
+ if (fCompareAsText == null)
+ fCompareAsText = new CompareAsText();
+ return fCompareAsText;
+ }
return null;
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
index f9bd97342..01e54e12c 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewer.java
@@ -15,6 +15,10 @@ import java.util.ResourceBundle;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.PlatformUI;
import org.eclipse.core.runtime.CoreException;
@@ -30,30 +34,67 @@ public class BinaryCompareViewer extends AbstractViewer {
private static final String BUNDLE_NAME= "org.eclipse.compare.internal.BinaryCompareViewerResources"; //$NON-NLS-1$
private static final int EOF= -1;
- private Label fControl;
private ICompareInput fInput;
private ResourceBundle fBundle;
private boolean fLeftIsLocal;
+
+ private Composite fComposite;
+ private Label fMessage;
+ private Button fTextButton;
- public BinaryCompareViewer(Composite parent, CompareConfiguration cc) {
+ public BinaryCompareViewer(Composite parent, final CompareConfiguration cc) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICompareContextIds.BINARY_COMPARE_VIEW);
fBundle= ResourceBundle.getBundle(BUNDLE_NAME);
+
+ fComposite= new Composite(parent, SWT.NONE);
+ RowLayout rowLayout = new RowLayout();
+ rowLayout.type = SWT.VERTICAL;
+ fComposite.setLayout(rowLayout);
- fControl= new Label(parent, SWT.WRAP);
- fControl.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
+ fMessage= new Label(fComposite, SWT.WRAP);
+ fMessage.setData(CompareUI.COMPARE_VIEWER_TITLE, Utilities.getString(fBundle, "title")); //$NON-NLS-1$
fLeftIsLocal= Utilities.getBoolean(cc, "LEFT_IS_LOCAL", false); //$NON-NLS-1$
+
+ if (canShowAsText(cc)) {
+ fTextButton = new Button(fComposite, SWT.PUSH);
+ fTextButton.setText(Utilities.getString(fBundle, "compareAsText")); //$NON-NLS-1$
+ fTextButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
+ public void run() {
+ handleShowAsText(cc);
+ }
+ });
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+ });
+ fTextButton.setEnabled(false);
+ }
+ }
+
+ private boolean canShowAsText(CompareConfiguration cc) {
+ if (cc == null)
+ return false;
+ return Utilities.getAdapter(cc.getContainer(), ICompareAsText.class) != null;
+ }
+
+ protected void handleShowAsText(CompareConfiguration cc) {
+ ICompareAsText comparer = (ICompareAsText)Utilities.getAdapter(cc.getContainer(), ICompareAsText.class);
+ comparer.compareAsText(getInput());
}
public Control getControl() {
- return fControl;
+ return fComposite;
}
public void setInput(Object input) {
- if (fControl != null && input instanceof ICompareInput) {
+ if (fComposite != null && input instanceof ICompareInput) {
fInput= (ICompareInput) input;
InputStream left= null;
@@ -100,7 +141,10 @@ public class BinaryCompareViewer extends AbstractViewer {
Utilities.close(right);
}
if (message != null)
- fControl.setText(message);
+ fMessage.setText(message);
+ if (fTextButton != null)
+ fTextButton.setEnabled(true);
+ fComposite.layout();
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
index 6d61c8ab1..3f839e136 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/BinaryCompareViewerResources.properties
@@ -20,3 +20,4 @@ deleteConflictMessage= Delete Conflict
addedMessage= Added Resource
deletedMessage= Removed Resource
errorMessage= Internal Error
+compareAsText= Compare as Text
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index dd6f26e2d..6aa1f096c 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -25,8 +25,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.*;
-import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
@@ -58,9 +58,9 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
private final static String CONTENT_TYPE_ID_ATTRIBUTE= "contentTypeId"; //$NON-NLS-1$
- private HashMap fIdMap; // maps ids to datas
- private HashMap fExtensionMap; // maps extensions to datas
- private HashMap fContentTypeBindings; // maps content type bindings to datas
+ private HashMap fIdMap; // maps ids to data
+ private HashMap fExtensionMap; // maps extensions to data
+ private HashMap fContentTypeBindings; // maps content type bindings to data
void register(IConfigurationElement element, Object data) {
@@ -300,7 +300,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fStructureCreators.createBinding(element, STRUCTURE_CREATOR_ID_ATTRIBUTE);
}
- // collect all viewers which define the structure mergeviewer extension point
+ // collect all viewers which define the structure merge viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGE_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
@@ -317,7 +317,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fStructureMergeViewers.createBinding(element, STRUCTURE_MERGE_VIEWER_ID_ATTRIBUTE);
}
- // collect all viewers which define the content mergeviewer extension point
+ // collect all viewers which define the content merge viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGE_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
@@ -805,8 +805,12 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
ICompareInput input= (ICompareInput) in;
+
IContentType ctype= getCommonType(input);
+ if (isCompareAsText(input, cc)) {
+ ctype = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
+ }
if (ctype != null) {
initializeRegistries();
Viewer viewer= getViewer(fContentMergeViewers.search(ctype), oldViewer, parent, cc);
@@ -861,6 +865,13 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
}
+ private boolean isCompareAsText(ICompareInput input, CompareConfiguration cc) {
+ Set set = (Set)cc.getProperty(ICompareAsText.PROP_TEXT_INPUTS);
+ if (set == null)
+ return false;
+ return set.contains(input);
+ }
+
private static Viewer getViewer(Object descriptor, Viewer oldViewer, Composite parent, CompareConfiguration cc) {
if (descriptor instanceof IViewerDescriptor)
return ((IViewerDescriptor)descriptor).createViewer(oldViewer, parent, cc);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java
new file mode 100644
index 000000000..1476a6fb1
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ICompareAsText.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+public interface ICompareAsText {
+
+ /**
+ * Property key for the set of test inputs (instance of Set)
+ */
+ public static final String PROP_TEXT_INPUTS = "org.eclipse.compare.TextInputs"; //$NON-NLS-1$
+
+ public void compareAsText(Object input);
+
+}

Back to the top