Skip to main content



      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 12:30 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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

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


Current Time: Wed Jul 23 08:35:18 EDT 2025

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

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

Back to the top