Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Contents
Prev Next

Editing Source Code

Enterprise Architect contains a powerful source code editor that helps you to view, edit and maintain your source code directly inside the tool. Once source code has been generated for one or more Classes it can be viewed in this flexible editing environment. Seeing the code in the context of the UML models from which it is derived brings clarity to both the code and the models, and bridges the gap between design and implementation that has historically introduced errors into software systems.

The Source Code Editor is fully-featured, with a structure tree for easy navigation of attributes, properties and methods. Line numbers can be displayed and syntax highlight options can be configured. Many of the features that software engineers are familiar with in their favorite IDE, such as Intelli-sense and code completion are included in the editor. There are many additional features, such as macro recording that makes it easy to manage the source code inside Enterprise Architect. There are also many options for managing the code, available through the code editor context menu, toolbar and function keys.

For most programming languages a single file is created from a UML Class, but in the case of C++ both header and implementation classes are created and the source code editor displays these files in separate tabs.

A number of options change the way the source code editor works; they can be altered using the 'Preferences' dialog available from the Start ribbon:

     'Start > Workspace > Preferences > Source Code Engineering > Code Editors'

There are four variants of the Source Code Editor, with different access methods. The variants are discussed in the Compare Editors topic.

Access

Ribbon

Code > Source Code > Edit Code > Open Source File    or

Code > Source Code > Edit Code > Edit Element Source    or

Code > Source Code > Edit Code > Edit New Source File

Context Menu

Project Browser | Right-click on element | Code Engineering | View Source Code

On diagram | Right-click on element | Code Engineering | View Source Code

Keyboard Shortcuts

Ctrl+E  (for code associated with elements)

Ctrl+Alt+O  (for external files)

Facilities

Facility

Description

See also

Source Code editor

By default the Source Code editor is set to:

  • Parse all opened files, and show a tree of the results
  • Show line numbers

If you are editing an XML file, the structure tree is presented in a folder hierarchy rather than a Class structure hierarchy:

Structure Tree

The structure tree is available for supported language files, such as C++, C#, Java, XML files such as XSD, XSL

Notes

  • There are no context menu options to display XML or DDL.sql files; select the appropriate object and use the keyboard keys F12 or Alt+7
  • When you select an element to view source code, if the element does not have a generation file (that is, code has not been or cannot be generated, such as for a Use Case), Enterprise Architect checks whether the element has a link to either an operation or an attribute of another element - if such a link exists, and that other element has source code, the code for that element displays
  • You can also locate the directory containing a source file that has been created in or imported to Enterprise Architect, and edit it or its related files using an external editor such as Notepad or Visual Studio; right-click on the element in the Project Browser and select the 'Code Engineering | Open Source Directory' option (Ctrl+Alt+Y)

Learn more