Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Best Practice for building and pasting data structures
Best Practice for building and pasting data structures [message #686050] Tue, 21 June 2011 14:02 Go to next message
Michael Jastram is currently offline Michael JastramFriend
Messages: 235
Registered: April 2010
Location: Düsseldorf, Germany
Senior Member
Hello,

I often have to attach larger data structures to my model. Of course I do this with a command. However, I used to build up the data structures "by hand". Once the data structure is complete, I can attach it with a command, e.g.

Item item = factory.createItem();
Color color = factory.createColor();
item.setColor(color);
Command cmd = SetCommand.create(editingDomain, cart, ItemPackage.Literals.CART__THE_ITEM, item);
editingDomain.getCommandStack().execute(cmd);


The problem: The model will never be notified when the color on the item is set. But I may very well be interested in that notification.

I stopped doing this. Instead, I use a number of commands and pack them into a CompoundCommand.

Question one: Is this the recommended approach, or is there an even better one?

Unfortunately, I encounter a similar situation where this approach doesn't work: Copy and Paste. When I paste a structure, notifications are only generated for the root element that is pasted, not for all the children hanging on it. Do I have to explicitly build a visitor and let it run over the structure?

There is one scenario that I am sure others have encountered: If I paste objects that have IDs multiple times, I end up with non-unique IDs. So I have to inspect all children of a node upon paste. Upon encountering conflicts, I have to create new IDs. What's the best approach to this situation? I solved it with a visitor that runs upon paste, but it has a clunky feel to it.

Thanks,

- Michael
Re: Best Practice for building and pasting data structures [message #696590 is a reply to message #686050] Thu, 14 July 2011 10:54 Go to previous message
Nirmal SasidharanFriend
Messages: 120
Registered: July 2009
Location: Germany
Senior Member
+1
I am also interested to know the right EMF approach for Question 1 above.

Nirmal
Previous Topic:Migration from EMF 2.4 to EMF 2.5
Next Topic:linking a help context to a model feature and the property dialog
Goto Forum:
  


Current Time: Fri Mar 29 13:12:00 GMT 2024

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

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

Back to the top