mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
[254573] [source lookup] iostream is opened with default text editor instead of C/C++ editor
This commit is contained in:
parent
cdf145e63d
commit
bc28948f31
1 changed files with 10 additions and 15 deletions
|
@ -73,12 +73,12 @@ import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
import org.eclipse.ui.IEditorDescriptor;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.editors.text.EditorsUI;
|
import org.eclipse.ui.editors.text.EditorsUI;
|
||||||
import org.eclipse.ui.ide.FileStoreEditorInput;
|
import org.eclipse.ui.ide.FileStoreEditorInput;
|
||||||
|
import org.eclipse.ui.ide.IDE;
|
||||||
import org.eclipse.ui.part.FileEditorInput;
|
import org.eclipse.ui.part.FileEditorInput;
|
||||||
import org.eclipse.ui.progress.UIJob;
|
import org.eclipse.ui.progress.UIJob;
|
||||||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||||
|
@ -199,7 +199,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
||||||
URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI();
|
URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI();
|
||||||
IFileStore fileStore = EFS.getStore(uriLocation);
|
IFileStore fileStore = EFS.getStore(uriLocation);
|
||||||
editorInput = new FileStoreEditorInput(fileStore);
|
editorInput = new FileStoreEditorInput(fileStore);
|
||||||
editorId = getEditorIdForFilename(uriLocation.getPath());
|
editorId = getEditorIdForFilename(fileStore.getName());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
editorInput = new CommonSourceNotFoundEditorInput(dmc);
|
editorInput = new CommonSourceNotFoundEditorInput(dmc);
|
||||||
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
|
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
|
||||||
|
@ -208,7 +208,7 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
||||||
File file = ((LocalFileStorage)sourceElement).getFile();
|
File file = ((LocalFileStorage)sourceElement).getFile();
|
||||||
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
|
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
|
||||||
editorInput = new FileStoreEditorInput(fileStore);
|
editorInput = new FileStoreEditorInput(fileStore);
|
||||||
editorId = getEditorIdForFilename(file.getPath());
|
editorId = getEditorIdForFilename(file.getName());
|
||||||
}
|
}
|
||||||
result.setEditorInput(editorInput);
|
result.setEditorInput(editorInput);
|
||||||
result.setEditorId(editorId);
|
result.setEditorId(editorId);
|
||||||
|
@ -218,13 +218,13 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEditorIdForFilename(String filename) {
|
private String getEditorIdForFilename(String filename) {
|
||||||
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
try {
|
||||||
IEditorDescriptor descriptor = registry.getDefaultEditor(filename);
|
IEditorDescriptor descriptor= IDE.getEditorDescriptor(filename);
|
||||||
if (descriptor == null) {
|
return descriptor.getId();
|
||||||
return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
|
} catch (PartInitException exc) {
|
||||||
}
|
DsfDebugUIPlugin.log(exc);
|
||||||
|
}
|
||||||
return descriptor.getId();
|
return "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,11 +681,6 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
|
||||||
fRunningLookupJob.schedule();
|
fRunningLookupJob.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
// To be called only on dispatch thread.
|
|
||||||
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page) {
|
|
||||||
startDisplayJob(lookupResult, frameData, page, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be called only on dispatch thread.
|
// To be called only on dispatch thread.
|
||||||
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
|
private void startDisplayJob(SourceLookupResult lookupResult, FrameData frameData, IWorkbenchPage page, boolean eventTriggered) {
|
||||||
DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered);
|
DisplayJob nextDisplayJob = new DisplayJob(lookupResult, frameData, page, eventTriggered);
|
||||||
|
|
Loading…
Add table
Reference in a new issue