Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2013-11-06 10:52:35 -0500
committerDani Megert2013-11-06 10:52:35 -0500
commitec3d37680e890ded361048d4561f71398cd1ed32 (patch)
treeb90cfe16bff95b9f42fbc5b22995568f0057403c
parenta71e56373a4b873af521839c8795b2fde71e1180 (diff)
downloadeclipse.platform.team-ec3d37680e890ded361048d4561f71398cd1ed32.tar.gz
eclipse.platform.team-ec3d37680e890ded361048d4561f71398cd1ed32.tar.xz
eclipse.platform.team-ec3d37680e890ded361048d4561f71398cd1ed32.zip
Fixed bug 421163: CompareUIPlugin.getContentType(ITypedElement) can return wrong content type for IFileI20131112-0800
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java48
1 files changed, 34 insertions, 14 deletions
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 f88b6a398..7de9a27f8 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
@@ -31,15 +31,13 @@ import java.util.ResourceBundle;
import java.util.Set;
import java.util.StringTokenizer;
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.IStreamMerger;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.internal.core.ComparePlugin;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
-import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
+import org.osgi.framework.BundleContext;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
@@ -52,9 +50,13 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -62,10 +64,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
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.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
+
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
@@ -78,7 +77,17 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareEditorInput;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.IStreamMerger;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.ResourceNode;
+import org.eclipse.compare.internal.core.ComparePlugin;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.compare.structuremergeviewer.IStructureCreator;
+import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
/**
* The Compare UI plug-in defines the entry point to initiate a configurable
@@ -1137,6 +1146,17 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
return null;
String name= element.getName();
IContentType ct= null;
+ if (element instanceof ResourceNode) {
+ IResource resource= ((ResourceNode)element).getResource();
+ if (resource instanceof IFile) {
+ try {
+ IContentDescription contentDesc= ((IFile)resource).getContentDescription();
+ return contentDesc != null ? contentDesc.getContentType() : null;
+ } catch (CoreException e) {
+ //$FALL-THROUGH$
+ }
+ }
+ }
if (element instanceof IStreamContentAccessor) {
IStreamContentAccessor isa= (IStreamContentAccessor) element;
try {

Back to the top