Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Default value of String(Xtext grammar default values)
Default value of String [message #1176412] Fri, 08 November 2013 10:13 Go to next message
Gunnar Boström is currently offline Gunnar BoströmFriend
Messages: 26
Registered: February 2013
Junior Member
Hi,
Is it possible in the xtext grammar to define the default value of a String?
I don't want it to be null.

Actually I would like to add "structural" nodes to the outline.
One of the nodes is defines as
Accounts:
{Accounts}
name=STRING?
accounts+=Account*;

To set the name now I've overridden the _createChildren method in the OutlineTreeProvider as

if (childElement instanceof Accounts) {
val accs = childElement as Accounts
accs.name = "Accounts";
}

It would be much better and cleaner if I could provide the default value in the grammar.

/Gunnar
Re: Default value of String [message #1176424 is a reply to message #1176412] Fri, 08 November 2013 10:24 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
AFAIK, if you use an enumeration, the default is always the first option.
Perhaps you can use this in your grammar.
Re: Default value of String [message #1176431 is a reply to message #1176424] Fri, 08 November 2013 10:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

cant you simply adopt the IQualifiedNameProvider??


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default value of String [message #1176525 is a reply to message #1176424] Fri, 08 November 2013 11:40 Go to previous messageGo to next message
Gunnar Boström is currently offline Gunnar BoströmFriend
Messages: 26
Registered: February 2013
Junior Member
Uli Merkel wrote on Fri, 08 November 2013 05:24
AFAIK, if you use an enumeration, the default is always the first option.
Perhaps you can use this in your grammar.


I tried that but the outline view but the name must be a string for the outline to work.

/Gunnar
Re: Default value of String [message #1176532 is a reply to message #1176431] Fri, 08 November 2013 11:45 Go to previous messageGo to next message
Gunnar Boström is currently offline Gunnar BoströmFriend
Messages: 26
Registered: February 2013
Junior Member
Christian Dietrich wrote on Fri, 08 November 2013 05:27
Hi,

cant you simply adopt the IQualifiedNameProvider??


Hi,
How can I use that?
Would it be simpler than the way I handle it now in the outline provider?
/Gunnar
Re: Default value of String [message #1176544 is a reply to message #1176532] Fri, 08 November 2013 11:54 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
sorry it is actually not used have a look at
org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider.doGetText(Object)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default value of String [message #1176545 is a reply to message #1176532] Fri, 08 November 2013 11:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi isn't that used by default? Please debug
DefaultDeclarativeNameProvider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default value of String [message #1176573 is a reply to message #1176545] Fri, 08 November 2013 12:16 Go to previous messageGo to next message
Gunnar Boström is currently offline Gunnar BoströmFriend
Messages: 26
Registered: February 2013
Junior Member
Hi,
Sorry but I'm to new with xtext to understand what I should do!
/Gunnar
Re: Default value of String [message #1176581 is a reply to message #1176573] Fri, 08 November 2013 12:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Have a look at org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider.doGetText(Object) ,
debug it, customize it (you should already have a sublass pregrenerated


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Default value of String [message #1176631 is a reply to message #1176581] Fri, 08 November 2013 13:03 Go to previous message
Gunnar Boström is currently offline Gunnar BoströmFriend
Messages: 26
Registered: February 2013
Junior Member
Hi,
I've got it. Much easier than to change the outline.
Thanks!
/Gunnar
Previous Topic:Customizable formatting
Next Topic:What is generated by fornax-oaw-m2-plugin?
Goto Forum:
  


Current Time: Fri Apr 19 02:51:14 GMT 2024

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

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

Back to the top