Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Copy Paste issue(Copy Paste issue when the meta-model contains EClass having more than one containment references to the same EClass.)
Copy Paste issue [message #1800954] Thu, 10 January 2019 10:27 Go to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 104
Registered: February 2016
Senior Member
Consider the following meta-model: meta-model.jpg. Note the two containment references input and output from the Operation meta-class to the Parameter meta-class.

When copying an output parameter from one operation and pasting it into an other operation (using the generated EMF tree editor), it pastes the copied output parameter as an input parameter.

Hint: I analysed the code a little bit and as far as I understand, the copy command copies only the EObject to the clipboard. The paste command takes the content of the clipboard and (since it is not aware where the EObject has been copied from) pastes into the first EStructuralFeature that suits.

What are the suggessted way to overcome this problem?
Would it be possible to provide a general solution in the EMF framework itself?
Re: Copy Paste issue [message #1800965 is a reply to message #1800954] Thu, 10 January 2019 12:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6795
Registered: July 2009
Senior Member

Hm. Thinking about the copy-target container helps me understand why the inter model DND capability of the Sample Ecore Editor varies from poor to non-existent; it is a hard problem and it is only a SAMPLE Ecore Editor.

Arguably the copy could/should have put the copy as an orphan in the Resource root, but EMF discourages multi-rooted Resources, so perhaps you are lucky that it found a container. naively "input" is better since it has [*] multiplicity and will always work whereas "output" [?] might already be used.

It would be possible for the copied EObject to retain an eContainingFeature as a hint for the subsequent paste, but it wouldn't always work.

Fundamentally the tree-paradigm does not adequately distinguish different categories of children. This could be remedied by extra nesting or <<role>> prefixes at the expense of adding clutter always to avoid confusion sometimes. This would have enabled you to paste on the extra nesting / role. The confusion could be resolved by a better Properties View that showed ALL children. Perhaps a Properties View might give you more precise paste/drop targets.

Way to overcome the problem? use a graphical editor such as the Ecore Tools Diagram or just see what happens and fix it up manually.

General solution? possible, but I suspect it requires quite a bit of research to avoid degrading more than you enhance.


Ed Willink
Re: Copy Paste issue [message #1800967 is a reply to message #1800965] Thu, 10 January 2019 12:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31362
Registered: July 2009
Senior Member
Well, the default presentation for this model will also be confusing to the user because an operation will show both the input parameters and the output parameter under the operation. The user will not be able to distinguish which is which just looking at the flat combined list that they see, i.e., is the last parameter the output parameter? That's why Ed W suggests an intermediate node, at least in the tree view as induced by the item providers. That's quite a bit of work to get exactly right (as documented in the EMF book). Must easier would be to change the model to add a bit to a parameter to indicate whether it's an input or an output (and define a constraint on operation that there can be at most one parameter that is an output or even that it should be last).

Ed Merks
Professional Support:
Re: Copy Paste issue [message #1800969 is a reply to message #1800967] Thu, 10 January 2019 12:48 Go to previous message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 104
Registered: February 2016
Senior Member
Ok. Thank you both for your quick reply!
Previous Topic:Problem when use generator in java code
Next Topic:[CDO] Best way to manage Detached object/Stale References
Goto Forum:

Current Time: Sun Aug 09 15:38:20 GMT 2020

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

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

Back to the top