diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java
index cb9f8d9a9a9..e57f1428a1e 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/coff/parser/CygwinPEParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2000, 2007 QNX Software Systems 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.utils.coff.parser;
@@ -81,13 +82,12 @@ public class CygwinPEParser extends PEParser {
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
- if (adapter.equals(ICygwinToolsFactroy.class)) {
+ if (adapter.isAssignableFrom(ICygwinToolsFactroy.class)) {
if (toolFactory == null) {
toolFactory = createToolFactory();
}
return toolFactory;
}
- // TODO Auto-generated method stub
return super.getAdapter(adapter);
}
}
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index a8838df322f..cb04a363c2a 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -142,7 +142,7 @@ ColoringPreferencePage.name=Syntax Coloring
FoldingPreferencePage.name=Folding
HoverPreferencePage.name=Hovers
-Editors.DefaultTextEditor = Default Text Editor
+DefaultBinaryFileEditor.name = Default Binary File Editor
AsmEditor.name = Assembly Editor
# Task Action
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 619f69fe727..449c02407d5 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -551,6 +551,16 @@
icon="icons/obj16/c_file_obj.gif"
name="%ExternalSearchEditor.name"
id="org.eclipse.cdt.ui.editor.ExternalSearchEditor"/>
+
+
+
+
null
*/
public static String getEditorID(String name) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- if (registry != null) {
- IEditorDescriptor descriptor = registry.getDefaultEditor(name);
+ try {
+ IEditorDescriptor descriptor = IDE.getEditorDescriptor(name);
if (descriptor != null) {
return descriptor.getId();
}
+ } catch (PartInitException exc) {
+ // ignore
}
return DEFAULT_TEXT_EDITOR_ID;
}
@@ -433,47 +440,58 @@ public class EditorUtility {
* @return a valid editor id, never null
*/
public static String getEditorID(IEditorInput input, Object inputObject) {
-
- ITranslationUnit tunit = null;
- if (inputObject instanceof ITranslationUnit) {
- tunit= (ITranslationUnit)inputObject;
- } else if (input instanceof IFileEditorInput) {
+ ICElement cElement= null;
+ if (input instanceof IFileEditorInput) {
IFileEditorInput editorInput = (IFileEditorInput)input;
IFile file = editorInput.getFile();
- ICElement celement = CoreModel.getDefault().create(file);
- if (celement instanceof ITranslationUnit) {
- tunit = (ITranslationUnit)celement;
+ // Try file specific editor.
+ try {
+ String editorID = file.getPersistentProperty(IDE.EDITOR_KEY);
+ if (editorID != null) {
+ IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
+ IEditorDescriptor desc = registry.findEditor(editorID);
+ if (desc != null) {
+ return editorID;
+ }
+ }
+ } catch (CoreException e) {
+ // do nothing
}
+ cElement = CoreModel.getDefault().create(file);
} else if (input instanceof ITranslationUnitEditorInput) {
ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput)input;
- tunit = editorInput.getTranslationUnit();
+ cElement = editorInput.getTranslationUnit();
+ } else if (inputObject instanceof ICElement) {
+ cElement= (ICElement)inputObject;
}
- if (tunit != null) {
- // Choose an editor based on the content type
- String contentTypeId= tunit.getContentTypeId();
+ // Choose an editor based on the content type
+ IContentType contentType= null;
+ if (cElement instanceof ITranslationUnit) {
+ String contentTypeId= ((ITranslationUnit)cElement).getContentTypeId();
if (contentTypeId != null) {
- IContentType contentType= Platform.getContentTypeManager().getContentType(contentTypeId);
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
- if (desc != null) {
- return desc.getId();
+ contentType= Platform.getContentTypeManager().getContentType(contentTypeId);
+ }
+ }
+ if (contentType == null) {
+ IProject project= null;
+ if (cElement != null) {
+ project= cElement.getCProject().getProject();
+ } else {
+ IFile file= ResourceUtil.getFile(input);
+ if (file != null) {
+ project= file.getProject();
}
}
- // Choose an editor based on the language (obsolete?)
- if (tunit.isCLanguage()) {
- return CUIPlugin.EDITOR_ID;
- } else if (tunit.isCXXLanguage()) {
- return CUIPlugin.EDITOR_ID;
- } else if (tunit.isASMLanguage()) {
- return "org.eclipse.cdt.ui.editor.asm.AsmEditor"; //$NON-NLS-1$
- }
+ contentType= CCorePlugin.getContentType(project, input.getName());
+ }
+ IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
+ IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
+ if (desc != null) {
+ return desc.getId();
}
- // Choose an editor based on filename/extension
- String editorId = getEditorID(input.getName());
-
- return editorId;
+ return DEFAULT_TEXT_EDITOR_ID;
}
/**