Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to use EVL validation from GEF
How to use EVL validation from GEF [message #870772] Wed, 09 May 2012 15:23 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Currently I am not using GMF, but would like to use EVL for my (live) validations.

Is this possible? I do not seem able to find any documentation on this subject.

Note: I already removed the GmfMarkerResolver class to remove the dependency of org.eclipse.epsilon.evl.emf.validation on GMF (see bug #378998 (still no links, sorry))
Re: How to use EVL validation from GEF [message #870918 is a reply to message #870772] Thu, 10 May 2012 09:09 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 918
Registered: July 2009
Senior Member
Hi Maarten,

One option would be to hook into the EMF validation framework using [1] (without the GMF dependency which indeed makes more sense to be optional - thanks). Another option would be to get hold of your EMF resource and then evaluate a specific EVL file on it as demonstrated in [2].

Cheers,
Dimitris

[1] http://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/plugins/org.eclipse.epsilon.evl.emf.validation/
[2] http://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/examples/org.eclipse.epsilon.examples.standalone/
Re: How to use EVL validation from GEF [message #870965 is a reply to message #870918] Thu, 10 May 2012 11:22 Go to previous message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
I managed to get it working for GEF, so I'll put some notes here for others.

Registering my EVL file in the EMF validation did not cause too much problems using the org.eclipse.epsilon.evl.emf.validation.org.eclipse.epsilon.evl.emf.validation extension.

Finding out how to activate this registered EVL file, was a bigger challenge.
In the end I found out about the Diagnostician class (in emf.ecore.util) and that is it able to 'find' the EVL file and use it for its diagnostics.
I created a AbstractModelConstraint that uses the Diagnostician class for its validation and convert the result into a status:
public class MyConstraint extends AbstractModelConstraint
{
    @Override
    public IStatus validate(IValidationContext ctx)
    {
        Diagnostician diagnostician = new Diagnostician();
        Diagnostic diagnostics = diagnostician.validate(ctx.getTarget());

        if (diagnostics.getSeverity() == Diagnostic.OK)
        {
            return createSuccessReport(ctx, target);
        }

        List<Diagnostic> diagnosticsChildren = diagnostics.getChildren();
        if (diagnosticsChildren.size() == 1)
        {
            Diagnostic child = diagnosticsChildren.get(0);
            return createFailureReport(ctx, target, child.getMessage());
        }

        // Create multiple failure reports and combine into a multistatus report
        List<IStatus> statusList = new ArrayList<IStatus>(diagnosticsChildren.size());
        for (Diagnostic child : diagnosticsChildren)
        {
            statusList.add(createFailureReport(ctx, target, child.getMessage()));
        }

        return ConstraintStatus.createMultiStatus(ctx, statusList);
    }
}


The constraint can be registered using the org.eclipse.emf.validation.constraintProviders extension and a validation listener can be used to do something with the validation result (eg creating markers)
Previous Topic:Changing the file permission of the generated EGL template
Next Topic:[Doubt] About Eugenia
Goto Forum:
  


Current Time: Thu Dec 18 07:33:33 GMT 2014

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

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