简体   繁体   English

如何以编程方式触发EMF模型的验证?

[英]How to programmatically trigger validation of EMF model?

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. 在使用EMF创建的编辑器中,可以通过右键单击任何建模元素并从上下文菜单中选择“验证”来验证模型。 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? 有谁知道如何以编程方式实现这一目标?

You should be able to trigger the validation thanks to org.eclipse.emf.ecore.util.Diagnostician (call Diagnostician.INSTANCE.validate(...) ). 由于org.eclipse.emf.ecore.util.Diagnostician(调用Diagnostician.INSTANCE.validate(...) ),您应该能够触发验证。 You can have a look at its javadoc . 你可以看看它的javadoc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM