|
|
|
|
|
Re: Diagram Validation Decoration [message #1064023 is a reply to message #1057753] |
Mon, 17 June 2013 10:18 |
Mario Cortes Messages: 3 Registered: March 2013 |
Junior Member |
|
|
Thanks for the answers!Thant gave me some clues!
I used the OCL plugin that permits to insert OCL constraints in the Ecore models:
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Ftutorials%2Foclinecore%2FoclInEcoreTutorial.html
Then, I activate the option to generate the corresponding Java code from the EMF models.
That creates a Validator in the util folder (ChoreographyValidator) which contains a validate method. The latter includes a call to a method that validates the OCL constraint (validateParticipant_nullPlayedRoles).
Then, in the ToolBehaviorProvider within Graphiti, I include this code in the getDecorators method:
public IDecorator[] getDecorators(PictogramElement pe) {
IFeatureProvider featureProvider = getFeatureProvider();
Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
if (bo instanceof Participant) {
Participant participant = (Participant) bo;
if (!ChoreographyValidator.INSTANCE.validateParticipant_nullPlayedRoles (participant, null, null)){
IDecorator imageRenderingDecorator = new ImageDecorator(IPlatformImageConstants.IMG_ECLIPSE_INFORMATION_TSK);
imageRenderingDecorator.setMessage("WARNING:"+ ChoreographyValidator.INSTANCE.PARTICIPANT__NULL_PLAYED_ROLES + ";"); //$NON-NLS-1$
return new IDecorator[] { imageRenderingDecorator };
}
}
...
This creates the marker instantly when the ocl constraint is not respected. No need to move or update the graphical construct.
I neither need to use extensions. I just include a dependency to org.eclipse.ocl.examples.library.
Note that this was I little test. I need to improve the constraint system.
In addition, I had some problems with the OCL plugin (the CreateDynamicModel option do not worked as expected).
Cheers,
Mario
[Updated on: Mon, 17 June 2013 10:19] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03520 seconds