Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Adding functions to util.ext
[TEXO] Adding functions to util.ext [message #683718] Tue, 14 June 2011 09:48 Go to next message
gdelprete is currently offline gdelpreteFriend
Messages: 10
Registered: June 2011
Junior Member
Hello,

I'd like to add functions to util.ext, to be used in my overridden template definitions.

I add the definition:

boolean isEnum ( EStructuralFeature eStructuralFeature ): JAVA org.me.TexoUtils.isEnum(org.eclipse.emf.ecore.EStructuralFeature);

and created the class org.me.TexoUtils with a static booleran isEnum(org.eclipse.emf.ecore.EStructuralFeature) method.

I added the class to a Eclipse plugin, and am trying to test it in a plugin development workspace.

However, the code generation fails saying that it cannot find class org.me.TexoUtils:

org.me.TexoUtils.isEnum(org.eclipse.emf.ecore.EStructuralFeature) not found, problems were:
[AnalysationIssueType not found] - Couldn't find Java type org.me.TexoUtils : org.me.TexoUtils

Has someone any idea of what is wrong with my approach?

Sorry if the answer to my question is silly but it's my very first try at extending an Eclipse project.

Regards,
Gabriele
Re: [TEXO] Adding functions to util.ext [message #683746 is a reply to message #683718] Tue, 14 June 2011 10:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gabriele,
I am afraid that it currently is not possible to call your own javacode from these templates. Your development project
is not part of the classpath of the template generation. There is specific logic to find template files in your
development project, but not to add javaclasses from your development project. This is quite hard to do. So I am afraid
that you need to implement your logic in xtend.

gr. Martin

On 06/14/2011 11:48 AM, forums-noreply@eclipse.org wrote:
> Hello,
>
> I'd like to add functions to util.ext, to be used in my overridden template definitions.
>
> I add the definition:
>
> boolean isEnum ( EStructuralFeature eStructuralFeature ): JAVA
> org.me.TexoUtils.isEnum(org.eclipse.emf.ecore.EStructuralFeature);
>
> and created the class org.me.TexoUtils with a static booleran isEnum(org.eclipse.emf.ecore.EStructuralFeature) method.
> I added the class to a Eclipse plugin, and am trying to test it in a plugin development workspace.
> However, the code generation fails saying that it cannot find class org.me.TexoUtils:
>
> org.me.TexoUtils.isEnum(org.eclipse.emf.ecore.EStructuralFeature) not found, problems were: [AnalysationIssueType not
> found] - Couldn't find Java type org.me.TexoUtils : org.me.TexoUtils
>
> Has someone any idea of what is wrong with my approach?
>
> Sorry if the answer to my question is silly but it's my very first try at extending an Eclipse project.
>
> Regards,
> Gabriele


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] Adding functions to util.ext [message #683794 is a reply to message #683746] Tue, 14 June 2011 12:43 Go to previous messageGo to next message
gdelprete is currently offline gdelpreteFriend
Messages: 10
Registered: June 2011
Junior Member

Is this going to work if I create an Eclipse Plugin with just my "utils" class? This way my class would be in eclipse's (running) classpath, available to be called by Texo when it's running the generator. I'm trying to do this right now, but it still can't find my class.

Otherwise, can you recommend a tutorial on xtend?

For the record, what I'm trying to achieve is modify Texo's behavior when generating initializers on fields.
I need:
1) EEnum fields to be init'd to null, not the enum's first value;
2) EReference to be initialized with a object (i.e. new TYPE()) instead of being set to null, with the added requirment, of course, that if a field's type is an interface, the initialized object must be of a concrete class (for example List -> ArrayList).

I achieved in part 2) by modifying the entity template (I can easily check if a field is a reference), but achiveving 1) and the second part of 2) would be awesome.

Note that I don't want to touch the .ecore file as we generate it from an XSD file.

Regards, and thanks for the quick response.

Gabriele


Re: [TEXO] Adding functions to util.ext [message #683869 is a reply to message #683794] Tue, 14 June 2011 14:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hmm, not that won't work with the current version of Texo but I can easily change that. So then you can create a plugin
which adds classes to the classpath of the generator plugin.

I am doing a build right now with this change.

gr. Martin

On 06/14/2011 02:43 PM, forums-noreply@eclipse.org wrote:
>
> Is this going to work if I create an Eclipse Plugin with just my "utils" class? This way my class would be in eclipse's
> (running) classpath, available to be called by Texo when it's running the generator. I'm trying to do this right now,
> but it still can't find my class.
>
> Otherwise, can you recommend a tutorial on xtend?
> For the record, what I'm trying to achieve is modify Texo's behavior when generating initializers on fields.
> I need:
> 1) EEnum fields to be init'd to null, not the enum's first value;
> 2) EReference to be initialized with a object (i.e. new TYPE()) instead of being set to null, with the added requirment,
> of course, that if a field's type is an interface, the initialized object must be of a concrete class (for example List
> -> ArrayList).
>
> I achieved in part 2) by modifying the entity template (I can easily check if a field is a reference), but achiveving 1)
> and the second part of 2) would be awesome.
>
> Note that I don't want to touch the .ecore file as we generate it from an XSD file.
>
> Regards, and thanks for the quick response.
>
> Gabriele
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] Adding functions to util.ext [message #683896 is a reply to message #683869] Tue, 14 June 2011 15:58 Go to previous messageGo to next message
gdelprete is currently offline gdelpreteFriend
Messages: 10
Registered: June 2011
Junior Member
I can confirm that it did not work Wink

Meanwhile, I learnt that bit of Xpand/Xtend which allowed me to do all what I wanted by means of the template.

I'm sorry for making you code the change...

In any case, I believe it's a nice enhancement to Texo's flexibility, will test it and let you know.



Re: [TEXO] Adding functions to util.ext [message #683917 is a reply to message #683896] Tue, 14 June 2011 16:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Good to hear that it works, in any case there is now a new build available where you can add your plugin to the
classpath using registerbuddy, add this to the Manifest.mf of the plugin:
Eclipse-RegisterBuddy: org.eclipse.emf.texo.modelgenerator

gr. Martin

On 06/14/2011 05:58 PM, forums-noreply@eclipse.org wrote:
> I can confirm that it did not work ;)
>
> Meanwhile, I learnt that bit of Xpand/Xtend which allowed me to do all what I wanted by means of the template.
>
> I'm sorry for making you code the change...
> In any case, I believe it's a nice enhancement to Texo's flexibility, will test it and let you know.
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [TEXO] Adding functions to util.ext [message #685863 is a reply to message #683917] Mon, 20 June 2011 12:38 Go to previous message
gdelprete is currently offline gdelpreteFriend
Messages: 10
Registered: June 2011
Junior Member
Tested, and it works like a charm!!

Thank you very much, this is going to be very useful in our next development iteration.

A suggestion: now that it's possible to extend utility functions, you might want to add a empty util_addition.ext file among the built-in templates and have it called, so there's a proper position where users can put their new utility definitions (or, if possible, allow this util_addition.ext to be placed somewhere in the plugin jar, for a true plug&play experience Smile )

Gabriele
Previous Topic:[JS4EMF] goal of JS4EMF
Next Topic:[EEF] Multiple Generation errors with 1.0RC
Goto Forum:
  


Current Time: Thu Oct 22 18:58:34 GMT 2020

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

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

Back to the top