When reverse engineering existing source code into Enterprise Architect, there is an option to import dependency relationships based on operation return types and parameter types. These dependencies are only shown between individual classes. Some users however, wish to view implicit dependencies at the Package level, which Enterprise Architect does not generate by default.
The purpose of these scripts is to generate implicit dependencies at the package level based on the contents of the packages, and to assist with drawing a diagram to show these cross-package dependencies.
Configuring the scripts
In this example, we will take advantage of the new ability to call scripts directly from the Project Browser, introduced in Enterprise Architect 8.0.
- Open the scripting window (View | Scripting)
- Create a new script group
- Name the group "Project Browser"
- Set the group type to "Project Browser"
- Create a new VBScript under this group and name it "Synchronize Package Dependencies"
- Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencies.txt
- Save
- Create another new VBScript under this same group and name it "Synchronize Package Dependency Diagram"
- Open this new script in the built-in editor and paste in the contents of the file VBS_SynchPackageDependencyDiagram.txt
- Save
Using the scripts
With the scripts successfully added to your model, select the root package in the Project Browser from where you wish to generate your cross-package dependencies. To see the messages output by this script, make sure to open the Output window (View | System Output).
- Create a new Diagram of type 'Package' and open it (this diagram is where the dependencies will be drawn)
- Right-click on the context package in the Project Browser and select "Scripts | Synchronize Package Dependencies". The Output window will inform you when the process has been completed and report how many new package dependencies have been found.
- Right-click on your context package in the Project Browser again and select "Scripts | Synchronize Package Dependency Diagram"
- Several packages should now appear on your open diagram, but will all be piled on top of one another. We can now use EA's automatic diagram layout tools to organize these packages into a sensible layout.
- Open the Diagram Layout window ("View | Layout Tools")
- Select "Digraph" layout and click the "Apply Layout" button
These scripts can be executed again at any later time to update any changes in your cross-package dependencies that may have occurred since the original execution. Dependency relationships are added and removed between packages as necessary by running the “Synchronize Package Dependencies” script, and running the “Synchronize Package Dependency Diagram” script again can automatically add/remove packages from the currently open package diagram to show the items that are now relevant. If any items are added or removed from the diagram, you may need to run the automatic diagram layout tools again.