Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354826 - [model explorer] copy/paste a package does not copy diagrams (should)
Summary: [model explorer] copy/paste a package does not copy diagrams (should)
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.10.0   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Remi Schnekenburger CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 396622 396624 410423
Blocks:
  Show dependency tree
 
Reported: 2011-08-16 09:56 EDT by Raphael Faudou CLA
Modified: 2013-06-11 04:40 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Faudou CLA 2011-08-16 09:56:54 EDT
Copy a package and then paste it in another package. Only model elements are copied, no diagram is copied.
Comment 1 Remi Schnekenburger CLA 2012-03-06 12:11:51 EST
The paste manager plugin, in charge of copy/paste function in Papyrus, do not know which technology exists for diagrams. It should depend neither from the table framework nor the GMF notation framework. Moreover, semantic elements do not really know that representations are linked to them.

=> Each technology implementation should define the way diagrams/tables are duplicated when linked model elements are copied and paste with model.
This could be defined using advices from Element Edit Service.
Comment 2 Remi Schnekenburger CLA 2012-03-13 19:11:57 EDT
fixed in r7394.

Added two advices for tables and GMf diagrams to help copy diagrams and tables.
Enhanced copy commands for editing domain should be used, or the one from GMF runtime. This fix should only work on 0.8.X series, this should be really improved on 0.9 and later versions.
Comment 3 Alain Le Guennec CLA 2012-03-15 08:56:25 EDT
I have found one remaining issue:
We use Papyrus in a multi-project context (one modelset/editingdomain per project, with a shared clipboard to allow inter-project copy/paste).

Intra-project copy/paste does work well now, including diagrams.
But inter-project copy/paste does not (diagrams are not copied).

Looking quickly at the code, it seems that copied diagrams are added in the same NotationResource as the original diagram, which is not always appropriate (see org.eclipse.papyrus.diagram.common.advice.GMFDiagramDuplicateEditHelperAdvice.DuplicateDiagramCommand.doExecuteWithResult()):
-There could be multiple notation resources, even in a mono-project context, due to control mode.
-The copied diagram may be associated to an element copied into a different project altogether.

I think the right place to store the diagram would be in the NotationResource corresponding to the UmlResource of the corresponding copied element.
What do you think?
Comment 4 Remi Schnekenburger CLA 2012-03-16 11:16:10 EDT
Yes, the diagrams should be placed in the notation resource corresponding to the semantic resource where the copied element is added.
Comment 5 Remi Schnekenburger CLA 2012-03-16 11:18:56 EDT
fixed in branch in r7418
Comment 6 Alain Le Guennec CLA 2012-03-16 12:17:55 EDT
Actually, it still does not *quite* work in a multi-project context, because the target resource for diagram or table is looked-up in the source editingdomain's resource set, not in the target's resource set.

I have modified the two functions that deal with target resource computation:
-org.eclipse.papyrus.diagram.common.advice.GMFDiagramDuplicateEditHelperAdvice.getNotationResourceForDiagram(EObject, TransactionalEditingDomain)
-org.eclipse.papyrus.table.common.advice.TableDuplicateEditHelperAdvice.getNewResourceForTable(EObject, TransactionalEditingDomain)

In both functions, I have replaced the line that reads:
   Resource resource = domain.getResourceSet().getResource(targetUri, true);
... by the following lines:
   // By default, simply put it in the same resource set as the semantic element.
   ResourceSet resourceSet = containerResource.getResourceSet();
   if (resourceSet == null) resourceSet = domain.getResourceSet(); // ALG: Is this case actually possible? If not, we could simply remove the domain parameter.
   Resource resource = resourceSet.getResource(notationURI, true);

With those two changes, the right resource set is used.
I cannot easily provide a patch, as I am not working on the head of branch, but it should be trivial to integrate.
Comment 7 Remi Schnekenburger CLA 2012-03-16 12:47:06 EDT
"Patch" applied in r7423

Thanks!
Comment 8 Remi Schnekenburger CLA 2012-12-14 10:14:25 EST
fixes were not backport to 0.9.X => bug is reopened
Comment 9 Remi Schnekenburger CLA 2012-12-14 10:15:23 EST
Some bugs are still present. See the list of dependent tasks
Comment 10 Raphael Faudou CLA 2013-05-15 10:57:16 EDT
Does not work anymore in 0.10.M7 (current build)
Comment 11 Remi Schnekenburger CLA 2013-05-29 06:16:54 EDT
backported on trunk r11251
Comment 12 Remi Schnekenburger CLA 2013-06-10 13:18:57 EDT
table duplication backported in trunk 0.10.X in r11393