1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

Fix for 217727: Binary files do not open in the binary editor

This commit is contained in:
Anton Leherbauer 2008-02-05 14:45:53 +00:00
parent 7e9700c5a7
commit 76bea72bfb

View file

@ -513,10 +513,22 @@ public class EditorUtility {
} }
contentType= CCorePlugin.getContentType(project, input.getName()); 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(); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType); IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
if (desc != null) { 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; return DEFAULT_TEXT_EDITOR_ID;