Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » templates as a menu(using templates created on xText)
templates as a menu [message #1691704] Thu, 09 April 2015 08:13 Go to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 13:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

can you please elaborate a bit more: why "they become strings" - what are you doing?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: templates as a menu [message #1691761 is a reply to message #1691704] Thu, 09 April 2015 14:00 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Does the view "Navigate/Open Model Element" show roughly what you need in you menu?

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: templates as a menu [message #1691878 is a reply to message #1691751] Fri, 10 April 2015 09:28 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 09:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

whall the text be only displayed to select the template or shall it be inserted as well?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: templates as a menu [message #1691892 is a reply to message #1691761] Fri, 10 April 2015 10:40 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 10:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 10 April 2015 10:43]

Report message to a moderator

Re: templates as a menu [message #1691907 is a reply to message #1691882] Fri, 10 April 2015 12:18 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 12:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: templates as a menu [message #1691991 is a reply to message #1691909] Sat, 11 April 2015 15:53 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 18:17]

Report message to a moderator

Re: templates as a menu [message #1692000 is a reply to message #1691991] Sat, 11 April 2015 18:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: templates as a menu [message #1692026 is a reply to message #1692000] Sun, 12 April 2015 11:49 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
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 19:03 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 19:06 Go to previous messageGo to next message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 05:30 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
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 09:16 Go to previous message
naseclipse naseclipse is currently offline naseclipse naseclipseFriend
Messages: 14
Registered: April 2015
Junior Member
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 09:17]

Report message to a moderator

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


Current Time: Thu Mar 28 22:08:25 GMT 2024

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

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

Back to the top