use of org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension in project egit by eclipse.
the class BlameOperation method openEditor.
private void openEditor(final RevisionInformation info) {
IEditorPart editorPart;
try {
if (storage instanceof IFile) {
editorPart = RevisionAnnotationController.openEditor(page, (IFile) storage);
} else {
FileRevisionEditorInput editorInput = new FileRevisionEditorInput(fileRevision, storage);
editorPart = EgitUiEditorUtils.openEditor(page, editorInput);
if (editorPart instanceof MultiPageEditorPart) {
MultiPageEditorPart multiEditor = (MultiPageEditorPart) editorPart;
for (IEditorPart part : multiEditor.findEditors(editorInput)) {
if (part instanceof AbstractDecoratedTextEditor) {
multiEditor.setActiveEditor(part);
editorPart = part;
break;
}
}
}
}
} catch (CoreException e) {
// $NON-NLS-1$
Activator.handleError(// $NON-NLS-1$
"Error displaying blame annotations", // $NON-NLS-1$
e, false);
return;
}
if (!(editorPart instanceof AbstractDecoratedTextEditor)) {
return;
}
AbstractDecoratedTextEditor editor = (AbstractDecoratedTextEditor) editorPart;
// IRevisionRulerColumn would also be possible but using
// IVerticalRulerInfo seems to work in more situations.
IVerticalRulerInfo rulerInfo = AdapterUtils.adapt(editor, IVerticalRulerInfo.class);
BlameInformationControlCreator creator = new BlameInformationControlCreator(rulerInfo);
info.setHoverControlCreator(creator);
info.setInformationPresenterControlCreator(creator);
editor.showRevisionInformation(info, // $NON-NLS-1$
"org.eclipse.egit.ui.internal.decorators.GitQuickDiffProvider");
if (lineNumberToReveal >= 0) {
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
int offset;
try {
offset = document.getLineOffset(lineNumberToReveal);
editor.selectAndReveal(offset, 0);
} catch (BadLocationException e) {
Activator.logError("Error revealing line " + lineNumberToReveal, // $NON-NLS-1$
e);
}
}
IRevisionRulerColumn revisionRuler = AdapterUtils.adapt(editor, IRevisionRulerColumn.class);
if (revisionRuler instanceof IRevisionRulerColumnExtension)
((IRevisionRulerColumnExtension) revisionRuler).getRevisionSelectionProvider().addSelectionChangedListener(new RevisionSelectionHandler(repository, path, storage));
}
Aggregations