Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Validation on doSave()
Validation on doSave() [message #1786910] Tue, 15 May 2018 12:01 Go to next message
Cosmin Stoinescu is currently offline Cosmin StoinescuFriend
Messages: 2
Registered: May 2018
Junior Member

I have a generated editor and I'm triggering the validation action in the doSave() function using the following line:
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(object);

The validation, returns a valid diagnostic object.
As an example, diagnostic.toString() returns:
 Diagnostic WARNING source=org.eclipse.emf.ecore code=0 ...

I have the Live Validation option disabled, because I want the validation to be done only when doSave() is triggered.
The problem is that the markers of the evaluated objests are not updated.
Is there a solution for this problem?

Thank you!

Re: Validation on doSave() [message #1786982 is a reply to message #1786910] Wed, 16 May 2018 19:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30372
Registered: July 2009
Senior Member
Have a look at org.eclipse.emf.edit.ui.action.ValidateAction to see how it creates markers.
Re: Validation on doSave() [message #1786989 is a reply to message #1786982] Wed, 16 May 2018 20:20 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6440
Registered: July 2009
Senior Member

You need to be aware that there are two kinds of marker and two different marker idioms.

Internal markers/annotation markers appear within an editor when the editor validates internally,.

External markers/problems view markers are created from an external resource and persist across Eclipse restarts. External markers are often visible internally as well, sometimes causing confusion when they remain in the editor for too long.

The normal Eclipse idiom is that a nature+builder combine to refresh the external/problems view markers when a relevant resource changes/is cleaned.

EMF does not comply with the Eclipse idiom since it has no nature/builder. External markers are therefore created for the prevailing selection by a validate. An EMF Resource may therefore have stale and partial external markers.

The EMF idiom is simpler but inaccurate. Once you add a builder, hidden *.ecore bugs suddenly show up. It's quite frightening. But would you wait till you edit/compile a Java file to find out what bugs it has?

OCL switches policies for Photon to exploit the new EMF EAnnotationValidators for OCL embedded in Ecore. The new OCL builder has the option to show accurate Ecore/UML markers.

The Xtext builder also builds EMF resources for the benefit of its index, but I have never quite understood why problems view markers suddenly appear/disappear long after Eclipse has started.


Ed Willink
Previous Topic:Ecoreutil.copier
Next Topic: [CDO] Easier Eclipse debugging on CDOObject instances
Goto Forum:

Current Time: Sun Aug 25 04:29:55 GMT 2019

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

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

Back to the top