Diagram Validation Decoration [message #979045] |
Sat, 10 November 2012 10:18  |
Eclipse User |
|
|
|
With respect to showing model validation directly in diagrams I'm kind newbie.
Which ways do I have to decorate my diagram when something the metamodel+OCL+... doesn't allow ,is happening?
I'm using now DefaultToolBehaviorProvider#getDecorators to "indicate" when and where decoration must be placed, but I'm doing everything inside the method.
I want to separate or even use OCL and relate the constraints with diagram decoration.
Is there any way to do that? Can you point me some material / project.
Thanks in advance.
Rui Domingues
|
|
|
|
|
|
|
Re: Diagram Validation Decoration [message #1064023 is a reply to message #1057753] |
Mon, 17 June 2013 06:18  |
Eclipse User |
|
|
|
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 06:19] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03959 seconds