|
|
Re: EMF and Maps [message #423128 is a reply to message #423069] |
Tue, 23 September 2008 15:23 |
Eclipse User |
|
|
|
Originally posted by: luzi.anderegg.ergon.ch
Ed,
thanks for your answer! I still have problems with maps and emf
commands. do i have to use an addcommand or a setcommand? and what are
the feature, the owner, and the value? do you have a sample for that?
Luzi
Ed Merks wrote:
> Luzi,
>
> Just treat it like a list and use
> EcoreUtil.create(XyzPackage.Literals.<MapEntryClass>) to create the
> instance you want to add. Cast the result of the creation to
> BasicMap.Entry to set the key and value.
>
>
> Luzi Anderegg wrote:
>> Hi,
>>
>> I modelled a map in my ecore according to
>> http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF .3F. Is
>> there an example how to use such a map with an AddCommand from the
>> generated edit plug-in?
>>
>> Gnerally, I did not find much information about modelling maps in EMF.
>> Does somebody know some good pointers?
>>
>> Luzi
>>
>>
|
|
|
Re: EMF and Maps [message #423130 is a reply to message #423128] |
Tue, 23 September 2008 15:43 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Luzi,
The Ecore model's EAnnotation.details is an example so you can look at
how that works. If you simply treat an EMap as a plain old containment
EList, all the same concepts apply as for non-EMaps. Generally you'd use
add and remove commands to manipulate EMaps. The feature, owner, and
value are no different than any other non-EMap case. The only tricky
thing is that there's no strongly typed create method for the map entry
in the generated factory interface...
Luzi Anderegg wrote:
> Ed,
>
> thanks for your answer! I still have problems with maps and emf
> commands. do i have to use an addcommand or a setcommand? and what are
> the feature, the owner, and the value? do you have a sample for that?
>
> Luzi
>
> Ed Merks wrote:
>> Luzi,
>>
>> Just treat it like a list and use
>> EcoreUtil.create(XyzPackage.Literals.<MapEntryClass>) to create the
>> instance you want to add. Cast the result of the creation to
>> BasicMap.Entry to set the key and value.
>>
>>
>> Luzi Anderegg wrote:
>>> Hi,
>>>
>>> I modelled a map in my ecore according to
>>> http://wiki.eclipse.org/EMF/FAQ#How_do_I_create_a_Map_in_EMF .3F. Is
>>> there an example how to use such a map with an AddCommand from the
>>> generated edit plug-in?
>>>
>>> Gnerally, I did not find much information about modelling maps in
>>> EMF. Does somebody know some good pointers?
>>>
>>> Luzi
>>>
>>>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03163 seconds