Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » LinkCommands template
LinkCommands template [message #230677] Mon, 18 May 2009 12:58 Go to next message
Michael is currently offline MichaelFriend
Messages: 23
Registered: July 2009
Junior Member
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 #230698 is a reply to message #230677] Mon, 18 May 2009 17:23 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Michael,

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
Re: LinkCommands template [message #230719 is a reply to message #230698] Mon, 18 May 2009 19:58 Go to previous messageGo to next message
Michael is currently offline MichaelFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Alex,

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

boolean isTypeLink(gmfgen::GenLink link) :
{link.modelFacet}.typeSelect(gmfgen::TypeLinkModelFacet).siz e() > 0
;

boolean isRefLink(gmfgen::GenLink link) :
{link.modelFacet}.typeSelect(gmfgen::FeatureLinkModelFacet). size() > 0
;

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
Re: LinkCommands template [message #230742 is a reply to message #230719] Tue, 19 May 2009 10:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Michael,

> 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
Re: LinkCommands template [message #230788 is a reply to message #230742] Tue, 19 May 2009 15:53 Go to previous messageGo to next message
Michael is currently offline MichaelFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Alex,

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
Re: LinkCommands template [message #230812 is a reply to message #230788] Tue, 19 May 2009 17:26 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
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
Previous Topic:Arrange all customization
Next Topic:Problem with creating dynamic palette
Goto Forum:
  


Current Time: Thu Apr 25 04:37:33 GMT 2024

Powered by FUDForum. Page generated in 0.03614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top