1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

[269689] [source lookup] DsfSourceDisplayadapter should respect ISourcePresentation API

This commit is contained in:
Anton Leherbauer 2009-03-24 11:00:42 +00:00
parent 30c1dc4f38
commit 486b8d0bde

View file

@ -56,6 +56,7 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.ISourcePresentation;
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditorInput; import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditorInput;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
@ -192,24 +193,39 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
if (sourceElement == null) { if (sourceElement == null) {
editorInput = new CommonSourceNotFoundEditorInput(dmc); editorInput = new CommonSourceNotFoundEditorInput(dmc);
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR; editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
} else if (sourceElement instanceof IFile) { } else {
editorId = getEditorIdForFilename(((IFile)sourceElement).getName()); ISourcePresentation presentation= null;
editorInput = new FileEditorInput((IFile)sourceElement); if (fSourceLookup instanceof ISourcePresentation) {
} else if (sourceElement instanceof ITranslationUnit) { presentation = (ISourcePresentation) fSourceLookup;
try { } else {
URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI(); if (dmc != null) {
IFileStore fileStore = EFS.getStore(uriLocation); presentation = (ISourcePresentation) dmc.getAdapter(ISourcePresentation.class);
editorInput = new FileStoreEditorInput(fileStore); }
editorId = getEditorIdForFilename(fileStore.getName()); }
} catch (CoreException e) { if (presentation != null) {
editorInput = new CommonSourceNotFoundEditorInput(dmc); editorInput = presentation.getEditorInput(sourceElement);
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR; if (editorInput != null) {
} editorId = presentation.getEditorId(editorInput, sourceElement);
} else if (sourceElement instanceof LocalFileStorage) { }
File file = ((LocalFileStorage)sourceElement).getFile(); } else if (sourceElement instanceof IFile) {
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file); editorId = getEditorIdForFilename(((IFile)sourceElement).getName());
editorInput = new FileStoreEditorInput(fileStore); editorInput = new FileEditorInput((IFile)sourceElement);
editorId = getEditorIdForFilename(file.getName()); } else if (sourceElement instanceof ITranslationUnit) {
try {
URI uriLocation = ((ITranslationUnit)sourceElement).getLocationURI();
IFileStore fileStore = EFS.getStore(uriLocation);
editorInput = new FileStoreEditorInput(fileStore);
editorId = getEditorIdForFilename(fileStore.getName());
} catch (CoreException e) {
editorInput = new CommonSourceNotFoundEditorInput(dmc);
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
}
} else if (sourceElement instanceof LocalFileStorage) {
File file = ((LocalFileStorage)sourceElement).getFile();
IFileStore fileStore = EFS.getLocalFileSystem().fromLocalFile(file);
editorInput = new FileStoreEditorInput(fileStore);
editorId = getEditorIdForFilename(file.getName());
}
} }
result.setEditorInput(editorInput); result.setEditorInput(editorInput);
result.setEditorId(editorId); result.setEditorId(editorId);