Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Non-empty model in the beginning(Somehow it is like creating a symbol table with built-in types)
Non-empty model in the beginning [message #1412624] Tue, 26 August 2014 16:30 Go to next message
Inti Gonzalez-Herrera is currently offline Inti Gonzalez-HerreraFriend
Messages: 1
Registered: August 2014
Junior Member
Hi,

I'm creating a language with a few related concepts as Type, Property and Entity.
The idea is that entities contain properties and each property is from a type.

The problem at hand is that there are some predefined properties for each entity, and of course these properties have predefined types. It is by far more easy to handle all the properties in the same way in the validator and the generator but, to do so, I need to include such properties by default in the model.

Is there a way to customize the mechanism to create an "empty" model? I mean, I want to execute some Java/Xtend code when a model/file is created.

If possible, I would like to avoid solutions as: create an ecore model "graphically", then import it because the language is under development it is not comfortable to modify a graphic model over and over.

Thanks
Re: Non-empty model in the beginning [message #1412916 is a reply to message #1412624] Wed, 27 August 2014 10:59 Go to previous messageGo to next message
Axel Guckelsberger is currently offline Axel GuckelsbergerFriend
Messages: 341
Registered: July 2009
Senior Member
Hi,

maybe you can work with code templates, like described here:
https://www.eclipse.org/Xtext/documentation.html#templates

After you defined a template for your desired initial model content, you
only need to find a way how to insert this template programmatically.

HTH,
Axel


Inti Gonzalez-Herrera wrote:

> Hi,
>
> I'm creating a language with a few related concepts as Type, Property and
> Entity. The idea is that entities contain properties and each property is
> from a type.
>
> The problem at hand is that there are some predefined properties for each
> entity, and of course these properties have predefined types. It is by far
> more easy to handle all the properties in the same way in the validator
> and the generator but, to do so, I need to include such properties by
> default in the model.
>
> Is there a way to customize the mechanism to create an "empty" model? I
> mean, I want to execute some Java/Xtend code when a model/file is created.
>
> If possible, I would like to avoid solutions as: create an ecore model
> "graphically", then import it because the language is under development it
> is not comfortable to modify a graphic model over and over.
>
> Thanks
Re: Non-empty model in the beginning [message #1413029 is a reply to message #1412916] Wed, 27 August 2014 15:49 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 246
Registered: June 2013
Senior Member
Ok: the very best would be if the preamble text is added in the open process of the empty file.

But: what about putting all your initial specifications in the Proposal Provider.
So if you have an empty file and press CTRL+SPACE, you get this text.

Another option is the validator and a quickfix which enters your standard text.

[Updated on: Wed, 27 August 2014 15:50]

Report message to a moderator

Previous Topic:right place to add save actions?
Next Topic:code generation using xtend
Goto Forum:
  


Current Time: Thu Dec 12 17:06:36 GMT 2019

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

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

Back to the top