Skip to main content



      Home
Home » Modeling » TMF (Xtext) » templates as a menu(using templates created on xText)
templates as a menu [message #1691704] Thu, 09 April 2015 04:13 Go to next message
Eclipse UserFriend
Hello,

I have templates that are created using a template programming language developed on xText. I want the templates to appear as a menu. I dont want to treat the templates as strings, rather should maintain their structure.
I thought of enumerating the templates, but then they become strings...

Can someone suggest me a technique, and idea?

Tnx a lot.
Re: templates as a menu [message #1691751 is a reply to message #1691704] Thu, 09 April 2015 09:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

can you please elaborate a bit more: why "they become strings" - what are you doing?
Re: templates as a menu [message #1691761 is a reply to message #1691704] Thu, 09 April 2015 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Does the view "Navigate/Open Model Element" show roughly what you need in you menu?
Re: templates as a menu [message #1691878 is a reply to message #1691751] Fri, 10 April 2015 05:28 Go to previous messageGo to next message
Eclipse UserFriend
Tnx for replying Razz My ultimate goal is to build an ontology for writing/to construct a restricted sentence. So I started with a simple template language that allows me to create templates as shown below.

Template:
template1 <someone> likes <a pet>
template2 <a pet> likes <something>


I have hundreds of these templates. I want to have a menu that holds these templates. These allows me to select a template, and fill the placeholders in order to complete the sentence.

in my grammar i have:
UseTemplate:
template=[Template];


However, the scoping only shows me template1, and template2 (the intantiations). I want the template itself to be displayed just like a menu.

I am just beginning to learn xText. I hope this clarifies better. Tnx

Regards,
Nas
Re: templates as a menu [message #1691882 is a reply to message #1691878] Fri, 10 April 2015 05:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

whall the text be only displayed to select the template or shall it be inserted as well?
Re: templates as a menu [message #1691892 is a reply to message #1691761] Fri, 10 April 2015 06:40 Go to previous messageGo to next message
Eclipse UserFriend
Hello Karsten,

could you please send me a reference to "Navigate/Open Model Element"?
I couldnt find a good reference on the internet for it.

Regards,
Nas
Re: templates as a menu [message #1691894 is a reply to message #1691892] Fri, 10 April 2015 06:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

simply type "Open Model Element" in the Quick Access Field in the Top Right of Eclipse or Type Sgift+Cmd+F3 (dont know what it is on windows - Probalbly Crtl + Shift+ F3)

[Updated on: Fri, 10 April 2015 06:43] by Moderator

Re: templates as a menu [message #1691907 is a reply to message #1691882] Fri, 10 April 2015 08:18 Go to previous messageGo to next message
Eclipse UserFriend
That is correct: a template should be selected, and inserted. When this happens,

first preference: reserve the structural integrity of the template
second preference: treat the template as a string, if first choice is too complicated.

Do you think manipulating the content assist of the default xText editor could help?

Regards,
Nas
Re: templates as a menu [message #1691909 is a reply to message #1691907] Fri, 10 April 2015 08:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi i am still not sure if i get your usecase. Did you have a look at the eclipse template mechanism as xtext supports it by default? You could fill that programarically as well.

To understand better what you want to do. Can you share asample template grammar and usage grammar and sample template model file and sample model dile before and after inserting the template
Re: templates as a menu [message #1691991 is a reply to message #1691909] Sat, 11 April 2015 11:53 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

the grammar

Type:
Livingthing
;

Livingthing:
'datatype' name=ID
;

Template:
"Template" name=ID
('<name=ID':'type=[Type]'>' 'likes' <name=ID':'type=[Type]'>)
;

UseTemplate:
template=[Template] // Here, "template" is a reference of type"Template". Rather, I want to have it as a menu of templates.
;
...

In the editor, I create

/* Declare types */
datatype People
datatype animal

/* crerate the template */
Template template1 <name:People> likes <name:animal>
Template template2 <name:animal> likes <name:people>

/* use the template */
I prefer to have a menu that holds the templates. Then select, and fill the placeholders (<xx:type>).

Thank you for your support Smile

Regards,
Nas

[Updated on: Sat, 11 April 2015 14:17] by Moderator

Re: templates as a menu [message #1692000 is a reply to message #1691991] Sat, 11 April 2015 14:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

this makes only sense if the structure of the template is very similar to the one of the usage.
you can programatically add templates by adapting DefaultTemplateProposalProvider.

You can add own variables by adapting XtextTemplateContextType
Re: templates as a menu [message #1692026 is a reply to message #1692000] Sun, 12 April 2015 07:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nas,

I created Luecken(x)text which uses textblocks with a syntax similar to the Templates in Eclipse.
It is published as 3 (german) articles in "Eclipse Magazin"
and they bundled it as a "shortcut" https://entwickler.de/press/dsl-mit-xtextxtend-126643.html

Perhaps this may give you some ideas.

Greetings from Frankfurt/Germany,
Uli

Re: templates as a menu [message #1692044 is a reply to message #1692026] Sun, 12 April 2015 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Uli!! It seems very close to what I need Rolling Eyes
I will try to deal about the language challenge with googletranslate.

Regards,
Nas
Re: templates as a menu [message #1692045 is a reply to message #1692000] Sun, 12 April 2015 15:06 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Christian!
I will look into it. I will be back with some result. Tnx for the help.

Regards,
Nas
Re: templates as a menu [message #1692056 is a reply to message #1692045] Mon, 13 April 2015 01:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi Nas,

the (mostly english) sourcecode can be downloaded from
http://uli-merkel.de/uli-xtext/downloads/!lueckenxtext_luna-part3-all-in-one.zip
The additional files for the experiments are in
http://uli-merkel.de/uli-xtext/downloads/!lueckenxtext_luna-part3-initial-data.zip

HIH, Uli
Re: templates as a menu [message #1692655 is a reply to message #1692056] Fri, 17 April 2015 05:16 Go to previous message
Eclipse UserFriend
Due to time limitation, for know I am using xText default template proposal (from the preferences).
Of course, that wasn't my initial intention to do. But I will try to do what you guys have suggested me.
I am sure I will come with some results sometime later.

Thank you.
Cheers,
Nas

[Updated on: Fri, 17 April 2015 05:17] by Moderator

Previous Topic:Extending the Xtext Generator
Next Topic:How to format lists with new Xtext formatter?
Goto Forum:
  


Current Time: Sat Jul 19 08:51:45 EDT 2025

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

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

Back to the top