LinkCommands template [message #230677] |
Mon, 18 May 2009 08:58  |
Eclipse User |
|
|
|
Hi,
I try to modify the linkCommands.xpt file under
templates/xpt/diagram/editPolicies
In the method «DEFINE startLinkCommands(gmfgen::TypeModelFacet
typeModelFacet) FOR gmfgen::GenLink-» I want to check if the link has its
own lnk class with "source" and "target" or is just a reference.
My approach is «IF typeModelFacet instanceof gmfgen::TypeLinkModelFacet)-»
respectively «IF typeModelFacet instanceof gmfgen::FeatureLinkModelFacet)-»
But the code generation fails.
Thanks,
Michael
|
|
|
|
|
|
|
Re: LinkCommands template [message #230812 is a reply to message #230788] |
Tue, 19 May 2009 13:26  |
Eclipse User |
|
|
|
Hello Michael,
> I want to check in the startLinkCommands method (parameter is a
> gmfgen::TypeModelFacet) if the link is a type based link or reference.
> Dependent on the type of the link, I call the following method with
> different parameters: "getGEFWrapper(new
> «getCreateCommandQualifiedClassName()»(req,..."
I'll try to explain how to modify currently existing templates to make it
working. Instead of:
«DEFINE startLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType())
{
«IF createStartLinkCommand(self, linkEnd)-»
return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
«IF createStartIncomingLinkCommand(self, linkEnd)-»
req.getTarget(), req.getSource()
«ELSE-»
req.getSource(), req.getTarget()
«ENDIF-»
));
«ELSE-»
return null;
«ENDIF-»
}
«ENDDEFINE»
you have to write something like:
«DEFINE startLinkCommands(linkEnd : gmfgen::GenLinkEnd) FOR gmfgen::GenLink-»
if («EXPAND xpt::providers::ElementTypes::accessElementType» == req.getElementType())
{
«IF createStartLinkCommand(self, linkEnd)-»
return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
«IF createStartIncomingLinkCommand(self, linkEnd)-»
req.getTarget(), req.getSource()
«ELSE-»
req.getSource(), req.getTarget()
«ENDIF-»
/* processing additional parameters*/
«EXPAND additionalConstructorParameter FOR modelFacet»));
«ELSE-»
return null;
«ENDIF-»
}
«ENDDEFINE»
«DEFINE additionalConstructorParameter FOR gmfgen::LinkModelFacet»«ENDDEFINE»
«DEFINE additionalConstructorParameter FOR gmfgen::TypeLinkModelFacet», <generate
desired parameter here>«ENDDEFINE»
> And only in the case of a type based link, this command is returned.
You can see from the declaration that "startLinkCommands" define was defined
for gmfgen::GenLink type, so you can check is it a type link or reference
link by checking a type of self.modelFacet reference (is it just LinkModelFacet
or TypeLinkModelFacet) : «DEFINE startLinkCommands(linkEnd : gmfgen::GenLinkEnd)
FOR gmfgen::GenLink-»
> I checked the newest templates and here the startLinkCommands method
> has a parameter of type gmfgen::GenLinkEnd. This way I could check if
Right. GenLinkEnd represents source/target of the link. The link itself is
represented by GenLink.
-----------------
Alex Shatalin
|
|
|
Powered by
FUDForum. Page generated in 0.05043 seconds