1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +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.ui.DebugUITools;
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.ISourceDisplay;
import org.eclipse.jface.text.BadLocationException;
@ -192,24 +193,39 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
if (sourceElement == null) {
editorInput = new CommonSourceNotFoundEditorInput(dmc);
editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
} else if (sourceElement instanceof IFile) {
editorId = getEditorIdForFilename(((IFile)sourceElement).getName());
editorInput = new FileEditorInput((IFile)sourceElement);
} 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());
} else {
ISourcePresentation presentation= null;
if (fSourceLookup instanceof ISourcePresentation) {
presentation = (ISourcePresentation) fSourceLookup;
} else {
if (dmc != null) {
presentation = (ISourcePresentation) dmc.getAdapter(ISourcePresentation.class);
}
}
if (presentation != null) {
editorInput = presentation.getEditorInput(sourceElement);
if (editorInput != null) {
editorId = presentation.getEditorId(editorInput, sourceElement);
}
} else if (sourceElement instanceof IFile) {
editorId = getEditorIdForFilename(((IFile)sourceElement).getName());
editorInput = new FileEditorInput((IFile)sourceElement);
} 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.setEditorId(editorId);