1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 516461: use user's/content-type editor selection

This fix applies during debugging:
1) If a user has overridden the default editor to open an IFile with,
ensure that decision is respected by the breakpoints window.
2) If a user has put a breakpoint in an external file, open the same
editor as would be opened by File > Open File

Change-Id: Id32419f1197e3a8eaebf8fad176a884464cbcf85
This commit is contained in:
Jonah Graham 2017-05-11 13:27:04 +01:00
parent 9f4feda520
commit cea32dfe7b

View file

@ -16,6 +16,7 @@
package org.eclipse.cdt.debug.internal.ui;
import java.io.File;
import java.net.URI;
import java.util.HashMap;
import org.eclipse.cdt.core.IAddress;
@ -49,6 +50,8 @@ import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@ -85,7 +88,10 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.FileEditorInput;
import com.ibm.icu.text.MessageFormat;
@ -217,13 +223,35 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
String id = null;
if (input != null) {
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() );
IEditorDescriptor descriptor = null;
if (input instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput = (IFileEditorInput) input;
IFile file = fileEditorInput.getFile();
descriptor = IDE.getDefaultEditor(file);
} else if (input instanceof IURIEditorInput) {
IURIEditorInput uriEditorInput = (IURIEditorInput) input;
URI uri = uriEditorInput.getURI();
try {
IFileStore fileStore = EFS.getStore(uri);
id = CDebugUIUtils.getEditorId(fileStore);
} catch (CoreException e) {
// fallback to default case
}
}
if (id == null) {
if (descriptor == null) {
IEditorRegistry registry = PlatformUI.getWorkbench()
.getEditorRegistry();
descriptor = registry.getDefaultEditor(input.getName());
}
id = CUIPlugin.EDITOR_ID;
if (descriptor != null) {
id = descriptor.getId();
}
else if ( element instanceof ICBreakpoint ) {
}
if (id == null && element instanceof ICBreakpoint) {
// There is no associated editor ID for this breakpoint, see if an alternative can be supplied from an adapter.
ISourcePresentation sourcePres = Platform.getAdapterManager().getAdapter(element, ISourcePresentation.class);
if ( sourcePres != null ) {