Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Cancel EVL validation that is in progress(When user clicks cancel button of progress monitor)
Cancel EVL validation that is in progress [message #987705] Tue, 27 November 2012 16:48 Go to next message
Maarten Bezemer is currently offline Maarten Bezemer
Messages: 117
Registered: February 2012
Senior Member
Hi all,

I have implemented model validation using EVL. This all works great (well have some problems, but will be another story if I feel up for it).

The models that need validation might become large, which in combination of a slow PC might result in several minutes validation time.
So I added a Job (which runs on the background) so the user is still able to work on the model or other things).

Of course, the user might become restless and annoyed and wants to cancel the job using the cancel button on the progress monitor (which popped up due to the Job). My code handles this fine (validation requests are queued), but the status of the monitor is only checked in between validations (that might take this long time)...

The actual question:
I am wondering how to abort a validation that is still in progress when the user clicks the cancel button? It is even possible to cancel/abort an EVL validation or is additional support by Epsilon required? And while we are at it, is it possible to show the validation progress in the monitor?

Thanks,
Re: Cancel EVL validation that is in progress [message #987746 is a reply to message #987705] Tue, 27 November 2012 21:36 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 309
Registered: January 2010
Senior Member
Hi Maarten,

It depends on how you're launching the EVL script from your job. Since you're running the EVL script from Eclipse, you're probably calling EclipseContextManager#setup to set up Eclipse integration for the context of the EVL module, right?

There's a version of setup that takes both the IEolContext and an IProgressMonitor. If you tie up the return value of the IProgressMonitor#isCanceled() method to the cancel button, the EVL script should be cancelled properly when the user hits the cancel button.

That's pretty much how the cancel button is implemented for all the E*L launch configurations, basically.

As for the progress bar, I don't think we have anything in Epsilon for that. Could you file a feature request for that? How should we measure progress? Should we measure progress by the number of checked constraints, or by the number of checked objects? I think the second option won't scale well to large models, though.

No problem,
Antonio
Re: Cancel EVL validation that is in progress [message #987808 is a reply to message #987746] Wed, 28 November 2012 09:09 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten Bezemer
Messages: 117
Registered: February 2012
Senior Member
Antonio Garcia-Dominguez wrote on Tue, 27 November 2012 22:36

It depends on how you're launching the EVL script from your job. Since you're running the EVL script from Eclipse, you're probably calling EclipseContextManager#setup to set up Eclipse integration for the context of the EVL module, right?

Not exactly, the validator is created using
IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH);
...
validator.validate(myObject);


During validation my model constraint (provided using the org.eclipse.emf.validation.constraintProviders extension) is found.
In the validate() method I use (a slightly modified version of) the Eclipse diagnostican:
EObject target = ctx.getTarget();
Diagnostician diagnostician = new MyDiagnostician();
Diagnostic diagnostics = diagnostician.validate(target);


The diagnostican class finds the EVL constraint files using the used instances of the extension org.eclipse.epsilon.evl.emf.validation and the actual validation (using the EMF Validation framework) is performed.

Hm... now I wrote this down: this seems a little complicated just to get validation working...

Antonio Garcia-Dominguez

There's a version of setup that takes both the IEolContext and an IProgressMonitor. If you tie up the return value of the IProgressMonitor#isCanceled() method to the cancel button, the EVL script should be cancelled properly when the user hits the cancel button.


So, I do not have this setup() method I believe..?

I try to keep the EMF validation in the loop, so the validator shows in the Eclipse 'Model Validation' preferences, so the user is able to disable them. And to be able to get regular notifications of the validation result using the IValidationListener interface.

I do need another method to activate the EVL validations? (preferably while keep using the Eclipse/EMF validation framework)

Antonio Garcia-Dominguez

As for the progress bar, I don't think we have anything in Epsilon for that. Could you file a feature request for that? How should we measure progress? Should we measure progress by the number of checked constraints, or by the number of checked objects? I think the second option won't scale well to large models, though.


Hm... I did not think of a measure for the amount of work...

Checking by the amount of constraints might be an option, as it is probably easier to get the total amount than the total amount of (nested) objects that needs to be checked? (Especially since the complete resource is currently validated). Also after parsing the EVL files, the number of validation rules is probably known already?
Only thing is, I register a unknown/certain amount of EVL validators. The total progress of one validation cycle, should keep this amount in mind...? Also possible as org.eclipse.epsilon.evl.emf.validation.EValidatorPopulator registers all my validators.
Re: Cancel EVL validation that is in progress [message #987831 is a reply to message #987808] Wed, 28 November 2012 10:31 Go to previous message
Maarten Bezemer is currently offline Maarten Bezemer
Messages: 117
Registered: February 2012
Senior Member
I got curious about EclipseContextManager#setup and saw it was used in the EVLValidator class (which I use somewhere along the line).

I solved my problem and provided a patch: see Bug #395261

Because I execute the validation from a background thread (Job), I get another problem because a MessageDialog is opened on the wrong (non-UI) thread, see Bug #395262.

[Updated on: Wed, 28 November 2012 10:32]

Report message to a moderator

Previous Topic:[EVL] CritiqueLevel
Next Topic:[EVL] How to acces a element in my model
Goto Forum:
  


Current Time: Fri Oct 24 08:47:04 GMT 2014

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

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