From 76bea72bfb214ac8908e262ae06deb66f1a8a581 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 5 Feb 2008 14:45:53 +0000 Subject: [PATCH] Fix for 217727: Binary files do not open in the binary editor --- .../cdt/internal/ui/util/EditorUtility.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java index 9f41122abc2..2dd4c48f88d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java @@ -513,10 +513,22 @@ public class EditorUtility { } contentType= CCorePlugin.getContentType(project, input.getName()); } + // handle binary files without content-type (e.g. executables without extension) + if (contentType == null && cElement != null) { + final int elementType= cElement.getElementType(); + if (elementType == ICElement.C_ARCHIVE || elementType == ICElement.C_BINARY) { + contentType= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE); + } + } IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType); if (desc != null) { - return desc.getId(); + String editorID= desc.getId(); + if (input instanceof IFileEditorInput) { + IFile file= ((IFileEditorInput)input).getFile(); + IDE.setDefaultEditor(file, editorID); + } + return editorID; } return DEFAULT_TEXT_EDITOR_ID;