Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Problem when copying model elements using EcoreUtil
Problem when copying model elements using EcoreUtil [message #1802960] Tue, 19 February 2019 17:16 Go to next message
Kevin Sanchez is currently offline Kevin SanchezFriend
Messages: 10
Registered: July 2017
Junior Member
Good afternoon, we want to copy elements from one model to another model (different files in the workspace) mantaining the layout saved in the source sirius viewpoint. We are coping the model elements using EcoreUtil, and then using the functionality of drag and drop we include the element in and specific view. How can copy the model elements and copy the diagram layout from the source model too?
When we copy the model elements everything appears inside at the left top corner as shown in the attached figure.

Thank you inadvance
Re: Problem when copying model elements using EcoreUtil [message #1803029 is a reply to message #1802960] Thu, 21 February 2019 09:23 Go to previous message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 300
Registered: July 2009
Senior Member
Hello,

I think you can reuse the mechanism under the extension point org.eclipse.sirius.diagram.ui.formatDataManagern that allows to provide a specific copy/paste format manager. The copy/paste format manager by default use the semantic element as key. But sometimes, it is not enough. You can find an example [1] in Capella [2].,

But in your case, you can just create a specific org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManager, probably based on org.eclipse.sirius.diagram.ui.tools.api.format.AbstractSiriusFormatDataManager, to explicitely call in your code:
* org.eclipse.sirius.diagram.ui.tools.api.format.AbstractSiriusFormatDataManager.storeFormatData(IGraphicalEditPart): To store the format data corresponding to the edit part you want to "copy" from the source diagram
* org.eclipse.sirius.diagram.ui.tools.api.format.AbstractSiriusFormatDataManager.applyLayout(IGraphicalEditPart): To apply the layout to the new edit parts in the target diagram, after having applied the current copy tool.

You need to have a "link" between source element and target element that be retrieved with a specific org.eclipse.sirius.diagram.ui.tools.api.format.FormatDataKey created with org.eclipse.sirius.diagram.ui.tools.api.format.SiriusFormatDataManager.createKey(DSemanticDecorator).

Regards,

[1] https://git.polarsys.org/c/capella/capella.git/tree/core/plugins/org.polarsys.capella.core.sirius.ui/plugin.xml#n78
[2] https://www.polarsys.org/capella/


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Hiding duplicate element
Next Topic:Set/arrange the sub container programmatically
Goto Forum:
  


Current Time: Fri Apr 26 11:42:13 GMT 2024

Powered by FUDForum. Page generated in 0.03272 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top