Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Code Editor framework
Code Editor framework [message #1739363] Sat, 30 July 2016 16:27 Go to next message
Onno Kouwenberg is currently offline Onno KouwenbergFriend
Messages: 18
Registered: January 2015
Junior Member
I'd like to use the syntax highlighting code editor framework of e(fx)clipse. I have some familiarity with the standard Eclipse code editor framework (although not enough to start out of the box).

I've found some articles on Tomsondev blog, but they are primarily some highlights and I need some more. Are there any examples I can browse? Javadoc? A tutorial?

Also, I'd like to have features such as error/warning markers, code suggestions. I know they are present in the Eclipse standard framework, but have they also been implemented here yet?
Re: Code Editor framework [message #1739423 is a reply to message #1739363] Mon, 01 August 2016 08:34 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
It looks like my replies (who are made through the newsgroup) don't find their way to the forum. I replied there with the following:

---
Hi,

A start of a documentation is at
https://wiki.eclipse.org/Efxclipse/SmartCode. There's a sample at
https://github.com/BestSolution-at/dartedit demonstrating the useage.
Feel free to file bugzillas if you found something not working.

Tom
--
Re: Code Editor framework [message #1739487 is a reply to message #1739423] Tue, 02 August 2016 10:45 Go to previous messageGo to next message
Onno Kouwenberg is currently offline Onno KouwenbergFriend
Messages: 18
Registered: January 2015
Junior Member
thx. I'll study them.
Re: Code Editor framework [message #1739545 is a reply to message #1739487] Tue, 02 August 2016 19:19 Go to previous messageGo to next message
Onno Kouwenberg is currently offline Onno KouwenbergFriend
Messages: 18
Registered: January 2015
Junior Member
Thomas,

The first link doesn't contain any information yet.

I've downloaded the example, and as with many Eclipse plugins it is hard to understand if you don't know how to wire the specific parts already.

For my example I'd like to create an editor, but I'd rather not use the XTend generation at this moment, so I'm looking for a way to create a SourceViewer and attach the specific parts myself. If I instantiate a SourceViewer I can't find out how to configure its DocumentPartitioner anymore. If I instantiate a TextEditor I can do a setDocumentPartitioner, but when I request the SourceViewer from the TextEditor I get a NPE because I haven't set a SourceViewerConfiguration. I tried to use the built-in DefaultSourceViewerConfiguration, but it is bundle internal (and it required a lot of objects in the constructor).
Re: Code Editor framework [message #1739547 is a reply to message #1739545] Tue, 02 August 2016 19:51 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
in general you need:

a) an IPresentationReconciler
b) an IDocumentPartitioner
c) an IDocument document
d) SourceViewerConfiguration

The a setup would look like this

              SourceViewer viewer = new SourceViewer();

		IPresentationReconciler reconciler = /* Generated by the DSL */;
		SourceViewerConfiguration configuration = new SourceViewerConfiguration() {

			@Override
			public String getStyleclassName() {
				return "source-viewer"; //$NON-NLS-1$
			}

			@Override
			public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
				return reconciler;
			}
		};


		IDocumentPartitioner partitioner = .... /* Generated by the DSL */;
		IDocument document = new Document();

		if( document instanceof IDocumentExtension3 ) {
			((IDocumentExtension3)document).setDocumentPartitioner(configuration.getConfiguredDocumentPartitioning(viewer),partitioner);
		} else {
			document.setDocumentPartitioner(partitioner);
		}

		document.setDocumentPartitioner(partitioner);
		partitioner.connect(document);
		viewer.configure(configuration);
                viewer.setDocument(document, configuration.getAnnotationModel());


If you don't want to use the DSL we have you need to implement IPresentationReconciler & IDocumentPartitioner yourself.

[Updated on: Tue, 02 August 2016 19:52]

Report message to a moderator

Re: Code Editor framework [message #1739566 is a reply to message #1739547] Tue, 02 August 2016 23:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6363
Registered: July 2009
Senior Member
https://wiki.eclipse.org/Efxclipse/SmartCode without the "." is the correct URL!
Re: Code Editor framework [message #1740994 is a reply to message #1739566] Mon, 22 August 2016 09:23 Go to previous message
Onno Kouwenberg is currently offline Onno KouwenbergFriend
Messages: 18
Registered: January 2015
Junior Member
I'm now trying to use the editor in a non-OSGi/Equinox environment, using the latest available on maven, 2.2.0 . As far as I know I've wired all the required objects, but e.g. the document partitioner is never called. To debug that I added the following code:

document.addDocumentPartitioningListener(new IDocumentPartitioningListener() {
@Override
public void documentPartitioningChanged(IDocument document) {
System.out.println("documentPartitioningChanged");
try {
System.out.println(" " + document.getPartition(0));
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

});

Without the "System.out.println(" " + document.getPartition(0));" I do get a notification, but no call to my document partitioner.
With the println the situation gets worse:
Exception in thread "JavaFX Application Thread" java.lang.NoClassDefFoundError: org/eclipse/core/internal/runtime/Activator
at org.eclipse.core.runtime.SafeRunner.handleException(SafeRunner.java:55)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:44)
at org.eclipse.jface.text.AbstractDocument.log(AbstractDocument.java:1844)
at org.eclipse.jface.text.AbstractDocument.fireDocumentPartitioningChanged(AbstractDocument.java:619)
at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:755)
at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:736)
at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:721)
at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:796)
at org.eclipse.jface.text.AbstractDocument.set(AbstractDocument.java:1237)
at org.eclipse.jface.text.AbstractDocument.set(AbstractDocument.java:1217
Previous Topic:Where to get standard Eclipse bundles (e.g. bundle for BundleActivator)
Next Topic:FXGraph: styledwith and resourcefile can't find the files on Maven
Goto Forum:
  


Current Time: Mon Oct 23 04:46:22 GMT 2017

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

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