Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Instant model validation
Instant model validation [message #861089] Sat, 28 April 2012 11:11 Go to next message
Jürgen KFriend
Messages: 3
Registered: April 2012
Junior Member
Hi,

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

Re: Instant model validation [message #865048 is a reply to message #861089] Mon, 30 April 2012 07:49 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

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
Re: Instant model validation [message #868222 is a reply to message #865048] Tue, 01 May 2012 17:59 Go to previous messageGo to next message
Jürgen KFriend
Messages: 3
Registered: April 2012
Junior Member
Hi,

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
Re: Instant model validation [message #868569 is a reply to message #868222] Wed, 02 May 2012 08:37 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

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
Re: Instant model validation [message #869829 is a reply to message #868569] Fri, 04 May 2012 12:42 Go to previous messageGo to next message
Jürgen KFriend
Messages: 3
Registered: April 2012
Junior Member
Hi Ralph,

Thanks for the hint with the custom templates. I'll have a look at it.

Regards
Jürgen
Re: Instant model validation [message #870114 is a reply to message #869829] Sun, 06 May 2012 16:39 Go to previous message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
Hi Jürgen,

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.

Regards,
Andreas





Previous Topic:Not able to create new GMF project
Next Topic:How to create a umlclass file, and create some notations and then save by programming
Goto Forum:
  


Current Time: Sat Oct 24 03:47:26 GMT 2020

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

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

Back to the top