diff options
author | Anton Leherbauer | 2008-02-05 14:45:38 +0000 |
---|---|---|
committer | Anton Leherbauer | 2008-02-05 14:45:38 +0000 |
commit | 224215d6fe13dc1f66ae524fba62ba0d57d6485a (patch) | |
tree | 0086362752b2f47fe4c460e18f9382ec86ab2a25 | |
parent | bc335d2fb816b55de3473be4bc1a816a4fafcb97 (diff) | |
download | org.eclipse.cdt-224215d6fe13dc1f66ae524fba62ba0d57d6485a.tar.gz org.eclipse.cdt-224215d6fe13dc1f66ae524fba62ba0d57d6485a.tar.xz org.eclipse.cdt-224215d6fe13dc1f66ae524fba62ba0d57d6485a.zip |
Fix for 217727: Binary files do not open in the binary editor
-rw-r--r-- | core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java | 14 |
1 files changed, 13 insertions, 1 deletions
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 247fbc1e371..524b4ae5603 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 @@ -493,10 +493,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; |