| start EVL validation from wizard [message #1681345] |
Tue, 17 March 2015 05:15  |
Eclipse User |
|
|
|
Hi all,
I created a GMF editor using Epsilon / Eugenia and I also defined some EVL constraints for the model. Validation works as expected. What I do with the model is that I offer a wizard to transform the model to a different model, which also works fine. What I want to achieve now is, that before the transformation is executed, the model is automatically validated (using my EVL contraints) and that the transformation is only started when there are no errors.
So my question is basically how to execute EVL validation programmatically as part of a wizard (which is started by right-clicking on the model file and selecting the corresponding option in the context menu).
Thanks in advance for any hints.
Florian
|
|
|
|
| Re: start EVL validation from wizard [message #1682292 is a reply to message #1681763] |
Tue, 17 March 2015 13:27   |
Eclipse User |
|
|
|
Hi Dimitris,
thanks for the fast feedback.
If I create a tool, who will call it? The ETL transformation?
You suggested to run the validation programmatically using:
ValidateAction.runValidation((View) document.getContent());
Where do I get the View (or IDocument) object from if I put this code into a tool (and not into the DocumentProvider class)?
If I understand correctly, the use of a View indicates a dependency to GMF, i.e. to a graphical editor. What I currently do is independent of GMF, maybe this is my main problem. Let me show some code snippets:
public class MyHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IFile selectedFile = ...;
fileURI = selectedFile.getLocationURI().toString();
// TODO validate model here
// open a SaveAs dialog for the target file
...
// run a wizard to ask the user for some transformation parameters
...
// run the transformation
ETLExecutor executor = new ETLExecutor(MODEL_NAME, ETL_SCRIPT_LOCATION);
...
executor.execute();
}
}
The handler is activated when right-clicking on a EMF model file (that has been created using a GMF editor). Before processing the file I want to validate it, this is what my question was about. After that (this is already working) the user is asked for a target file and some parameters and the ETL transformation is executed.
I can load the EMF model from the file using the following code:
EmfModel model = EmfModelFactory.getInstance().loadEmfModel(MODEL_NAME, file, MODEL_NS, AccessMode.READ_ONLY);
Is there any chance to execute a EVL validation on this model without having the model opened in a GMF editor?
Thanks and regards
Florian
|
|
|
|
| Re: start EVL validation from wizard [message #1683876 is a reply to message #1682856] |
Wed, 18 March 2015 03:39  |
Eclipse User |
|
|
|
Hi Dimitris,
many thanks, it works now! And I realized that it works the same way as the transformation that is executed afterwards, so the solution was already in my code (although I did not write that part)...
Florian
|
|
|
Powered by
FUDForum. Page generated in 0.05926 seconds