Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Automatic validation on Save EMF model
Automatic validation on Save EMF model [message #1766671] Sat, 24 June 2017 21:21 Go to next message
Sara Rosa is currently offline Sara RosaFriend
Messages: 24
Registered: March 2017
Junior Member
Hi all,

I added extra validation to my tree generated editor with EVL. This validation is only executed when the user clicks the "validate" button and I would like to validate the model automatically when the user saves it.

I came across this solution (https://stackoverflow.com/questions/8594212/how-to-programmatically-trigger-validation-of-emf-model) but I don't know how to apply it... Can anyone help me? Is this a good solution?

Thanks,

Cheers,
Sara

[Updated on: Sat, 24 June 2017 21:22]

Report message to a moderator

Re: Automatic validation on Save EMF model [message #1766679 is a reply to message #1766671] Sun, 25 June 2017 16:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29136
Registered: July 2009
Senior Member
I'm not sure what this "validate" button is. The generated editor doesn't have such a thing, but it does have a validate action in the context menu for the selected objects as implemented by org.eclipse.emf.edit.ui.action.ValidateAction.run(). You could invoke that when the generated editor's XyzEditor.doSave(IProgressMonitor) is called.
Re: Automatic validation on Save EMF model [message #1766680 is a reply to message #1766679] Sun, 25 June 2017 17:55 Go to previous messageGo to next message
Sara Rosa is currently offline Sara RosaFriend
Messages: 24
Registered: March 2017
Junior Member
Hi Ed,

Thanks for your message.

Yes, "validate" action. I added the ValidateAction.run() to this method on one of the Editors but nothing happened...

protected void doSaveAs(URI uri, IEditorInput editorInput) {
(editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
IProgressMonitor progressMonitor =
getActionBars().getStatusLineManager() != null ?
getActionBars().getStatusLineManager().getProgressMonitor() :
new NullProgressMonitor();
doSave(progressMonitor);
ValidateAction.run();
}

What am I doing wrong? Thanks

Cheers,
Sara
Re: Automatic validation on Save EMF model [message #1766687 is a reply to message #1766680] Sun, 25 June 2017 20:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29136
Registered: July 2009
Senior Member
It's not a static method; does this even compile? I doubt it. Also, the action operates on the selection and it listens to selection changes, so you'd need logic for org.eclipse.emf.edit.ui.action.ValidateAction.updateSelection(IStructuredSelection) as well.
Re: Automatic validation on Save EMF model [message #1766688 is a reply to message #1766687] Sun, 25 June 2017 21:12 Go to previous message
Sara Rosa is currently offline Sara RosaFriend
Messages: 24
Registered: March 2017
Junior Member
Hi Ed,

Ed Merks wrote on Sun, 25 June 2017 20:56
It's not a static method; does this even compile? I doubt it. Also, the action operates on the selection and it listens to selection changes, so you'd need logic for org.eclipse.emf.edit.ui.action.ValidateAction.updateSelection(IStructuredSelection) as well.


Do you have any example on how can I do that? Thanks

Cheers,
Sara
Previous Topic:[CDO] How to build cdo from sources
Next Topic:XText(L) -> model(L) -> JVM bytecode; which toolchain for that?
Goto Forum:
  


Current Time: Wed Jan 24 10:09:36 GMT 2018

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

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