Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsInstant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/861089/#msg_861089
I've a question regarding validation: Is there a way to enable instant validation after each change in the GMF editor? I found the option "Live Validation UI Feedback" in the generation model, but enabling it does not generate any different code at all. I've tried it with GMF 2.3 and GMF 2.4.
Running the validaton manually from the menu works, but I would prefer a fast feedback when contraints are violated. Any idea how to do that?
Thanks,
Jürgen
]]>Jürgen K2012-04-28T11:11:34-00:00Re: Instant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/865048/#msg_865048
I wantedt to have validation of my model too. I first had the approach to validate the model on each selection changed event. That was not very usable. Then I moved to validating on each save event which gave me much more usability. This is quiete easy to achieve. All you need to do is changeing the methods in xxxDiagramEditor of your generated code. Just add this line of code there:
ValidateAction.runValidation(this.getDiagram());
If this is the way you want to go I can show you how to create a custom template so that this line gets generated with your GMF code each time you generate code out of your genmodel.
Ralph]]>Ralph Gerbig2012-04-30T07:49:37-00:00Re: Instant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/868222/#msg_868222
I run now ValidateAction.runValidation() within a org.eclipse.emf.transaction.ResourceSetListener whenever the ResouceSet changes. That means after each change in the editor, even if the changes are not yet saved.
I'm still a bit unsure where to place the listener registration, currently i do it in a custom DiagramEditPart within activate(). It least it does the trick and it works without modifing generated code.
Regards
Jürgen]]>Jürgen K2012-05-01T17:59:36-00:00Re: Instant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/868569/#msg_868569
you could also create a custom code generation template. The one you would need is templates/aspects/xpt/editor/Editor.xpt. I think it is personal preference in which way you do it.
A tutorial on custom templates can be found at: http://www.bonitasoft.org/blog/eclipse/customize-your-gmf-editor-by-customizing-templates/. The attribute in the genmodel can also be set via a qvto transformation during creation out of the gmfmap model. The advantage of using the template and qvto transformation is that you can delete everything of your editor except gmfgraph, gmftool and gmfmap.
The qvto is also nice if you want to have your file being expandable in the project explorer and show the model structure there.
Cheers,
Ralph]]>Ralph Gerbig2012-05-02T08:37:23-00:00Re: Instant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/869829/#msg_869829
Thanks for the hint with the custom templates. I'll have a look at it.
Regards
Jürgen]]>Jürgen K2012-05-04T12:42:41-00:00Re: Instant model validation
https://www.eclipse.org/forums/index.php/mv/msg/343951/870114/#msg_870114
I do the resource set listener registration in MyCustomEditor#createEditingDomain()
With your solution, you should check that validation is only executed when the semantic model changed. changes to the notation model should not force a validation.