Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Duplicate Content Instances in Eclipse Runtime Application(When i create entries for an EList programmatically in Constructor i get all of them twice)
Duplicate Content Instances in Eclipse Runtime Application [message #1723089] Thu, 11 February 2016 13:59 Go to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Hey,

i want to use my ecore model within the generated editor.

I have a root object "diagram" with a content "Cont", which holds a "list" content as EList.
Because i want my diagram to hold 1 Cont Object per default, i set an instance of Cont in the diagram constructor.
And Cont's list should per default be filled with exactly 1 entry, which i add in the Cont constructor.

Now when i start my runtime application and create a new instance of my diagram model. My Diagram holds exactly 1 Cont Object, but the list has exactly 2 entries with identically parameters.

If i do all of this manually or within a java test class, everything is right.

I although tried it with a map and override the equals method of my list type, but it's still wrong.

I although tried to create it with TransactionalEditingDomain with an addCommand, but same problem.

What am i missing? How do i create and add this programmatically?

Regards,
Matt

[Updated on: Thu, 11 February 2016 14:00]

Report message to a moderator

Re: Duplicate Content Instances in Eclipse Runtime Application [message #1723091 is a reply to message #1723089] Thu, 11 February 2016 14:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29112
Registered: July 2009
Senior Member
Matt,

Comments below.


On 11.02.2016 14:59, Matt Se wrote:
> Hey,
>
> i want to use my ecore model within the generated editor.
>
> I have a root object "diagram" with a content "Cont", which holds a
> "list" content as EList.
> Because i want my diagram to hold 1 Cont Object per default, i set an
> instance of Cont in the diagram constructor.
In the generated constructor? That's a very bad idea. Don't do that.
> And Cont's list should per default be filled with exactly 1 entry,
> which i add in the Cont constructor.
Don't do that either.
>
> Now when i start my runtime application and create a new instance of
> my model. My Diagram holds exactly 1 Cont Object, but the list has
> exactly entries with identically parameters.
Don't specialize the generated model constructors or the generated
factory methods. If you need to do these kinds of things in code,
provide specialized additional factory methods. If you just need it in
the UI, do it in the wizard, or the item providers.
>
> If i do all of this manually or within a java test class, everything
> is right.
>
> I although tried it with a map and override the equals method of my
> list type, but it's still wrong.
I have no idea what you mean by this sentence...
>
> I although tried to create it with TransactionalEditingDomain with an
> addCommand, but same problem.
"It"? What problem?
>
> What am i missing? How do i create and add this programmatically?
There's just no enough context here. If this is a GMF question, best
ask on the GMF forum.
>
> Regards,
> Matt
>
>
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1755571 is a reply to message #1723091] Sun, 05 March 2017 21:22 Go to previous messageGo to next message
khalid nasr is currently offline khalid nasrFriend
Messages: 23
Registered: March 2017
Junior Member
I Have the same problem
did you fin a solution ??
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1755572 is a reply to message #1723091] Sun, 05 March 2017 21:23 Go to previous messageGo to next message
khalid nasr is currently offline khalid nasrFriend
Messages: 23
Registered: March 2017
Junior Member
I Have the same problem
did you fin a solution ??
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1755573 is a reply to message #1723091] Sun, 05 March 2017 21:23 Go to previous messageGo to next message
khalid nasr is currently offline khalid nasrFriend
Messages: 23
Registered: March 2017
Junior Member
I Have the same problem
did you fin a solution ??
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1755582 is a reply to message #1755573] Mon, 06 March 2017 05:37 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29112
Registered: July 2009
Senior Member
I answered this question already. Populating an instance should not be done in the constructor, nor in the existing factory methods. You could add additional factory methods to create a populated instance. Or, in the generated item providers you could specialize the children that are created, e.g., as in org.eclipse.emf.ecore.provider.EGenericTypeItemProvider.collectNewChildDescriptors(Collection<Object>, Object).
Previous Topic:genmodel ->.editor-> run as
Next Topic:Test if EMF object is loading?
Goto Forum:
  


Current Time: Tue Jan 16 07:41:51 GMT 2018

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

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