Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Derived Property
Derived Property [message #1706147] Mon, 24 August 2015 08:08 Go to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
How do i implement the custom method for a derived EReference?

In my Ecore model an Eclass has a child reference that i like to make derived from another child reference. Adjusting the getter to create the objects i need and set them leads to all kinds of problems, concurrent write exception, resource adjusted outside of workspace..

Basicly the Eclass is instance of a class and the child derived ereference are instances derived from that class.

Some more information/guide on how to use the derived property would also be usefull.
Re: Derived Property [message #1706159 is a reply to message #1706147] Mon, 24 August 2015 09:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Koen,

Comments below.

On 24/08/2015 10:08 AM, Koen Staal wrote:
> How do i implement the custom method for a derived EReference?
Is it a multi-valued references?
>
> In my Ecore model an Eclass has a child reference that i like to make
> derived from another child reference.
Single valued references?
> Adjusting the getter to create the objects i need and set them leads
> to all kinds of problems, concurrent write exception, resource
> adjusted outside of workspace..
Yes, you should never modify the model as a result of getters (and
certainly not let notifications leak out)....
>
> Basicly the Eclass is instance of a class and the child derived
> ereference are instances derived from that class.
>
> Some more information/guide on how to use the derived property would
> also be usefull.
It's not possible to implement derived containment and you should not be
creating contained objects in getters.

So it's hard to give good advice... If you're trying to prepopulate
contained objects you should do that either in addition factory methods,
or in the child creation in the item providers.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Derived Property [message #1706177 is a reply to message #1706159] Mon, 24 August 2015 12:52 Go to previous messageGo to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
Thanks for your quick response. It wasnt my intention to keep logic in the getter i just made quick example to figure out what setting the derived property really does for the ecore model. It seemed something i could use but its hard to find any description on it and when to use it. The prepopulting is probably what i want to do so i gues i will leave derived for what it is.
Re: Derived Property [message #1706251 is a reply to message #1706177] Tue, 25 August 2015 10:12 Go to previous messageGo to next message
Koen Staal is currently offline Koen StaalFriend
Messages: 70
Registered: October 2014
Member
I have looked into the possible solutions, and this post discourages adjusting the factory. In the itemprovider however i cant figure in which method i can add the creation of new Eobject. collectNewChildDescriptors seems to never get called.

Any suggestion what method i should adjust?

[Updated on: Tue, 25 August 2015 11:39]

Report message to a moderator

Re: Derived Property [message #1706320 is a reply to message #1706251] Tue, 25 August 2015 16:19 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Koen,

Comments below.

On 25/08/2015 12:12 PM, Koen Staal wrote:
> I have looked into the possible solutions, and this post
> http://eclipsesource.com/blogs/2013/03/13/emf-dos-and-don%C2%B4ts-4/
> discourages adjusting the factory.
It discourages changing what the existing methods in the factory do. In
general you should not initial objects beyond the normal generated
state. So no calling setters in the constructors or in the factory
methods, no calling setters in any getter methods, and so on. There's
nothing to argue against adding additional convenient methods to the
factory to do whatever you like. Just don't disrupt the default behavior.
> In the itemprovider however i cant figure in which method i can add
> the creation of new Eobject. collectNewChildDescriptors seems to never
> get called.
You'll see methods in the container object's item providers for creating
the contained types of children. There you can create any kind of
initialized child that you like.
>
> Any suggestion what method i should adjust?
Here's how I would find this out if I didn't know how a framework
worked. I'd set a breakpoint in the constructor of the object and then
I'd go to the editor and create an instance of it. Then I could see
how and where that instance is being created...


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:eGet of an Attribute results in an IllegalArgumentException
Next Topic:[CDO] Error when saving a model having two editors opened
Goto Forum:
  


Current Time: Tue Apr 23 12:37:32 GMT 2024

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

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

Back to the top