Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Extending EMF EClass
Extending EMF EClass [message #218597] Thu, 12 February 2009 22:00 Go to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi,

In my model I am trying to extend existing EMF models, in particular the
EMF model itself. For an example, I am trying to define a domain object
which extends EClass.

I modified the AbstractDomainObject type to extend EClass:

eSuperTypes="... http://www.eclipse.org/emf/2002/Ecore#//EClass">

Loading into .genmodel worked fine, generating model and edit code
worked fine but I had to tell AbstractDomainObjectImpl to extend
EClassImpl rather than EObjectImpl.

Regenerating the .gmfgen threw two ignorable validation problems similar
to "Label attributes must be available in 'Domain Element' EClass of the
labeled mapping entry". In my editor I define a 'name' label which was
previously set to a different element class in my model (NamedElement).

If the errors were ignored, the code would generate fine, except the
name label would be replaced with the toString() of the object. Trying
to change the name and saving the model in the generated editor would
throw "java.util.MissingResourceException: The string resource
'_UI_ENamedElement_name_feature' could not be located".

Obviously it was still referring to the old element, so I reloaded the
gmfmap to point to EClass.name rather than NamedElement.name. But now
the .gmfgen will not be generated, at the last step it reports:

The object
'org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl@19cbbfb
(property: Editable, notify: true, children: false, createChild: false,
propertyCategory: null, propertyFilterFlags: [], propertyDescription:
null, propertyMultiLine: false, propertySortChoices: false)' is not
contained in a resource.

Following the discussion at
http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 8404.html, I
added GenModelEditPlugin.INSTANCE and EcoreEditPlugin.INSTANCE to the
constructor of the XXXEditPlugin, but the exception above is still thrown.

I tried adding the org.eclipse.emf.codegen.* plugins as dependencies of
the .gmfgen plugin to no effect.

Any other ideas? Is this an issue limited only to extending EMF, or will
I get similar errors when trying to extend my own EMF models in this way?

Thanks :)

Jevon
Re: Extending EMF EClass [message #218603 is a reply to message #218597] Thu, 12 February 2009 22:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Jevon,

Comments below.

Jevon Wright wrote:
> Hi,
>
> In my model I am trying to extend existing EMF models, in particular
> the EMF model itself. For an example, I am trying to define a domain
> object which extends EClass.
>
> I modified the AbstractDomainObject type to extend EClass:
>
> eSuperTypes="... http://www.eclipse.org/emf/2002/Ecore#//EClass">
Don't do that! If you must do that, make sure you're using the
development time version of Ecore. I.e., the one in
platform:/plugins/org.eclipse.emf.ecore/model/Ecore.ecore.
>
> Loading into .genmodel worked fine, generating model and edit code
> worked fine but I had to tell AbstractDomainObjectImpl to extend
> EClassImpl rather than EObjectImpl.
>
> Regenerating the .gmfgen threw two ignorable validation problems
> similar to "Label attributes must be available in 'Domain Element'
> EClass of the labeled mapping entry". In my editor I define a 'name'
> label which was previously set to a different element class in my
> model (NamedElement).
>
> If the errors were ignored, the code would generate fine, except the
> name label would be replaced with the toString() of the object. Trying
> to change the name and saving the model in the generated editor would
> throw "java.util.MissingResourceException: The string resource
> '_UI_ENamedElement_name_feature' could not be located".
>
> Obviously it was still referring to the old element, so I reloaded the
> gmfmap to point to EClass.name rather than NamedElement.name. But now
> the .gmfgen will not be generated, at the last step it reports:
>
> The object
> 'org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl@19cbbfb
> (property: Editable, notify: true, children: false, createChild:
> false, propertyCategory: null, propertyFilterFlags: [],
> propertyDescription: null, propertyMultiLine: false,
> propertySortChoices: false)' is not contained in a resource.
>
> Following the discussion at
> http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 8404.html,
> I added GenModelEditPlugin.INSTANCE and EcoreEditPlugin.INSTANCE to
> the constructor of the XXXEditPlugin, but the exception above is still
> thrown.
>
> I tried adding the org.eclipse.emf.codegen.* plugins as dependencies
> of the .gmfgen plugin to no effect.
>
> Any other ideas? Is this an issue limited only to extending EMF, or
> will I get similar errors when trying to extend my own EMF models in
> this way?
Ecore itself is special being bootstrapped and all, but the important
thing is to be sure you're using the development time version of the
model, not the generated runtime version.

How did you build your model? Haven't you seen the countless times I've
told people not to extend Ecore but rather to decorate it with
EAnnotations whose contents can contain any EObject...
>
> Thanks :)
>
> Jevon


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Iteratively go through model
Next Topic:add a figure in a gmf file programmatically
Goto Forum:
  


Current Time: Fri Apr 19 00:53:17 GMT 2024

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

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

Back to the top