Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext integration with GMF(How to update semantic model of GMF label with use of partial Xtext parser)
Xtext integration with GMF [message #883745] Sat, 09 June 2012 08:52 Go to next message
Chris Rosas is currently offline Chris RosasFriend
Messages: 2
Registered: June 2012
Junior Member
Hi,

I have implemented the Xtext integration with GMF described in the Xtext2.1 documentation (14.4.1 Stage 1) and on the blog from Jan Köhnlein
for my Xtext grammar. And at this point it works as a charm. (Eclipse Indigo and Xtext 2.1)

Additionally I have tried to implement a partial Xtext parser for parsing expressions in a GMF label as described on state 2 in the Xtext2.1 Documentation.

However, I am stuck at the following problem:
How can i update/replace the currently found semantic element (in this case the expression) after successfully parsing the GMF label content?

If I change the contents of my GMFLabel (defined as a ExpressionLabelEditPart) my AntlrParserWrapper parses the contents and updates the semantic element for the XtextResource (UpdateXtextResourceCommand), but unfortunately the semantic model of the GMFEditor and so the contents of the gmf label is not updated.
Thus, after the saving event the content in GMFEditor and in the XtextEditor are
inconsistent.

What does work are the following cases:
-Changes in Xtext Editor => onSave: update of GMFEditor (because of semantic
unloader of ModelEditPart)
-Changes in GMFEditor (not the GMF Label) => onSave: update of contents in Xtext
Editor
-Changes in GMFEditor and XtextEditor => Dialog opening saying that other changes
will be overwritten => onSave: updates the last edited content in both editors.

For debugging purposes I already have used the NodeModelUtils to print the token text and compact dump of the CompositeNode to check the contents of the "old node"
and the "new node" (=RootNode of the ParseResult with the valid newString).

What I am searching for is how to replace both "nodes" or update the old node with the newString value in the semantic model.

I also tried to implement a CompositeTransactionalCommand to first update the semantic model of GMF and THEN invoke the UpdateXtextResourceCommand. However, i could not manage to realize it because normally updating a label and its semantic model (done by the classes: LabelDirectEditPolicy, MessageFormatParser, AbtractParser) corresponds with EAttributes and not with EObject (in this case Expressions).

Sorry for my long post. I hope my problem hab become clear.

Thanks in advance.

Christopher





Re: Xtext integration with GMF [message #883882 is a reply to message #883745] Sat, 09 June 2012 17:04 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Hi,

the Popup editor GMF integration example is quite outdated. Please use
the embedded editor that allows to have an Xtext based editor in any
SWT text control.

Unfortunately, there is not too much documentation yet. Start digging
yourself into the JavaDocs at EmbeddedEditorFactory

Regards
Jan

Am 09.06.12 10:52, schrieb Chris Rosas:
> Hi,
> I have implemented the Xtext integration with GMF described in the
> Xtext2.1 documentation (14.4.1 Stage 1) and on the blog from Jan
> Köhnlein for my Xtext grammar. And at this point it works as a charm.
> (Eclipse Indigo and Xtext 2.1)
>
> Additionally I have tried to implement a partial Xtext parser for
> parsing expressions in a GMF label as described on state 2 in the
> Xtext2.1 Documentation.
>
> However, I am stuck at the following problem:
> How can i update/replace the currently found semantic element (in this
> case the expression) after successfully parsing the GMF label content?
>
> If I change the contents of my GMFLabel (defined as a
> ExpressionLabelEditPart) my AntlrParserWrapper parses the contents and
> updates the semantic element for the XtextResource
> (UpdateXtextResourceCommand), but unfortunately the semantic model of
> the GMFEditor and so the contents of the gmf label is not updated.
> Thus, after the saving event the content in GMFEditor and in the
> XtextEditor are inconsistent.
>
> What does work are the following cases:
> -Changes in Xtext Editor => onSave: update of GMFEditor (because of
> semantic unloader of ModelEditPart)
> -Changes in GMFEditor (not the GMF Label) => onSave: update of contents
> in Xtext Editor
> -Changes in GMFEditor and XtextEditor => Dialog opening saying that
> other changes will be overwritten => onSave: updates the last edited
> content in both editors.
>
> For debugging purposes I already have used the NodeModelUtils to print
> the token text and compact dump of the CompositeNode to check the
> contents of the "old node" and the "new node" (=RootNode of the
> ParseResult with the valid newString).
>
> What I am searching for is how to replace both "nodes" or update the old
> node with the newString value in the semantic model.
>
> I also tried to implement a CompositeTransactionalCommand to first
> update the semantic model of GMF and THEN invoke the
> UpdateXtextResourceCommand. However, i could not manage to realize it
> because normally updating a label and its semantic model (done by the
> classes: LabelDirectEditPolicy, MessageFormatParser, AbtractParser)
> corresponds with EAttributes and not with EObject (in this case
> Expressions).
> Sorry for my long post. I hope my problem hab become clear.
>
> Thanks in advance.
>
> Christopher
>
>
>
>
>
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext integration with GMF [message #892212 is a reply to message #883882] Wed, 27 June 2012 12:29 Go to previous messageGo to next message
Chris Rosas is currently offline Chris RosasFriend
Messages: 2
Registered: June 2012
Junior Member
Hi,

it's quite a while since my first request.
Thanks for the fast reply:-D

I was on vacation and could not directly answer. Sorry.

I tried to start to look for the EmbeddedEditorFactory based on your advice.
But i was not able to find this Factory class in the Xtext 2.1 distribution.

Can you perhaps give me a hint in which distribution i can find the EmbeddedEditorFactory?
I am still stucked with the problem i have described above.

Thanks in advance.

Chris
Re: Xtext integration with GMF [message #892482 is a reply to message #892212] Thu, 28 June 2012 12:10 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
How about updating to the brand new 2.3? It will contain a couple of
bugfixes, too.

Am 27.06.12 14:29, schrieb Chris Rosas:
> Hi,
>
> it's quite a while since my first request. Thanks for the fast reply:-D
>
> I was on vacation and could not directly answer. Sorry.
>
> I tried to start to look for the EmbeddedEditorFactory based on your
> advice.
> But i was not able to find this Factory class in the Xtext 2.1
> distribution.
>
> Can you perhaps give me a hint in which distribution i can find the
> EmbeddedEditorFactory?
> I am still stucked with the problem i have described above.
> Thanks in advance.
>
> Chris
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Xtext-Error: rule ruleReference has non-LL(*) decision due to recursive rule invocations...
Next Topic:ImportURI - Processing & Scoping
Goto Forum:
  


Current Time: Fri Feb 28 16:48:44 GMT 2020

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

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

Back to the top