[Templates] Couldn't find operation 'eContainer()' [message #218631] |
Fri, 13 February 2009 07:51 |
|
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 21: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 #219029 is a reply to message #218930] |
Mon, 16 February 2009 19:49 |
Eclipse User |
|
|
|
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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03315 seconds