I am implementing a synchronization mechanism in Papyrus that keeps an UML model and an ECORE model consistent.
Now I want to hook in the Delete Command so that e.g. for every UML::Class the corresponding ECORE::EClass is deleted. I saw that there is this centralized ElementEditService that access the EditHelpers. So, I tried to override the existing EditHelpers and call my own DestroyElementPapyrusCommand that deletes the EClass.
In Papyrus, we use org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice (org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice) to add Advices (Pre/Post actions) for an EditHelper. You can add them by adding an "adviceBinding" element in the elementTypes extension point.
See org.eclipse.papyrus.uml.service.types/plugin.xml for a few examples.
Thank you for your reply. I tried that, but only the constructor of my Advice class is called, when I want to "Delete Selected Element" from the context menu.
Now, I am using the following plugin.xml. Actually, when I use this XML, I cannot delete messages between lifelines anymore ("Delete Selected Element" is disabled). I discovered that, because there is already an existing MessageHelperAdvice I tried out. So maybe there is a problem when you use the same elementTypeBindings or ClientContexts multiple times?
I want to synchronize Associations between Classes as well. I tried to create an AssociactionEditHelperAdvice, but I cannot get it running.
In a first step, I put some breakpoints into the classes org.eclipse.papyrus.uml.service.types.helper.AssociationBaseEditHelper and org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice, but none of their methods is called when I draw an Association between two Classes.
Maybe it is because of this?
<!-- ISpecializationType Association of UML::AssociationBase -->
<specializationType id="org.eclipse.papyrus.uml.Association" name="UML::Association"
<param name="semanticHint" value="UML::Association"/>
<specializes id="org.eclipse.papyrus.uml.AssociationBase" />
<matcher class ="org.eclipse.papyrus.uml.service.types.matcher.AssociationMatcher" />
What's wrong here? Or do I have to override org.eclipse.papyrus.uml.diagram.clazz.edit.policies.ClassItemSemanticEditPolicy.getCompleteCreateRelationshipCommand(CreateRelationshipRequest) instead?