|Strategies for using embedded editor [message #987497]
||Mon, 26 November 2012 21:15
| Hallvard Traetteberg
Registered: July 2009
Location: Trondheim, Norway
I'm (still) working in integrating a Graphiti editor with an Xtext DSL,
more specifically popping up an embedded editor for editing part of the
model as text. I've looked through several code examples and the general
strategy seems to be as follows:
1. Assume the user has selected or otherwise identified the object that
should be edited (call this object EO).
2. Serialize the whole model to a temporary resource and open it as an
XtextResource, effectively reparsing it.
3. Find the text span of EO and open the embedded editor on the
XtextResource and limit the view to EO text span.
4. After editing, merge the content of the XtextResource with the
A drawback of this approach is that you need to serialize the whole
model, and merge the result back into the original one. This is both
time-consuming and difficult, and seems like overkill for e.g. editing
the type of a connection or port in a process diagram.
An alternative strategy would be to
1. serialize the object that you want to edit and
2. configure the XtextResource and editor to parse using a specific
parse rule (for that object) and
3. use the original model for scoping and linking (and Java model
This should let you just replace the original EO with the
XtextResource's content instead of merging complete models/resources.
I've managed to do step 1 and 2, by using a special injector and custom
versions of several of the generated services, like the parser, some
factories etc. However, I have problems getting the completion service
to work and I haven't yet looked at scoping and linking.
The question is: Is the alternative strategy feasible or a dead end? If
feasible, are there any hints for how to implement it?
Powered by FUDForum
. Page generated in 0.06371 seconds