MIRA: Copy traces when copying requirements
At the moment traces of requirements are not copied when pasting the requirement after a copy or cut action.
Traces should be also copied/moved after a affirmation of the user (confirmation dialog).
#6 Updated by Anonymous about 6 years ago
The way to do this is to let
Requirement (with the real implementation being in
RequirementStaticImpl of course) implement
org.fortiss.tooling.kernel.model.SpeciallyCopyiable.java (a change to .ecore is necessary).
There is only one method to be implemented, namely the
specialCopyHook(Map<EObject, EObject> copyMap) which is called on both, copy/cut and paste. This can be seen in org.fortiss.tooling.kernel.ui.util.CopyPasteUtils.java.
Every element which implements
SpeciallyCopyiable will have the
specialCopyHook called separatedly.
RequirementStaticImpl.java we then should get void
specialCopyHook(RequirementImpl requirementImpl, Map<EObject, EObject> copyMap).
One can not directly differ whether a current call of
specialCopyHook is called from copying/cuting or pasting. Unsure and hard to explain content ahead: the only difference is the map we are copying to. When copying/cuting the map is the clipboard and when pasting the map is the real model. When copying/cuting we therefore have only the map's content and no real model instances of the content. When pasting we have the map's content and real model instances of, for example, the requirements that were selected to be pasted. So by checking whether there are real model instances we can find out whether we just have to only create a RequirementRelation and add it to the map or to create one and add it to the analysis node. (Dr. Aravantinos is the expert on this matter and has done something similar but not equal with Component ports, which can be found by checking the type hierarchy of SpeciallyCopyiable)
A possible pitfall is when more than one requirement is selected and put in the clipboard. For the following example lets assume we have two requirements in the clipboard, though more complex scenarios are possible.
If those two requirements share a requirement relation, then it is wished that the newly created requirements also share the newly created requirement relation, which is created by
specialCopyHook. As every requirement has its own call of
specialCopyHook though, we can not just create a requirement relation and set its targets and sources, we have to check for which requirements are in the copy map and which are not and set targets and sources accordingly.
When cuting (Ctrl+X) it is to note that selected requirements and related requirement relations which become empty are destroyed, so a full representation of requirements and their requirement relations has to be saved to the copy map.
It definitely is possible but someone with more knowledge about creating components, adding them to the analysis node (and make all this work with the CommandStackService to provide bugless change revert ?) is required.