|
|
|
|
|
Re: LinkCommands template [message #230812 is a reply to message #230788] |
Tue, 19 May 2009 17:26 |
Alexander Shatalin Messages: 2928 Registered: July 2009 |
Senior Member |
|
|
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.03614 seconds