The Source Code Viewer
Access: View | Other Element Tools | Source Code.
Use the Source Code viewer to view any source code files for an element. If a Class is selected, the Source Code viewer shows the source code for that Class, provided it has already been generated. For C++ a second tab displays to show the implementation file.
The Source Code viewer also displays any DDL generated for a selected table in your diagram.
You view source code for an element by selecting menu options in a number of places, or by pressing either [Ctrl]+[E] or [F12]. 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.
A number of options change the way the Source Code viewer works. They can be altered via the Options dialog (select the Tools | Options | Source Code Engineering | Code Editors menu option). There are also many options for developing the code, available through the code editor context menu and through the Toolbar.
By default the Source Code viewer 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, as follows:
If you intend to edit external code, XML and DDL files (that is, code not selected from the Project Browser) use the File | Open Source File menu option, or press [Ctrl]+[Alt]+[O].
If you try to close the window or select another file, the editor prompts you to save your changes.
The Source Code viewer parses files for a number of reasons. The first is to enable it to jump to the location in the file at which the currently selected item is found (but not when editing external files).
Additionally, parsing displays a structure tree showing an overview of the file in a similar fashion to the main Project Browser. You can also select anything in that and jump to the appropriate line in the editor.
The viewer cannot parse DDL, and therefore does not show the structure tree for a DDL file.