Fixed bug 251776: [Content Type] Need a better way to arbitrate content
types and/or editor associations
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
index eff5a91..a4a7346 100644
--- a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.team.ui; singleton:=true
-Bundle-Version: 3.5.102.qualifier
+Bundle-Version: 3.5.103.qualifier
 Bundle-Activator: org.eclipse.team.internal.ui.TeamUIPlugin
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
index 6c035f6..81076c4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -1113,21 +1113,28 @@
 	}
 	
 	public static IEditorDescriptor[] getEditors(IFileRevision revision) {
+		String name= revision.getName();
 		IEditorRegistry registry = PlatformUI.getWorkbench()
 				.getEditorRegistry();
 		// so far only the revision name is used to find editors
-		return registry.getEditors(revision.getName()/*, getContentType(revision) */);
+		IEditorDescriptor[] editorDescs= registry.getEditors(name/* , getContentType(revision) */);
+		return IDE.overrideEditorAssociations(name, null, editorDescs);
 	}
 	
 	public static IEditorDescriptor getDefaultEditor(IFileRevision revision) {
+		String name= revision.getName();
 		// so far only the revision name is used to find the default editor
-		IEditorRegistry registry = PlatformUI.getWorkbench()
-				.getEditorRegistry();
-		return registry.getDefaultEditor(revision.getName()/*, getContentType(revision) */);
+		try {
+			return IDE.getEditorDescriptor(name);
+		} catch (PartInitException e) {
+			// Fallback to old way of getting the editor
+			IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
+			return registry.getDefaultEditor(name);
+		}
 	}
 
 	private static String getEditorId(FileRevisionEditorInput editorInput) {
-		String id = getEditorId(editorInput.getFileRevision().getName(), getContentType(editorInput));
+		String id= getEditorId(editorInput, getContentType(editorInput));
 		return id;
 	}
 
@@ -1165,9 +1172,11 @@
 		return type;
 	}
 
-	private static String getEditorId(String fileName, IContentType type) {
+	private static String getEditorId(FileRevisionEditorInput editorInput, IContentType type) {
+		String fileName= editorInput.getFileRevision().getName();
 		IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
 		IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type);
+		IDE.overrideDefaultEditorAssociation(editorInput, type, descriptor);
 		String id;
 		if (descriptor == null || descriptor.isOpenExternal()) {
 			id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
index 948f5bd..c9c9334 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2012 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
@@ -297,15 +297,15 @@
 		job.setSystem(true);
 		job.schedule();*/
 
-		createDefaultMenuItem(menu, fileRevision);
+		createDefaultMenuItem(menu, fileRevision, preferredEditor == null);
 
 		// add Other... menu item
 		createOtherMenuItem(menu);
 	}
 
-	public void createDefaultMenuItem(Menu menu, final IFileRevision revision) {
+	public void createDefaultMenuItem(Menu menu, final IFileRevision revision, boolean markAsSelected) {
 		final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
-		menuItem.setSelection(Utils.getDefaultEditor(revision) == null);
+		menuItem.setSelection(markAsSelected);
 		menuItem
 				.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription);