Entry & Validation of Text in a GMF Runtime [message #1115150] |
Mon, 23 September 2013 14:38  |
Eclipse User |
|
|
|
Hi,
Please help me set out in the correct direction: I have used Epsilon to create a GMF runtime based on Emfatic using Eugenia. This includes EVL constaints which are pre-defined and validated as the user creates a model.
Now I need to allow the user to define textual rules in the model at runtime, and have these validated against the model. I would like the validation to show where the text references model elements, and where it doesn't. For example if the metamodel includes engine, gearbox, wheel, and the user creates a model of one engine, one gearbox and four wheels, the text rule might be "Engine1 + gearbox3 < 200hp". I would like the validation to show that "Engine1" and "Gearbox3" are model elements but that " < 200hp" is user defined and it does conform to a valid syntax.
Is EVL an appropriate starting point for this? Or should I explore xtext first? Could you give me an outline as to how to tackle this? Do I need to implement a "listener" for this - if so where do I start?
Thanks very much in advance...
Greg
|
|
|
|
|
|
|
Re: Entry & Validation of Text in a GMF Runtime [message #1125332 is a reply to message #1117898] |
Fri, 04 October 2013 07:58  |
Eclipse User |
|
|
|
Hi Greg,
Are you perhaps using Kepler (Eclipse 4.3)? If so, I think that you'll need to use a slightly newer version of the example, which I've just committed to our SVN repository [1]. If you're using Eclipse Juno (4.2), the version you already have should work. If not, you could try regenerating the GMF code for the precise version of GMF that you have installed, by selecting the esm.emf file, right-clicking and then selecting Eugenia > Generate GMF editor.
Also, for this example to work, do be sure that you edit the transition's text by double-clicking on the labels in the canvas, rather than via the property sheet view. This example only binds the Xtext parser to the label editor used on the GMF editor's canvas. The property sheet view is contributed by a plug-in which is generated by EMF rather than Eugenia, so we don't currently have a good way to repeatedly edit the behaviour of the property sheet view.
I've attached a video showing how the example works. First, I change the label on the transition and we see that this change is reflected by the addition of a "Dec" element in the model. This "Dec" object is an instance of a class from the metamodel generated from the Xtext grammar. Then, I show that the label editor won't allow invalid statements such as "foo" to be set as transition labels. Finally, I show that the property sheet editor doesn't perform validation and will allow "foo" to be set as a transition label.
Hope this helps!
Cheers,
Louis.
[1] https://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/examples/
[Updated on: Fri, 04 October 2013 08:02] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.08390 seconds