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: 30820
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
>
>
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: 30820
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
>>>
>>>
Previous Topic:getting additional resources via customized reflective editor
Next Topic:[CDO] CDOResource.isLoaded()
Goto Forum:
  


Current Time: Mon Jan 27 12:43:39 GMT 2020

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

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

Back to the top