Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] setting the value of a global variable from xtend?
[Xpand] setting the value of a global variable from xtend? [message #646706] Thu, 30 December 2010 09:54 Go to next message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1368
Registered: July 2009
Senior Member
Hi

in my Xpand template I'd like to set the value of a variable to be
available during the generation of a model element, and I don't want to
pass that value to all the definitions...

I saw that Xpand provides GLOBALVAR

I'd like to set that var when I start to generate a model element, but I
can't see how to do that...

any help please?
thanks in advance
Lorenzo

P.S. sorry, I'v just started using Xpand...

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Re: [Xpand] setting the value of a global variable from xtend? [message #646709 is a reply to message #646706] Thu, 30 December 2010 10:19 Go to previous message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1368
Registered: July 2009
Senior Member
On 12/30/2010 10:54 AM, Lorenzo Bettini wrote:
> Hi
>
> in my Xpand template I'd like to set the value of a variable to be
> available during the generation of a model element, and I don't want to
> pass that value to all the definitions...
>
> I saw that Xpand provides GLOBALVAR
>
> I'd like to set that var when I start to generate a model element, but I
> can't see how to do that...
>
> any help please?
> thanks in advance
> Lorenzo
>
> P.S. sorry, I'v just started using Xpand...
>

OK, I think I found the solution by googling much more, and I try to
answer myself :)

extension org::eclipse::xtend::util::stdlib::globalvar;

String getCurrentModelPackage() :
let currentModelPackage = (String) getGlobalVar("currentModelPackage") :
if(currentModelPackage == null) then (
storeGlobalVar("currentModelPackage", "")
) -> currentModelPackage
;

String setCurrentModelPackage(String s) :
storeGlobalVar("currentModelPackage", s)
;

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Previous Topic:[Acceleo 3] derived metamodel - type not recognized - eProxyURI
Next Topic:[Acceleo 3] getting All classes from Papyrus Model
Goto Forum:
  


Current Time: Thu Oct 23 10:17:55 GMT 2014

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

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