diff options
| author | Dani Megert | 2012-02-16 13:04:15 +0000 |
|---|---|---|
| committer | Dani Megert | 2012-02-16 13:04:15 +0000 |
| commit | 1be86f3e5a76009715303e189e73942933f76dc0 (patch) | |
| tree | 8270be0984eee160fedc31375ece65d0bfb43864 | |
| parent | 21b71cca4ee4254a2a61abbbd771dea13406e75b (diff) | |
| download | eclipse.platform.team-1be86f3e5a76009715303e189e73942933f76dc0.tar.gz eclipse.platform.team-1be86f3e5a76009715303e189e73942933f76dc0.tar.xz eclipse.platform.team-1be86f3e5a76009715303e189e73942933f76dc0.zip | |
Fixed bug 251776: [Content Type] Need a better way to arbitrate content
types and/or editor associations
3 files changed, 21 insertions, 12 deletions
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF index ff4803fe9..5f6d4d447 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 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.team.ui; singleton:=true -Bundle-Version: 3.6.101.qualifier +Bundle-Version: 3.6.102.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 a5f2affc6..dd7df1675 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 @@ -1132,21 +1132,28 @@ public class Utils { } 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; } @@ -1184,9 +1191,11 @@ public class Utils { 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 948f5bd38..c9c93340e 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 @@ public class OpenWithMenu extends ContributionItem { 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); |
