Author Topic: Code generation multiple classes into one file  (Read 4422 times)

Robert_N

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Code generation multiple classes into one file
« on: February 05, 2010, 11:03:37 pm »
Hi,
is it possible to make EA 7.5 to generate multiple selected classes of a diagram to on file? Normally my EA generates every class into a seperate file.

Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Code generation multiple classes into one file
« Reply #1 on: February 06, 2010, 04:47:04 am »
I haven't done this myself, but as I understood it when one of my team workers was generating Java code EA writes all the the contents (e.g., classes) in a namespace to a file.  So if you really want to write all the classes to a single file move these in the model below a top-level element.  In our case, we were trying to do the opposite.  The Java developer wanted each class in a separate file.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Code generation multiple classes into one file
« Reply #2 on: February 08, 2010, 08:42:46 pm »
Hi,

I could imagine to adapt the code generation templates, to produce a namespace general file (for the least packages in a hierarchy), and to sort out, what to place where based on tagged values for the classes, enums, etc. you want to place there.
I can't really tell, if this is possible. The main thing to figure out, is whether you can produce a separate file for a package element with EA's CG template engine.
If that won't work, it should be doable via an AddIn, using the MDG event hooks, IMHO. Didn't try this myself either.

HTH
Günther

PS.: Class nesting should work also. That's what I'm usually doing with internally used classes, or enum definitions releated to certain class attributes/operations. Take care to nest them in the project tree, just putting a 'nest' association doesn't serve that, AFAIE.
« Last Edit: February 08, 2010, 08:49:00 pm by Makulik »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8083
  • Karma: +118/-20
    • View Profile
Re: Code generation multiple classes into one file
« Reply #3 on: February 09, 2010, 08:54:25 am »
Basically, you need to set the classes to use the same filename, then use the Generate Package Source Code dialog to generate multiple classes at a same time.

Robert_N

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Code generation multiple classes into one file
« Reply #4 on: February 10, 2010, 01:25:52 am »
Quote
Basically, you need to set the classes to use the same filename
How to do this?

If it matters i want to develop a Delphi app. Yea, i know, please dont laugh to loud  ;D
« Last Edit: February 10, 2010, 01:35:22 am by dyferencjal »

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Code generation multiple classes into one file
« Reply #5 on: February 10, 2010, 01:40:41 am »
Quote
How to do this?
This can be done in the 'Files' tab of the classes' property dialogue.

Quote
If it matters i want to develop a Delphi app. Yea, i know, please dont laugh to loud  ;D
Shouldn't ...

HTH
Günther