Book a Demo

Author Topic: dependencies fail to result in java "import f  (Read 3513 times)

superfly

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
dependencies fail to result in java "import f
« on: October 12, 2004, 02:12:48 am »
Hello again,
I have 3 code generation questions.

1. is there a way of embedding the equivalent of roseuid's  so if a method name changes ea will recognise it as the same method?

2. Is there a way to treat my package structure as the directory structure on disk, so if i move a package around it automatically moves the files on disk ,or do i have to manually tell ea where they'll be for every class at generation time?

3. I'm quoting a previous user who never got an answer - any suggestions or is this somethingyou have to take care of manually in your jave ide and then reverse back.


<-- begin quotee -->

Hi,

I'm currently modelling a Java system using EA and was wondering why class dependencies are not translated into Java import statements during code generation.

For example:

Cricket --> pkg::Weather

Cricket.java:

Code:
import pkg.Weather;

public class Cricket{

}
     


Am I using the wrong relationship to model this sort of dependency or does the feature just not exist? I have had a look through the code generation templates and can't see a way to configure this sort of thing.

Cheers,

Brent.
<-- end quote -->
thanks in advance      

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: dependencies fail to result in java "impo
« Reply #1 on: October 12, 2004, 04:38:36 pm »
Hi,

Quote
1. is there a way of embedding the equivalent of roseuid's  so if a method name changes ea will recognise it as the same method?


We have been intending to provide GUID support for code synchronisation for a while now.  It is planned, but it's probably still a long way off.

Quote
2. Is there a way to treat my package structure as the directory structure on disk, so if i move a package around it automatically moves the files on disk ,or do i have to manually tell ea where they'll be for every class at generation time?


EA does not move or rename files if the class package or name changes.  So yes, you do need to tell EA where to look for the file before generation.

With regards to imports from dependency statements, it is now possible to configure in the code generation templates as there is now an import statement template and the ability to list over all possible imports.

A Java import template would look something like this.

Code: [Select]
%if importInFile!="T" and importPackagePath!="" and importPackagePath!=packagePath%
import %importPackagePath%.%importClassName%;
%endIf%


Then you could add imports for dependencies to your file by modifying the Import Section template to something like the following.

Code: [Select]
$COMMENT="WARNING: THIS IS AN ADVANCED TEMPLATE"
$COMMENT="DO NOT MODIFY UNLESS YOU ARE AN"
$COMMENT="ADVANCED USER!"
%if packagePath != "" and packagePath != "." and packagePath != ".\\"%
package %packagePath%;
%endIf%
$imports = %fileImports%
$imports += "\n" + %list="Import" @separator="\n" importFromDependency=="T"%
%REMOVE_DUPLICATES($imports, "\n")%


At some point in the future the %fileImports% will stop generating imports from class links and will only generate the imports field in the generation dialog box.  At that point you would need to replace that list with the following.  (Just a warning.  It does all need to be on the one line.)

Code: [Select]
%list="Import" @separator="\n" importFromAggregation=="T" or importFromAssociation=="T" or importFromAtt=="T" or importFromDependency=="T" or importFromGeneralization=="T" or importFromMeth=="T" or importFromParam=="T" or importFromRealization=="T"%

Simon

superfly

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: dependencies fail to result in java "impo
« Reply #2 on: October 13, 2004, 12:55:13 am »
Hey,
Thanks for the prompt reply. I can live without all these although they'd be nice to have.

I tried the import template technique and after much buggerising around discovered that this only worked if   it's the first time you're generating the file or if you are overwriting rather than synchronizing with the file. ( code generation options ) and thus losing any implementation code you've typed in.

It seems %File% just doesn't get invoked so the import stuff doesn't happen either. Is there a workaround for this or is this just the way it is?
Thanks



Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: dependencies fail to result in java "impo
« Reply #3 on: October 13, 2004, 04:08:23 pm »
That's just the way it is.

If you look at the help under (Code Engineering | Code Template Framework | Synchronizing Code) you find the following.

Quote
Only a subset of the code templates are used during synchronization.

It goes on to describe what templates are executed and when.

Simon