Book a Demo
Prev Next

Source Code Panel

The 'Source Code' panel brings together a number of facilities for working with source code. Here you can import existing source code files into your model, creating new model elements that represent the classes in those files. You can select a Class in your model, then click a button to open the code editor window and automatically load the source code file associated with that Class. Facilities are also provided for:

  • Issuing commands to generate source code from the model
  • Synchronizing the model from the source code
  • Performing code analysis
  • Accessing tools such as the Debugger, Profiler, Execution Recorder and the Testpoints Window
  • Working with language grammars
  • Managing code templates and defining the way source code is imported into and generated from your model
Part of the Code ribbon in Sparx Systems Enterprise Architect.

Available Facilities



See also

Create From Pattern

Click on this icon to display the Patterns window, through which you can generate:

  • Starter projects including model information, code and build scripts for one of several basic application types (on the 'Application Patterns' page)
  • Examples of key sections of code to generate Sequence diagrams, including a Class model, build scripts and related source code (from the 'VEA Examples' page)
Application Patterns (Model + Code) Samples


Click on this icon to open a file browser through which you locate and open the required code file to edit.


Click on this icon to display the Source Code editor, to create or edit Behavior code for the operations in the selected element, or in the parent of the selected operation. You have three options:

  • Edit Behavior
  • Edit Internal Code
  • Edit (or View) Source Code

All three options display the Code Editor window, but show the appropriate features, code and editing options for the type of code identified by the option.

Behavior Code


Click on the drop-down arrow to display a list of options for importing project code from certain popular development products into the current project. For example:

  • Import a Visual Studio Solution
  • Import a Mono Solution
  • Import an Eclipse Project
  • Import a Netbeans Project

Having imported the material, you can perform a comparison between the external project source code and the Enterprise Architect model to check for Class differences, using the 'Compare with Model' option, and you can refresh the Enterprise Architect model to update it with any changes to the source.

Import Projects


Click on the drop-down arrow to display a list of options for importing code files into the current model from a variety of sources, selecting from a range of popular coding languages.

  • Edit New Source File - display the Code Editor window as a 'New File' document, enabling you to create and populate a new code file of whatever type and format you require
  • Import Directory - display the 'Import Source Directory' dialog, through which you import a complete directory tree in one pass; language and other options can be specified within the dialog
  • View Dry Run Log - If you have performed a source directory import with the 'Perform a Dry Run' option selected, a log file of that dry run is generated; this option displays that log file

You can also import:

  • ActionScript Files
  • C Files
  • C# Files
  • C++ Files
  • Delphi Files
  • Java Files
  • PHP Files
  • Python Files
  • Visual Basic Files
  • VB .Net Files
  • Binary File - supported file types are: Java JAR files and .NET PE or IL format (exe, dll)
  • Windows .RC File (a Windows C/C++ .RC file), as a series of screen definitions

If you have developed model structures for any customized programming language, those languages are also included in the list.

Import Binary Module Import a Directory Structure Importing Source Code


Click on this icon to display options to generate source code for:

  • The currently selected model element(s), or
  • A single element, with options, or
  • All elements in the current context

Source code is generated into the file that is associated with each individual element. Code is generated only for elements that are of type Class or Interface.

Generate a Package Generate a Group of Classes Generate a Single Class


Click on this icon to display options to synchronize the currently selected model elements with their associated source code files, or to synchronize the whole Package containing the selected elements.

Update Package Contents Synchronize Model and Code


Click on the drop-down arrow to display a list of options for managing templates, which determine the way source code is imported into and generated from your model.

  • Edit Code Templates - display the Code Template Editor window, where you can review and edit the templates used for generating source code from your model
  • Set  Package as Namespace Root - set the selected Package as the Namespace root, for code generation
  • Suppress Namespace - ignore the current subordinate Package when generating Namespaces and showing Package paths
  • Configure Local Paths - display the 'Local Paths' dialog, where you can set up and manage a list of Local Path definitions, used for path substitutions in collaborative environments
  • Configure Code Engineering Datatypes - manage the list of Datatypes that are used in Code Engineering
  • Define Preprocessor Macros - manage a list of preprocessor macros that will be used when C and C++ code is imported into the model
  • Reset Source Language - display the 'Manage Code Generation' dialog to change the source language and other generation options for all Classes in the selected Package
  • Set Live Code Generation - update your source code instantly as you make changes to your model
Local Paths Dialog Namespaces Language Macros Coding Data Types The Code Template Editor Reset Options

Execution Analyzer

Click the drop-down arrow to access a menu of Analyzer tools.

  • Edit Analyzer Scripts - display the Execution Analyzer window, where you can create and manage scripts that define the build, run, test, deploy and simulate functions for the current Package
  • Edit Active Script - display the Analyzer script editor to edit the currently-active Analyzer script
  • Show Testpoints Window - display the Analyzer Test Points window, to configure, execute and work with dynamic test suits and test cases
  • Find Test Suites and Test Sets - search the model for Test Suites and Test Sets
  • Open Debugger - display the Analyzer Debug window to facilitate debugging and testing of the current application
  • Open Profiler - display the Analyzer Profiler window, from which you can perform application performance profiling and execution inspection of the current application
  • Open Recorder - display the Analyzer Recording window, from which you can set recording points, record program execution and create diagrams based on recordings
  • Open Object Workbench - open a simple Object Testing window, from which you can make ad hoc calls on Object methods; available for Java and .NET objects
Managing Analyzer Scripts The Testpoints Window Object Workbench Debugging Profiling The Recording History Build Scripts

Grammar Editor

Display the Grammar Editor window, an advanced facility that allows you to view, add, edit and manage language grammars, used for importing source code.

Editing Grammars

Code Analyzer

The Code Analyzer can perform very complex queries on source code repositories at lightning speed either locally or on a Sparx Intel Cloud service, allowing code metrics to be queried much faster than conventional methods.

Code Analyzer