Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Creating child objects of a type from another model?
Creating child objects of a type from another model? [message #662125] Tue, 29 March 2011 12:59 Go to next message
Dan Pollitt is currently offline Dan PollittFriend
Messages: 55
Registered: August 2010
Member
Hi all,

I have a modelled type "MessageAction" and I'd like to reuse EObject &
EPackage from Ecore as the eReferenceTypes of two EReferences of Message
- to represent the "payload" and "schema" respectively, e.g:

....
<eClassifiers xsi:type="ecore:EClass" name="MessageAction"
abstract="true" interface="true"
eSuperTypes="#//test/Action">
<eStructuralFeatures xsi:type="ecore:EReference" name="schema"
upperBound="-1"
eType="ecore:EClass
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Package "
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="message"
eType="ecore:EClass
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Object "
containment="true"/>
</eClassifiers>
....

I can't seem to persuade the generated .edit code to offer up EPackages
or EObjects as candidate children or properties of instances of
subclasses of the MessageAction type.

My question is: what should my approach be if I wanted to customise the
generated edit/editor to allow a user to create an EPackage instance as
a child of a MessageAction, or am I barking up the wrong tree to reuse
EPackage and EObject in this way? I had hoped to reuse the ecore.edit
item providers.

Thanks,
Dan
Re: Creating child objects of a type from another model? [message #662178 is a reply to message #662125] Tue, 29 March 2011 15:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30550
Registered: July 2009
Senior Member
Dan,

Do the corresponding GenFeatures for the schema and message features
indicate that children should be supported? I.e., did you maybe change
these to containment after you'd already created the GenModel?


Dan Pollitt wrote:
> Hi all,
>
> I have a modelled type "MessageAction" and I'd like to reuse EObject &
> EPackage from Ecore as the eReferenceTypes of two EReferences of
> Message - to represent the "payload" and "schema" respectively, e.g:
>
> ...
> <eClassifiers xsi:type="ecore:EClass" name="MessageAction"
> abstract="true" interface="true"
> eSuperTypes="#//test/Action">
> <eStructuralFeatures xsi:type="ecore:EReference" name="schema"
> upperBound="-1"
> eType="ecore:EClass
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Package "
> containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="message"
> eType="ecore:EClass
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Object "
> containment="true"/>
> </eClassifiers>
> ...
>
> I can't seem to persuade the generated .edit code to offer up
> EPackages or EObjects as candidate children or properties of instances
> of subclasses of the MessageAction type.
>
> My question is: what should my approach be if I wanted to customise
> the generated edit/editor to allow a user to create an EPackage
> instance as a child of a MessageAction, or am I barking up the wrong
> tree to reuse EPackage and EObject in this way? I had hoped to reuse
> the ecore.edit item providers.
>
> Thanks,
> Dan
Re: Creating child objects of a type from another model? [message #662181 is a reply to message #662178] Tue, 29 March 2011 15:47 Go to previous messageGo to next message
Dan Pollitt is currently offline Dan PollittFriend
Messages: 55
Registered: August 2010
Member
Hi Ed,

I did make the changes to the ecore model after I had already created
the GenModel (i.e. before regenerating over teh top of my existing
generated code), but I went into the GenModel in the editor afterwards
and checked that the "Edit/Children" and "Edit/Create Child" properties
of the features were set to "true".

By your question - I assume this should just "work" assuming I've set
the flags correctly?

Thanks,
Dan

On 29/03/2011 16:28, Ed Merks wrote:
> Dan,
>
> Do the corresponding GenFeatures for the schema and message features
> indicate that children should be supported? I.e., did you maybe change
> these to containment after you'd already created the GenModel?
>
>
> Dan Pollitt wrote:
>> Hi all,
>>
>> I have a modelled type "MessageAction" and I'd like to reuse EObject &
>> EPackage from Ecore as the eReferenceTypes of two EReferences of
>> Message - to represent the "payload" and "schema" respectively, e.g:
>>
>> ...
>> <eClassifiers xsi:type="ecore:EClass" name="MessageAction"
>> abstract="true" interface="true"
>> eSuperTypes="#//test/Action">
>> <eStructuralFeatures xsi:type="ecore:EReference" name="schema"
>> upperBound="-1"
>> eType="ecore:EClass
>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Package "
>> containment="true"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="message"
>> eType="ecore:EClass
>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Object "
>> containment="true"/>
>> </eClassifiers>
>> ...
>>
>> I can't seem to persuade the generated .edit code to offer up
>> EPackages or EObjects as candidate children or properties of instances
>> of subclasses of the MessageAction type.
>>
>> My question is: what should my approach be if I wanted to customise
>> the generated edit/editor to allow a user to create an EPackage
>> instance as a child of a MessageAction, or am I barking up the wrong
>> tree to reuse EPackage and EObject in this way? I had hoped to reuse
>> the ecore.edit item providers.
>>
>> Thanks,
>> Dan
Re: Creating child objects of a type from another model? [message #662192 is a reply to message #662181] Tue, 29 March 2011 16:02 Go to previous message
Dan Pollitt is currently offline Dan PollittFriend
Messages: 55
Registered: August 2010
Member
ok apologies - somehow I'd managed to mess up the supertype hierarchy so
the type (MessageAction) with these references was missed out!

Looking much better now (in the generated code at least)

Many thanks for the help,
Dan

On 29/03/2011 16:47, Dan Pollitt wrote:
> Hi Ed,
>
> I did make the changes to the ecore model after I had already created
> the GenModel (i.e. before regenerating over teh top of my existing
> generated code), but I went into the GenModel in the editor afterwards
> and checked that the "Edit/Children" and "Edit/Create Child" properties
> of the features were set to "true".
>
> By your question - I assume this should just "work" assuming I've set
> the flags correctly?
>
> Thanks,
> Dan
>
> On 29/03/2011 16:28, Ed Merks wrote:
>> Dan,
>>
>> Do the corresponding GenFeatures for the schema and message features
>> indicate that children should be supported? I.e., did you maybe change
>> these to containment after you'd already created the GenModel?
>>
>>
>> Dan Pollitt wrote:
>>> Hi all,
>>>
>>> I have a modelled type "MessageAction" and I'd like to reuse EObject &
>>> EPackage from Ecore as the eReferenceTypes of two EReferences of
>>> Message - to represent the "payload" and "schema" respectively, e.g:
>>>
>>> ...
>>> <eClassifiers xsi:type="ecore:EClass" name="MessageAction"
>>> abstract="true" interface="true"
>>> eSuperTypes="#//test/Action">
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="schema"
>>> upperBound="-1"
>>> eType="ecore:EClass
>>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Package "
>>> containment="true"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="message"
>>> eType="ecore:EClass
>>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Object "
>>> containment="true"/>
>>> </eClassifiers>
>>> ...
>>>
>>> I can't seem to persuade the generated .edit code to offer up
>>> EPackages or EObjects as candidate children or properties of instances
>>> of subclasses of the MessageAction type.
>>>
>>> My question is: what should my approach be if I wanted to customise
>>> the generated edit/editor to allow a user to create an EPackage
>>> instance as a child of a MessageAction, or am I barking up the wrong
>>> tree to reuse EPackage and EObject in this way? I had hoped to reuse
>>> the ecore.edit item providers.
>>>
>>> Thanks,
>>> Dan
>
Previous Topic:EMF load resource with different namespaces (prefixes)
Next Topic:Copying non-containment references
Goto Forum:
  


Current Time: Thu Oct 17 02:32:01 GMT 2019

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

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

Back to the top