Non-empty model in the beginning [message #1412624] |
Tue, 26 August 2014 12:30  |
Eclipse User |
|
|
|
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 06:59   |
Eclipse User |
|
|
|
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 11:49  |
Eclipse User |
|
|
|
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 11:50] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04835 seconds