Duplicate Content Instances in Eclipse Runtime Application [message #1723089] |
Thu, 11 February 2016 08:59  |
Eclipse User |
|
|
|
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 09:00] by Moderator
|
|
|
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1723091 is a reply to message #1723089] |
Thu, 11 February 2016 09:10   |
Eclipse User |
|
|
|
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 #1755582 is a reply to message #1755573] |
Mon, 06 March 2017 00:37  |
Eclipse User |
|
|
|
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).
|
|
|
Powered by
FUDForum. Page generated in 0.59369 seconds