Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF and Maps
EMF and Maps [message #423062] Mon, 22 September 2008 14:52 Go to next message
Eclipse UserFriend
Originally posted by: luzi.anderegg.ergon.ch

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 #423069 is a reply to message #423062] Mon, 22 September 2008 15:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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/
Re: EMF and Maps [message #423128 is a reply to message #423069] Tue, 23 September 2008 15:23 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:getting additional resources via customized reflective editor
Next Topic:[CDO] CDOResource.isLoaded()
Goto Forum:
  


Current Time: Wed Apr 24 22:59:28 GMT 2024

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

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

Back to the top