Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2012-01-16 17:01:15 +0000
committerDani Megert2012-01-17 16:08:09 +0000
commit465ec762a55e70fb743d4334d0150ed487c68cda (patch)
treee74ef25432f9cf0e0b4ea703bc13e49ca65d3bac
parent45e2a2fe42c326895aaa0a4323b9650225fa7863 (diff)
downloadeclipse.platform.team-465ec762a55e70fb743d4334d0150ed487c68cda.tar.gz
eclipse.platform.team-465ec762a55e70fb743d4334d0150ed487c68cda.tar.xz
eclipse.platform.team-465ec762a55e70fb743d4334d0150ed487c68cda.zip
Fixed bug 251776: [Content Type] Need a better way to arbitrate contentv20120117-1608
types and/or editor associations
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Utils.java23
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java8
2 files changed, 20 insertions, 11 deletions
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);

Back to the top