Automation Interface Examples: Code Details - Custom View
- Description of code
- Setting up MS VB to use EA's Automation interface
- Basic concepts
- EA is installed on the machine
- MS Graph 6.0 is installed
- Visual Basic 6.0 is installed on the machine if you wish to develop the application
The code details provide additional information to the documentation on the use of a Custom View in the Automation Interface. The intention is to provide an example on creating a user diagram using a Custom View. This code is considered as a starter for users to configure their own Custom View diagrams.
It is assumed there would be a reasonable knowledge of Visual Basic if modifications are to be made to the following example. Guidelines on the Use of the Automation Interface have been provided with EA (see References).
Description of Code
The code for DemoGraph is a Visual Basic 6.0 .ocx written to interface with Enterprise Architect.
The DemoGraph.ocx application is loaded when EA starts. It is referenced in the registry under two settings
a) The DLL entry
b) The EA Add-In entry which references the DLL entry. (For more information on this see Calling Applications from EA).
The basic concept behind the code is that it runs through the hierarchy of an EA repository from the selected package level and and sums the entries in the Tests or Maintenance tables to create graphical reports on these.
It basically consists of:
- A Module: Graphdata
- A Class: EaAddin (A class for the addin interface to EA)
- A User Control: UserControl1 (an MS Graph component)
The core piece of code relevant to setting up the custom View is contained in the EAAddin class and calls the EA reposiorty AddTab function as follows;
Set m_UserControl = Repository.AddTab(ItemName + "DisplayName", "UserControl")
In terms of the process; the key starting point for running through the EA repository is to get the currently selectedt package using GetTreeSelectedPackage.
The DumpPackage routine is then called with the value of the selected package. It runs through the set of project trees (packages). Each set of Elements/Packages are processed under this with the data accumulated in an array. Finally this array is passed to a routine to draw the graph contained in the UserControl.
The Call Cycle is as follows:
'Closes the open files
' Opens the EA Application and MS Graph Component and calls the following..
' Creates the heading text for the graphs
' Parses the Model
' Parses the Packages
' Parses the Elements in the package
' Sums the test or Maintenance
Setting up MS VB to use EA's Automation interface
To set up the Visual Basic 6 project to generate the DLL - create the new project in VB as an 'ActiveX DLL'. See in EA's help file under 'Automation and scripting' - 'Creating addins for a full description of setting up the class structure. Once the initial ActiveX control has been created see Calling EA Addin for a description of setting the registry reference to the DLL.
The following is a brief description of the contents of each of the modules within AutInt. This code is Downloadable.
|GRaphdata||The main Code for traversing the repository and summing the data.|
|Graph.cls||The EAAddin class|
|UserControl1||The code and form used to update the MS Graph User Control.|
A brief description of some of the Public Variables defined in the application:
|UserControl||The User control set up for MS Graph|
|GraphArr||An Array of items to be graphed|
|EaRepos||The instance of the current EA repository|