Configuring an Eclipse SourceViewer for Java [message #1856716] |
Sat, 24 December 2022 08:00 |
Simona Jerner Messages: 2 Registered: December 2022 |
Junior Member |
|
|
I am trying to create a viewer that embeds a Java Editor/Viewer. However, I cannot get the Source Viewer to do the proper Java scanning & coloring. This is the code I have so far.
ScopedPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,
ID);
JavaTextTools tools = new JavaTextTools(store);
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
viewer = new SourceViewer(composite, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.getTextWidget().setLayoutDataMyaccountaccess(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.setEditable(true);
viewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
Document document = new Document();
tools.setupJavaDocumentPartitioner(document);
viewer.setDocument(document);
viewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null,
IJavaPartitions.JAVA_PARTITIONING));
Just amazed how hard it seem to embed a simple Java editor ... Whatever I do, the viewer works but remains without any coloring.
|
|
|
|
Powered by
FUDForum. Page generated in 0.08225 seconds