[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.emf] Re: Suppress EMF Types=true, Root Extends Class="", Root Extends Interface=""
|
Michael,
More answers below.
Frank.
Michael Vorburger wrote:
> Frank,
>
> thanks for the explanations. I have tried pursuing the option of using my
> own templates, but still leveraging genmodel (and not "raw" JET as per the
> two JET Tutorial articles) but can't seem to get this to work... I suspect
> it's got something to do with how I set the Template Directory. Exact
> details below, but basically first I set it just to "templates", then I saw
> in Book p. 252 that's it's relative to Workspace, so I set it to
> "{myprojectname}/templates", lastly tried absolute path, still not luck.
> BTW, If I directly change files in
> plugins\org.eclipse.emf.codegen.ecore_2.0.0\templates it works. I think that
> fact that "... if any are missing, the ordinary templates are used instead"
> doesn't help for experimenting here... because if you get the path wrong or
> something, it will 'silently' use defaults. Could that be made more
> explicit, or at least some log be printed so that one knows which template
> is taken and why? Where in the code is that logic?
JET actually supports a templatePath (see the constructors for JETEmitter and
JETCompiler), which are similar to a Java classpath but for finding templates.
The EMF generator only supports one Template Directory, which it puts in front
of the default template directory on a templatePath of size 2. See the
GenModelImpl.getTemplatePath() method. The method JETCompiler.find() is the one
that actually searches for templates along the path.
>
>
> Something else: How would I do something like say disable generation of
> factories, or xyzPackage? I think what I want is to build my own codegen
> for an Ecore model but not using genmodel, if that makes sense. I guess I
> could do that using "pure" JET as per the two JET Tutorial articles, but
> that would be a pitty, because I still want to reuse some of the things in
> emf.codegen.ecore - from something as stupid as the getImportedType() helper
> to something as complex as the reloading an ecore model from an annotated
> Java interface. (Which, btw, I would like to extend, so if I come up with
> some new JavaDoc tags, how can I get the 'reloader' to stick them back into
> the ecore model?)
We're planning to make the code generator more customizable via
extension/extension points in the coming months, but for now, you'll need to
hack the code. Suppressing package/factory generation is just a matter of not
calling the generate method for the package. If you look at
GenPackageImpl.generate(), you'll see that it calls generate() for all of the
classes, and then generates the package and factory classes, among other things.
Sounds like you'll want to only do the first part.
Adding new JavaDoc tags would require changing JavaEcoreBuilder. You'll probably
want to store the new information in custom EAnnotations on the Ecore model
elements.
>
>
> BTW, did a checkout of org.eclipse.emf.codegen.ecore & ui src to maybe try
> some things, but had a compile time error in EMFProjectWizard.java,
> page.openEditor(modelFile) complains "is not applicable for the arguments".
> I found no tag or branch for 2.0.0, how would one get a working 2.0.0 EMF
> src?
Sorry about the delay in getting the EMF 2.0 code into CVS. We're restructuring
our internal builds right now. You can get the source from the source plugin
(emf.source_2.0.0_20031219_0637VL.zip) for now.
>
>
>
> Lastly, if interested why I am asking what I am asking, check out
> http://www.corejdo.com/modelling/ ... anybody on this forum interested in
> joining a relevant discussion list or something to carry some of that
> further together?
>
> Thanks,
> Michael
>
> ====
> Here is what I did in more details:
>
> - New Java project called 'emf'
> - New Java interface 'test.Book' with String getAuthor() and @model etc.
> - New EMF Models, test.genmodel, Load from Annotated Java
> - In test.genmodel Properties, set Dynamic Templates = true
> - In test.genmodel Properties, set Template Directory = emf/templates
> (relative to Workspace, according to Book p. 252)
> - Copy .../plugins\org.eclipse.emf.codegen.ecore_2.0.0\templates to project
> emf/templates
> - Modify copied emf/templates/model/Class.javajet
> - Open test.genmodel, Generator / Generate Model code
>
> The changes in templates don't seem to be taken into account.
>
> ===
> package test;
>
> /**
> * @model
> */
> public interface Book {
> /** @model */
> String getAuthor();
> }