Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » [Templates] Couldn't find operation 'eContainer()'
[Templates] Couldn't find operation 'eContainer()' [message #218631] Fri, 13 February 2009 07:51 Go to next message
Marc Mising name is currently offline Marc Mising nameFriend
Messages: 193
Registered: July 2009
Location: Valencia, Spain
Senior Member
Hi, I'm modifying some gmfgen XPand templates to adjust some rules to
generate my diagram using these templates, and I want to access to the
container of the EObject, so I think I should use the eContainer()
operation that an EObject has. But when regenerating the code, an error
told me that this operation doesn't exist. I import the ecore metamodel.
The code is the following (In the
impl::diagram::editParts::NodeEditPart.xpt):

«IMPORT "http://www.eclipse.org/gmf/2008/GenModel
«IMPORT "http://www.eclipse.org/emf/2002/Ecore

«AROUND createNodeShape(gmfgen::GenNode node) FOR
gmfgen::InnerClassViewmap-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.draw2d.IFigure createNodeShape() {
«EXPAND newFigureForStereotypes FOR this.eContainer()»
return primaryShape = figure;
}
«ENDAROUND»

«DEFINE newFigureForStereotypes FOR gmfgen::GenNode-»
...
«className» figure = new «className»Aux();
...
«ENDDEFINE»



Exception (Couldn't find operation 'eContainer()' for
InnerClassViewmap.:in aspects::impl::diagram::editparts::NodeEditPart on
line 213 'this.eContainer()') while generating code
Couldn't find operation 'eContainer()' for InnerClassViewmap.:in
aspects::impl::diagram::editparts::NodeEditPart on line 213
'this.eContainer()'



Anybody can help me please???
Thanks!!!
Re: [Templates] Couldn't find operation 'eContainer()' [message #218672 is a reply to message #218631] Fri, 13 February 2009 11:44 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Marc,

> line 213 'this.eContainer()') while generating code
> Couldn't find operation 'eContainer()' for InnerClassViewmap.:in
> aspects::impl::diagram::editparts::NodeEditPart on line 213
> 'this.eContainer()'
This is wirght - InnerClassViewmap is not a subclass of EObject in gmfgen.ecore
so due to the metainformation InnerClassViewmap has no .eContainer() methods...
Try to avoid usage of .eContainer() (and any other EObject-related methods)
in your templates or write java code + call it from the xpand.

-----------------
Alex Shatalin
Re: [Templates] Couldn't find operation 'eContainer()' [message #218727 is a reply to message #218672] Fri, 13 February 2009 13:26 Go to previous messageGo to next message
Marc Mising name is currently offline Marc Mising nameFriend
Messages: 193
Registered: July 2009
Location: Valencia, Spain
Senior Member
Alex Shatalin wrote:

> This is wirght - InnerClassViewmap is not a subclass of EObject in
gmfgen.ecore
> so due to the metainformation InnerClassViewmap has no .eContainer()
methods...

I think it's not try Alex. According to the GMF documentation,
InnerClassViewmap extends from Viewmap and Viewmap extends from EObject,
and EObject has an eContainer() method. I don't underestand why doesn't
work. Could you explain me more, please? Thanks a lot!

InnerClassViewmap:
( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/tooling/org/eclipse/gmf/codegen/gmfgen /InnerClassViewmap.html)

Viewmap:
( http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. gmf.doc/reference/api/tooling/org/eclipse/gmf/codegen/gmfgen /Viewmap.html)

EObject:
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. emf.doc/references/javadoc/org/eclipse/emf/ecore/EObject.htm l
Re: [Templates] Couldn't find operation 'eContainer()' [message #218760 is a reply to message #218727] Fri, 13 February 2009 14:37 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Marc,

> I think it's not try Alex. According to the GMF documentation,
> InnerClassViewmap extends from Viewmap and Viewmap extends from
> EObject, and EObject has an eContainer() method. I don't underestand
That's right - this class is an instance of EObject (in java world) but in
EMF world it is not.
EClass "Viewmap" defined in gmfgen.ecore has no ESuperTypes specified, so
in EMF meta-information Viewmap is a class on top of hierarchy and is not
sublcassing EObject.. Xpand is using EMF meta-information to locate appropriate
attributes/methods, so this is a reason why corresponding operation was not
found (i know that it actually present in an underlying java object..)

-----------------
Alex Shatalin
Re: [Templates] Couldn't find operation 'eContainer()' [message #218864 is a reply to message #218760] Fri, 13 February 2009 21:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Alex,

IIUC, GMF now uses XPand-OCL, right? It might be worth considering
using MDT OCL's "implicit root class" option to provide access to the
EObject operations ...

cW

Alex Shatalin wrote:
> Hello Marc,
>
>> I think it's not try Alex. According to the GMF documentation,
>> InnerClassViewmap extends from Viewmap and Viewmap extends from
>> EObject, and EObject has an eContainer() method. I don't underestand
> That's right - this class is an instance of EObject (in java world) but
> in EMF world it is not.
> EClass "Viewmap" defined in gmfgen.ecore has no ESuperTypes specified,
> so in EMF meta-information Viewmap is a class on top of hierarchy and is
> not sublcassing EObject.. Xpand is using EMF meta-information to locate
> appropriate attributes/methods, so this is a reason why corresponding
> operation was not found (i know that it actually present in an
> underlying java object..)
>
> -----------------
> Alex Shatalin
>
>
Re: [Templates] Couldn't find operation 'eContainer()' [message #218930 is a reply to message #218864] Mon, 16 February 2009 11:16 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Christian,

> IIUC, GMF now uses XPand-OCL, right? It might be worth considering
Right.

> using MDT OCL's "implicit root class" option to provide access to the
> EObject operations ...
Yes, we should consider this possibility, but i kannot answer right now is
it better to switch this option on or off. Probably we have to introduce
it into the GMF genmodel.

-----------------
Alex Shatalin
Re: [Templates] Couldn't find operation 'eContainer()' [message #219029 is a reply to message #218930] Mon, 16 February 2009 19:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Alex,

Alex Shatalin wrote:
> Hello Christian,
>
>> IIUC, GMF now uses XPand-OCL, right? It might be worth considering
> Right.
>
>> using MDT OCL's "implicit root class" option to provide access to the
>> EObject operations ...
> Yes, we should consider this possibility, but i kannot answer right now
> is it better to switch this option on or off. Probably we have to
> introduce it into the GMF genmodel.

Yes, that's a good point. Doubtless there are some that benefit from
the current state of things. :-)

cW


> -----------------
> Alex Shatalin
>
>
Re: [Templates] Couldn't find operation 'eContainer()' [message #219089 is a reply to message #219029] Tue, 17 February 2009 14:06 Go to previous messageGo to next message
Marc Mising name is currently offline Marc Mising nameFriend
Messages: 193
Registered: July 2009
Location: Valencia, Spain
Senior Member
It seems to be a good idea. But now, the only way to get the eContainer is
using Xtend, a method that returns me the eContainer, it's true? Something
like that:

*****************
import "http://www.eclipse.org/emf/2002/Ecore";
EObject getEContainer(EObject eobj) :
eobj.eContainer()
;
*****************

In the XPand rule I should call this method:

*****************
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.draw2d.IFigure createNodeShape() {
«EXPAND newFigureForStereotypes FOR getEContainer(this)»
return primaryShape = figure;
}
«ENDAROUND»

«DEFINE newFigureForStereotypes FOR gmfgen::GenNode-»
...
«ENDDEFINE»
*****************

Thanks!!!
Marc
Re: [Templates] Couldn't find operation 'eContainer()' [message #219136 is a reply to message #219089] Wed, 18 February 2009 10:08 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Marc,

Current version of impl::diagram::editparts::NodeEditPart contains following
definition(s):
«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::Viewmap-»

so if you are modifying this particular define then you can use node variable
to get ViewMap container from there:

«EXPAND newFigureForStereotypes FOR node»

-----------------
Alex Shatalin
Previous Topic:Can 2.2.0M5a be installed with eclipse 3.5M5?
Next Topic:2.0.2 to 2.2.0m5 migration, I lost the connection end decoration
Goto Forum:
  


Current Time: Fri Apr 19 22:34:13 GMT 2024

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

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

Back to the top