Dynamic Template Variable Resolvers [message #1061101] |
Wed, 29 May 2013 18:08  |
Eclipse User |
|
|
|
Hello,
I've researched this as far as I know how and am stuck wondering if it is even possible. What I would like to do is propose a template that has two cross-referenced variables taking on the familiar form:
${var1:CrossReference('MyType1.ref1')} ${var2:CrossReference('MyType2.ref2')}
Where ref1 points to the container which declares objects that ref2 may point to.
My problem is that I cannot figure out if it is possible to create a variable resolver that resolves template variables on the fly, i.e. while the template is being edited. I want the available candidates to ref2 to be able to refresh after a candidate for ref1 has been chosen from the drop-down. Right now, ref2 contains all possible candidates for ref2, for all possible candidates for ref1 (in other words, everything). I want ref2 to only contain possible candidates for the currently selected candidate for ref1.
Does anyone know if template variable resolvers are capable of this dynamic behavior?
|
|
|
|
Re: Dynamic Template Variable Resolvers [message #1061216 is a reply to message #1061113] |
Thu, 30 May 2013 10:48  |
Eclipse User |
|
|
|
Thanks Alexander,
That's actually the blog post that I discovered prior to asking this question. I created my own template variable resolver, but
resolveValues(TemplateVariable variable, XtextTemplateContext xtextTemplateContext)
is only called once, when the template is created. I couldn't get it to resolve my variable again while I was editing the template. Also, I would have posted the link to that blog, but the last time I tried to post an outside link, the forum wouldn't let me due to my account privileges.
I like your solution for the time being, except it initially leaves my model file in an invalid state because it inserts a "dummy" variable that still needs to be resolved by code completion. I will continue to investigate and I'll post a cleaner solution if I am able to come up with one.
Thanks for the suggestion!
Brad
|
|
|
Powered by
FUDForum. Page generated in 0.03492 seconds