Using Xtext embedded Editor how to synchronize back the changes ? [message #1725910] |
Tue, 08 March 2016 13:30 |
Nawel Amok Messages: 18 Registered: November 2013 |
Junior Member |
|
|
Hello,
I have followed this example http://fr.slideshare.net/meysholdt/lightweight-xtext-editorsasswtwidgets to integrate the Xtext editor of a grammer I created (BPmodel) in a composite - part of swt form, in a windowbuilder project, where the application that carries the EmbdedEditor is an Eclipse plugin.
The integration works, now I would like to fully use the embeddedEditor and synchronize back the changes with the entries of the users.
The presentation in the attached file gives some indications on how to use partial editors :
public EmbeddedEditorModelAccess createPartialEditor(
String prefix, String editablePart, String suffix,
boolean insertLineBreaks)
Is it what I should use to allow entering a specific rule of the grammer's model ?
In this case, what should the prefix and the suffix be ? knowing that I don't know in advance what the user will enter..
And how to synchronize back the changes.. I don't know exactly which use case I have : "Simple String edited with tooling and writtenback to the model as a String"
org.eclipse.xtext.resource.XtextResource.update(int, int, String)
public void update(int offset, int replacedTextLength, String newText)
or "Complete model edited and editable part
should be updated in resource" ??
org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess
public void updateModel(String prefix, String editablePart, String suffix)
Anyways how can I get these the elements needed to call the methods update or updateModel ?
Thanks in advance,
Nawel
|
|
|
|
Re: Using Xtext embedded Editor how to synchronize back the changes ? [message #1728455 is a reply to message #1728413] |
Mon, 04 April 2016 13:36 |
|
The prefix, editablePart and suffix are just used to create initial content to be shown in the embedded editor. If the user is supposed to write the content from scratch, you can leave these strings empty. If the user should write only a specific part of a document, you can use prefix and suffix to fill out the rest.
As to the question how to synchronize changes back to the source model... this is a very complex question, and there are several approaches to solve this. You can have a look at some example code I created for a conference talk:
https://github.com/spoenemann/xtext-gef
|
|
|
|
Powered by
FUDForum. Page generated in 0.03900 seconds