Duplicate Content Instances in Eclipse Runtime Application [message #1723089] |
Thu, 11 February 2016 13:59 |
Matt Se 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 |
Ed Merks Messages: 33218 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
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: Duplicate Content Instances in Eclipse Runtime Application [message #1755582 is a reply to message #1755573] |
Mon, 06 March 2017 05:37 |
Ed Merks Messages: 33218 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).
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.05062 seconds