如何以编程方式触发 EMF 模型的验证?
在使用 EMF 创建的编辑器中,可以通过右键单击任何建模元素并从上下文菜单中选择“验证”来验证模型。我想以编程方式调用此功能。我的用例是,我想在用户尝试打开向导时验证模型。根据验证结果,向导将打开(验证成功)或显示发现的错误。
有谁知道如何以编程方式实现这一目标?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够通过 org.eclipse.emf.ecore.util.Diagnostician(调用
Diagnostician.INSTANCE.validate(...)
)触发验证。您可以查看 它的 javadoc。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.