How to programmatically trigger validation of EMF model?
Asked Answered
B

1

9

In an editor created with EMF, one can validate a model by right-clicking on any modeled element and choosing "Validate" from the context menu. I want to call this functionality programmatically. My use case is that I want to validate the model when the user attempts to open a wizard. Based on the validation outcome, the wizard will either open (validation succeeded) or the found errors will be displayed.

Does anyone know how to achieve this programmatically?

Basia answered 21/12, 2011 at 17:57 Comment(0)
W
12

You should be able to trigger the validation thanks to org.eclipse.emf.ecore.util.Diagnostician (call Diagnostician.INSTANCE.validate(...)). You can have a look at its javadoc.

Workmanlike answered 21/12, 2011 at 19:48 Comment(2)
Hi Stephane, thanks for the quick response. I am still a little puzzled about what eObject to pass the validate method to validate the overall model?Basia
Hi, you can give it the root(s) of your model.Workmanlike

© 2022 - 2024 — McMap. All rights reserved.