Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » EClass from Ecore model in xtext runtime editor
EClass from Ecore model in xtext runtime editor [message #676990] Tue, 07 June 2011 07:50 Go to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hi,

As far as I know, Xtext offers the possibility, to import ecore models to use in the DSL. At runtime I can now use EOBjects of the ecore model in the DSL.

In my case I would like to use the EClass(es) (not the EObject Instances of these) at runtime in my DSL.
For example:
In my ecore model I define a EClass Book and Author.
In my dsl (runtime) I would like to use Book and Author (with content assist), and NOT "Dan Brown" and "The Da Vinci Code"

Any hints to do this?

Regards,
Markus
Re: EClass from Ecore model in xtext runtime editor [message #677001 is a reply to message #676990] Tue, 07 June 2011 09:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

simply import "http://www.eclipse.org/emf/2002/Ecore" as ecore and reference to a ecore::EClass. at runtime the .ecore simply has to be on the path of the model project.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EClass from Ecore model in xtext runtime editor [message #677023 is a reply to message #677001] Tue, 07 June 2011 10:47 Go to previous messageGo to next message
Markus Schindler is currently offline Markus SchindlerFriend
Messages: 30
Registered: July 2009
Member
Hi Christian,

Thanks a lot for your reply!
One question further, can I do some kind of restrictions on which ecore model, EClass(es) etc.?

Best regards,
Markus (from Stuttgart to Stuttgart ;-)
Re: EClass from Ecore model in xtext runtime editor [message #677032 is a reply to message #677023] Tue, 07 June 2011 11:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

no by default it takes all Eclasses from the index. of Course you could write a local scoping method the just adds the Eclasses you want explicitely.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EClass from Ecore model in xtext runtime editor [message #677034 is a reply to message #677023] Tue, 07 June 2011 11:22 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

here the short answer:

The quick way is via adapting the scoping (see documentation and about every 5th thread in this forum), but we do not recommend that (the user gets "could not resolve reference"-Errors for elements that if fact exist).

We recommend adapting validation (checking whether the referenced object is allowed to be referenced) and content assist (e.g. by using a filter in the resolveCrossReference method).

Alex
Re: EClass from Ecore model in xtext runtime editor [message #677081 is a reply to message #677023] Tue, 07 June 2011 14:10 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 06/07/2011 12:47 PM, Markus Schindler wrote:
> Hi Christian,
>
> Thanks a lot for your reply!
> One question further, can I do some kind of restrictions on which ecore
> model, EClass(es) etc.?
>
> Best regards,
> Markus (from Stuttgart to Stuttgart ;-)
>
>

Hi Markus

I've used EClasses from an ecore imported explicitly in my DSL in this
project

http://xtypes.sourceforge.net/

then the scoping will take care of filtering only the EClasses of the
imported ecore file

hope this (and the sources :) helps
cheers
Lore


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:Open Model Element menu item
Next Topic:Inheritance in XText
Goto Forum:
  


Current Time: Sat Apr 20 03:45:53 GMT 2024

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

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

Back to the top