Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] Can we know the Generated List file of mainFile(Can we know the Generated List file of mainFile)
[acceleo] Can we know the Generated List file of mainFile [message #543649] Wed, 30 June 2010 08:26 Go to next message
poltrox  is currently offline poltrox Friend
Messages: 16
Registered: June 2010
Junior Member
Hi

I use a main file acceleo with condition on generation of template.

Is it possible to know the generated file List of doGenerate call ?

Thanks.
Re: [acceleo] Can we know the Generated List file of mainFile [message #543667 is a reply to message #543649] Wed, 30 June 2010 08:59 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040908040803030307070602
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

The "doGenerate" method doesn't allow it, yet if you look at its
implementation, you'll realize that it simply delegates to "generate"
which does return the list of generated files. You can change your

We didn't add it directly to doGenerate() because of API compatibility
issues. You can call "generate()" directly if you wish to retrieve this
list.

Laurent

poltrox wrote:
> Hi
>
> I use a main file acceleo with condition on generation of template.
>
> Is it possible to know the generated file List of doGenerate call ?
> Thanks.


--------------040908040803030307070602
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040908040803030307070602--
Re: [acceleo] Can we know the Generated List file of mainFile [message #543675 is a reply to message #543667] Wed, 30 June 2010 09:25 Go to previous messageGo to next message
poltrox  is currently offline poltrox Friend
Messages: 16
Registered: June 2010
Junior Member
I try to call directly generate but the map return is empty.

Map<String,String> mapList;
dataAcceleoGenerator = ((AbstractAcceleoGenerator)acceleoGenerator.newInstance());
dataAcceleoGenerator.initialize(modelUri, folder, arguments);
mapList=dataAcceleoGenerator.generate(new BasicMonitor());
System.out.println("size " +mapList.size()+ " contains "+mapList.values());


Console :
size 0 contains []

This call generates 4 files .
Re: [acceleo] Can we know the Generated List file of mainFile [message #543680 is a reply to message #543675] Wed, 30 June 2010 09:38 Go to previous messageGo to next message
poltrox  is currently offline poltrox Friend
Messages: 16
Registered: June 2010
Junior Member
I see a method get Listener, I don't understand how to use her.
I don't find a method to add me to the listener.

Do you have some exemple ?

Thanks
Re: [acceleo] Can we know the Generated List file of mainFile [message #543693 is a reply to message #543680] Wed, 30 June 2010 10:33 Go to previous messageGo to next message
poltrox  is currently offline poltrox Friend
Messages: 16
Registered: June 2010
Junior Member
I find a solution , but i don't understand why you return a new list of Listener at each call of
getListeners ()

I must move to global attribute
List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
in each mainfile generated.

I can add my listener after this change :
dataAcceleoGenerator.getGenerationListeners().add(this);

Why you don't create this list in the abstract method as attribut instead to create a new list for each call ?

Re: [acceleo] Can we know the Generated List file of mainFile [message #543721 is a reply to message #543693] Wed, 30 June 2010 11:51 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010600070503030007070609
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

The "getGenerationListeners()" method will only be called once for each
generation, thus returning a new list is the easiest.

As for the "generate" call returning an empty map, this is due to the
generation strategy you use (see method getGenerationStrategy) : the
default strategy will create the files on the fly, and it doesn't keep
track of the files it generated.

If you use the PreviewStrategy instead, "generate()" will return a Map
which key=value pairs such as : filename = file contents... but the
PreviewStrategy doesn't generate files :p.

Feel free to fill in an enhancement request for this, the default
strategy simply doesn't keep track of them because this functionality
has been added later.

Laurent Goubet
Obeo

poltrox wrote:
> I find a solution , but i don't understand why you return a new list of
> Listener at each call of getListeners ()
>
> I must move to global attribute List<IAcceleoTextGenerationListener>
> listeners = super.getGenerationListeners(); in each mainfile generated.
>
> I can add my listener after this change :
> dataAcceleoGenerator.getGenerationListeners().add(this);
>
> Why you don't create this list in the abstract method as attribut
> instead to create a new list for each call ?
>


--------------010600070503030007070609
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------010600070503030007070609--
Re: [acceleo] Can we know the Generated List file of mainFile [message #543737 is a reply to message #543721] Wed, 30 June 2010 12:53 Go to previous messageGo to next message
poltrox  is currently offline poltrox Friend
Messages: 16
Registered: June 2010
Junior Member
How can I add one class like a listener of my generator if I don't used
The "getGenerationListeners()" method ?

the function addListener is deprecated in abstract class and i don't find another solution as modify each generator
Re: [acceleo] Can we know the Generated List file of mainFile [message #543744 is a reply to message #543737] Wed, 30 June 2010 13:02 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000501030501080803070507
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

The intended way of doing it is to use the "getGenerationListeners"
method, not the "addListener" one.

As mentionned in the "getGenerationListeners" code :

// TODO if you need to listen to generation event, add listeners to the
list here

which means you simply have to change it so that it looks like :

public List<IAcceleoTextGenerationListener> getGenerationListeners() {
List<IAcceleoTextGenerationListener> listeners =
super.getGenerationListeners();

listeners.add(new MyGenerationListener());

return listeners;
}

poltrox wrote:
> How can I add one class like a listener of my generator if I don't used
> The "getGenerationListeners()" method ?
>
> the function addListener is deprecated in abstract class and i don't
> find another solution as modify each generator


--------------000501030501080803070507
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------000501030501080803070507--
Previous Topic:Using JET on WSDL and XSD
Next Topic:[Acceleo] Import UML Profile to use in templates
Goto Forum:
  


Current Time: Fri Apr 19 00:27:08 GMT 2024

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

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

Back to the top