|Custom validation of constraints from existing metamodel [message #1776346]
||Wed, 15 November 2017 14:03
| Matteo M.
Registered: May 2012
I have a legacy Ecore metamodel that I cannot modify where a EClass "Foo" has an attribute "bar" with multiplicity 1 -- i.e., it is a required attribute. The EMF tree model editor I have generates a default value for "bar", which is generally ok, except when the user must use specific (custom) logics to derive a value for it. In that case the user will overwrite the generated default to insert the desired value.
Now, I want to define a grammar for this Ecore metamodel, and I want to emulate the behavior of the model editor above.
In other words, I want the xtext editor does not force the user to insert a value for "bar" each time, and that some Java code is called behind the scenes when "bar" is not specified to comply with the multiplity-1 constraint.
In yet other words, I want the editor does not raise any error when the user does:
because some Java code will be called behind the scenes to properly fill the "bar" attribute with some defaults.
On the other hand, this one of course is also valid:
Foo fobj with bar abc123;
Any hints on how do I do it?
[Updated on: Wed, 15 November 2017 14:07]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02106 seconds