Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsLinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230677/#msg_230677
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]]>Michael2009-05-18T12:58:03-00:00Re: LinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230698/#msg_230698
If you are using latest (OCL-based xpand) then you can use somethinkg like:
typeModelFacet.oclIsKindOf(gmfgen::TypeLinkModelFacet)
> «DEFINE startLinkCommands(gmfgen::TypeModelFacet typeModelFacet) FOR gmfgen::GenLink-»
AFAIKSee here, typeModelFacet is always instance of gmfgen::TypeModelFacet.
Probably there should be another «DEFINE startLinkCommands(gmfgen::FeatureLinkModelFacet
featureModelFacet) FOR gmfgen::GenLink-» called in case parameter is instance
of FeatureLinkModelFacet.
-----------------
Alex Shatalin]]>Alexander Shatalin2009-05-18T17:23:50-00:00Re: LinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230719/#msg_230719
thanks for your answer. I think TypeModelFacet is a super clss of both.
But maybe I'm on the wrong way.
If I had the gmfgen::GenLink link I could call the folowing methods from
LinkUtils.xpt
But I don't know how to get the link in the startLinkCommands method.
There is this call: «EXPAND startLinkCommands(this) FOREACH
getAllPotentialLinks(diagram)-»
Is "this" (which is the typeModelFacet) the only parameter or can I
retrieve the link too?
Thanks,
Michael]]>Michael2009-05-18T19:58:25-00:00Re: LinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230742/#msg_230742
> thanks for your answer. I think TypeModelFacet is a super clss of
> both.
No. TypeModelFacet is a superclass of TypeLinkModelFacet and not FeatureLinkModelFacet.
> But I don't know how to get the link in the startLinkCommands method.
> There is this call: «EXPAND startLinkCommands(this) FOREACH
> getAllPotentialLinks(diagram)-»
Strange - i have slightly different templates.. Nevertheless, this expand
will generate "startlink" commands for each link which can be started from
this element. Links (Type- or Reference-based) can be started only from type-based
element (diagram node or another type-based link). This is a reason why "this"
is a TypeModelFacet. "this" can be represent either diagram node or type-based
link.
> Is "this" (which is the typeModelFacet) the only parameter or can I
> retrieve the link too?
Result of getAllPotentialLinks(diagram) call is a collection of GenLinks
(typee- or reference-based). So I suppose you have to call isTypeLink/isRefLink
for elements of this collection?..
I do not understand what you are going to do and looks like you are using
not the latest version of GMF templates.
In case you'll have future problems I suggest you updating to the latest
version of GMF templates first and if you describe me requirements i'll be
able to provide you with more detailed explanation.
-----------------
Alex Shatalin]]>Alexander Shatalin2009-05-19T10:57:44-00:00Re: LinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230788/#msg_230788
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,..."
The reason is because I have modified constructors in the
commands/CreateLinkCommand.xpt
And only in the case of a type based link, this command is returned.
I checked the newest templates and here the startLinkCommands method has a
parameter of type gmfgen::GenLinkEnd. This way I could check if it is a
ref or type based link. Unfortunately I cannot upgrade to the newest
version, as the code should run with Ganymede 3.4 (GMF 2.1)
Do you have any idea how I can retrieve the gmfgen::GenLink for which the
command is created?
Thanks]]>Michael2009-05-19T15:53:19-00:00Re: LinkCommands template
https://www.eclipse.org/forums/index.php/mv/msg/73798/230812/#msg_230812
> 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 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]]>Alexander Shatalin2009-05-19T17:26:35-00:00