Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [TEXO] Adding functions to util.ext
|
Re: [TEXO] Adding functions to util.ext [message #683746 is a reply to message #683718] |
Tue, 14 June 2011 10:03 |
Martin Taal 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 |
gdelprete 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 |
Martin Taal 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 #683917 is a reply to message #683896] |
Tue, 14 June 2011 16:18 |
Martin Taal 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
|
|
| |
Goto Forum:
Current Time: Thu Apr 25 17:23:48 GMT 2024
Powered by FUDForum. Page generated in 0.04356 seconds
|