Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2017-05-11 12:27:04 +0000
committerJonah Graham2017-05-11 12:31:58 +0000
commitcea32dfe7b27a098f05e1e9daf9eea3634527ba0 (patch)
tree38a2143842ca14a2ef0332c2814944485b3e8e7b
parent9f4feda52043c53141b3b177911d628a525e81a9 (diff)
downloadorg.eclipse.cdt-cea32dfe7b27a098f05e1e9daf9eea3634527ba0.tar.gz
org.eclipse.cdt-cea32dfe7b27a098f05e1e9daf9eea3634527ba0.tar.xz
org.eclipse.cdt-cea32dfe7b27a098f05e1e9daf9eea3634527ba0.zip
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
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java44
1 files changed, 36 insertions, 8 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
index 0fa0a3eba9b..eff894c022e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
@@ -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;
@@ -216,14 +222,36 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if (element instanceof CSourceNotFoundElement)
return ICDebugUIConstants.CSOURCENOTFOUND_EDITOR_ID;
String id = null;
- if ( input != null ) {
- IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- IEditorDescriptor descriptor = registry.getDefaultEditor( input.getName() );
- id = CUIPlugin.EDITOR_ID;
- if ( descriptor != null ) {
- id = descriptor.getId();
- }
- else if ( element instanceof ICBreakpoint ) {
+ if (input != null) {
+ 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();
+ }
+ }
+
+ 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 ) {

Back to the top