Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:00 Go to next message
Simona Jerner is currently offline Simona JernerFriend
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.
Re: Configuring an Eclipse SourceViewer for Java [message #1856718 is a reply to message #1856716] Sat, 24 December 2022 12:10 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33224
Registered: July 2009
Senior Member
It's just a guess, but other places call the overload method setupJavaDocumentPartitioner(doc, IJavaPartitions.JAVA_PARTITIONING).

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Is there support for opencl in eclipse ?
Next Topic:Eclipse ignoring the git hooks
Goto Forum:
  


Current Time: Sat Oct 12 06:43:34 GMT 2024

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

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

Back to the top