1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00

[#808] Support overriden default-editor-association in EditorUtility (#809)

This commit is contained in:
G. Hentschke 2024-05-31 19:16:03 +02:00 committed by GitHub
parent d8328fb061
commit 9f85daf44b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 3 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
Bundle-Version: 8.1.400.qualifier
Bundle-Version: 8.1.500.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin

View file

@ -97,6 +97,7 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@ -676,8 +677,20 @@ public class EditorUtility {
contentType = Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
}
}
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor desc = registry.getDefaultEditor(input.getName(), contentType);
IEditorDescriptor desc = null;
if (input instanceof IURIEditorInput uriEditorInput) {
try {
IFileStore fileStore = EFS.getStore(uriEditorInput.getURI());
// get editor by considering overridden default editor association via IEditorAssociationOverride:
desc = IDE.getEditorDescriptorForFileStore(fileStore, false);
} catch (CoreException e) {
CUIPlugin.log(e);
}
}
if (desc == null) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
desc = registry.getDefaultEditor(input.getName(), contentType);
}
if (desc != null) {
String editorID = desc.getId();
if (input instanceof IFileEditorInput) {