Skip to main content



      Home
Home » Newcomers » Newcomers » Configuring an Eclipse SourceViewer for Java(Configuring an Eclipse SourceViewer for Java)
Configuring an Eclipse SourceViewer for Java [message #1856716] Sat, 24 December 2022 03:00 Go to next message
Eclipse UserFriend
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.
Re: Configuring an Eclipse SourceViewer for Java [message #1856718 is a reply to message #1856716] Sat, 24 December 2022 07:10 Go to previous message
Eclipse UserFriend
It's just a guess, but other places call the overload method setupJavaDocumentPartitioner(doc, IJavaPartitions.JAVA_PARTITIONING).
Previous Topic:Is there support for opencl in eclipse ?
Next Topic:Eclipse ignoring the git hooks
Goto Forum:
  


Current Time: Tue Jul 15 16:53:52 EDT 2025

Powered by FUDForum. Page generated in 0.08720 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top