/**
* Overridden to handle backspace (will only be called on Eclipse 3.5)
*/
@Override
protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
final SourceViewer viewer = super.createSourceViewer(parent, textOrientation);
viewer.appendVerifyKeyListener(PyPeerLinker.createVerifyKeyListener(viewer));
viewer.appendVerifyKeyListener(PyBackspace.createVerifyKeyListener(viewer, null));
IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart();
//Note that any site should be OK as it's just to know if a keybinding is active.
IWorkbenchPartSite site = null;
if (workbenchPart != null) {
site = workbenchPart.getSite();
} else {
IWorkbenchWindow window = PyAction.getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
IWorkbenchPart activePart = activePage.getActivePart();
if (activePart != null) {
site = activePart.getSite();
}
}
}
}
VerifyKeyListener createVerifyKeyListener = FirstCharAction.createVerifyKeyListener(viewer, site, true);
if (createVerifyKeyListener != null) {
viewer.appendVerifyKeyListener(createVerifyKeyListener);
}
return viewer;
}