Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Log with Jet ?
Log with Jet ? [message #22450] Mon, 18 June 2007 12:08 Go to next message
Aleks Dworak is currently offline Aleks DworakFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,

I'm working on some jet transformations for code generation.
I would like to be able to log some kind of informations about the jet
transformation when it is loaded :

1. do I create or update files ?
2. If it is an update, which part of file remains untouched (user specific
code or static part)?

For the first issue I think that it is not to hard, since I can verify if
my target file already exists.

But for informations whose granularity is a part of a file (and not the
file itself), I don't have any clue.

Did someone already have and resolved this kind of problem ?
Do you have any idea ?

Thank you,

Aleks.
Re: Log with Jet ? [message #22624 is a reply to message #22450] Tue, 19 June 2007 13:11 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Aleks:

JET does not provide explicit events that you can monitor to detect these.

Several ideas come to mind.

1) create a tag that you put in the templates you want to monitor. Have the
tag register a listener on the writer. The writer eventually broadcasts two
events 'finalizeContent' and 'postCommit'. In both, you get passed an IFile.
Finalize content happens before the file is written (this is where
userRegion does its real work); post commit notifies you that the content
has been written (this is where c:marker does its work). You could use
finalizeContent to determine if the file already exists.

2) As for monitoring parts of the generated content, I would start
experimenting with adding Positions to the IDocument backing the writer, and
then checking to see whether those positions still exist at postCommit. You
can see how this works by looking at the implementation of tags such as
c:userRegion (which delegates all its real work to the class
UserRegionHelper). I can imagine have a tag that does nothing but create a
Position in the writer, say withing an c:initialCode block:

<c:userRegion>// BEGIN ... <c:initialCode>
<custom:markPosition id="...some sort of id that relates this
position to the user region...">
.... the initial code...
</c:initialCode>// END ...</c:userRegion>

Then, at postcommit, you can inspect the IDocument to see which of the
Positions the tag created still remain on the tag.

3) Lastly, currently, JET always rewrites the static part of the template,
unless the ws:file 'replace' attribute is set to 'false' (in which case an
existing file is never changed). I am considering enhancements that would
only commit content if it has actually changed, but that is in the future.

I may be able to give you better ideas if I understood what you were trying
to accomplish. I have vague ideas of being able to trace text in a template
output back to either the template's static text or to a particular tag (an
perhaps to a particular model element), but I haven't really spent time
considering this deeply. Is this the kind of thing you are trying to do?

Paul


"adworak" <aleks_dworak@fr.ibm.com> wrote in message
news:528bc8678c265a365f94fe18a614e09e$1@www.eclipse.org...
> Hi,
>
> I'm working on some jet transformations for code generation.
> I would like to be able to log some kind of informations about the jet
> transformation when it is loaded :
>
> 1. do I create or update files ?
> 2. If it is an update, which part of file remains untouched (user specific
> code or static part)?
>
> For the first issue I think that it is not to hard, since I can verify if
> my target file already exists.
>
> But for informations whose granularity is a part of a file (and not the
> file itself), I don't have any clue.
>
> Did someone already have and resolved this kind of problem ?
> Do you have any idea ?
>
> Thank you,
>
> Aleks.
>
Previous Topic:Multiple transformations in a single project.
Next Topic:[JET2] Using MessageDialog in custom Tag
Goto Forum:
  


Current Time: Fri Dec 27 01:00:07 GMT 2024

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

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

Back to the top