|Re: Override the default behavior of a merge action [message #1412574 is a reply to message #1412229]
||Tue, 26 August 2014 13:45
| Olivier Constant
Registered: January 2012
Yes, it is possible. This kind of customization is normally handled by the merge policy, but this request goes a bit beyond the current capabilities of merge policies. So you are going to have to dig a bit more.|
You have to subclass DiffOperation. The DiffOperation is in charge of computing differences according to the diff policy, and setting merge dependencies between them according to the merge policy.
A merge dependency from a difference A to a difference B for a given direction (left or right, to simplify) can be of two kinds:
- "implies": the merging of A automatically implies the merging of B without doing anything specific - for example, corresponding values on opposite references;
- "requires": the proper merging of A requires that B be merged first - for example, a reference from element E1 to element E2 requires that E2 be present.
In your case, you want to specify that the merge of a value presence on your specific attribute requires the merge of all other value presence differences on that attribute on the same element.
Have a look at DiffOperation::createAttributeValueDifference(...). At the beginning of the method body, you can see how "symmetrical value differences" - different values on the same attribute of multiplicity  - are handled. A call is made to method setSymmetricalValuePresenceDependencies(...) which sets up interdependencies between the two "symmetrical" differences.
You would need to do something similar for your differences on attribute values. You can call getAttributeDifferences(EAttribute) on your IMatch to get the other differences on the same matching elements for the same attribute, then use method markRequires(...) to specify the interdependencies.
Once you have defined your specialization of DiffOperation, you can use it by subclassing EComparisonImpl and redefining method getDiffOperation(...). Then if you are using the standard editor initialization mechanism, you can use your subclass of EComparisonImpl in method EMFDiffMergeEditorInput::prepareInput(...).
Hope that helps.
Powered by FUDForum
. Page generated in 0.02070 seconds