[Templates] Couldn't find operation 'eContainer()' [message #218631] |
Fri, 13 February 2009 02:51  |
Eclipse User |
|
|
|
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 #218864 is a reply to message #218760] |
Fri, 13 February 2009 16:50   |
Eclipse User |
|
|
|
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 #219136 is a reply to message #219089] |
Wed, 18 February 2009 05:08  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.28871 seconds