I have set up a multi-page editor plugin in Eclipse and would like to embed the CSourceViewer from Eclipse CDT into a page that also has a couple other elements, like buttons etc. What is the easiest way to do that? I tried something like the following, but this resulted in null pointer exceptions as soon as I try to type something inside the source viewer.
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
CSourceViewer viewer = new CSourceViewer(composite, null, null, false, SWT.MULTI|SWT.V_SCROLL|SWT.H_SCROLL| SWT.FULL_SELECTION, CUIPlugin.getDefault().getPreferenceStore());
viewer.configure(new CSourceViewerConfiguration(textTools.getColorManager(), store, null, textTools.getDocumentPartitioning()));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 200;
gd.widthHint = 300;
viewer.getControl().setLayoutData(gd);
It works with a normal source viewer. But the CDT CSourceViewer would be really nice to get syntax highlighting etc.