The Source Code Viewer

The Source Code viewer can be used to view any source code you are opening. If a Class is selected, it shows the source code for that Class, provided it has already been generated. For C++ a second tab displays to show the implementation file.

Note:

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).

By default the Source Code viewer is set to:

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

The Source Code viewer also displays any DDL generated for a selected table in your diagram.

External File Editor

A very similar code editor for editing external code, XML and DDL files (that is, code not selected from the Project Browser) is available through the File | Open Source File menu option, or by pressing [Ctrl]+[Alt]+[O]. This editor does not have a toolbar; basic editing options are available through a right-click context menu.

To save changes, press [Ctrl]+[S]; also, if you try to close the window or select another file, the editor prompts you to save your changes.

File Parsing

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.

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.

SourceCodeViewer

The Source Code Viewer Toolbar Buttons

The toolbar buttons in the Source Code viewer enable you to edit, view and interact with the code contained in the Source Code viewer. The function of each button is described below:

SourceTool

  • Open button - opens the source code from an existing file, this option is also active in the 'Lite', read-only version of Enterprise Architect
  • Save button - saves the changes to the currently loaded source code; this option is also active in the 'Lite', read-only version of Enterprise Architect
  • Copy button - copies the highlighted text to the clipboard
  • Paste button - pastes the text that is currently contained in the clipboard to the Source Code viewer
  • Undo button - cancels the previous action
  • Generate and Synch button - generates and synchronizes with the current object source
  • Save and Resynch button - saves the source code and resynchronizes the Class
  • Build and Run button - provides quick access to the following commands:
  • Build - run package build scripts
  • Test - run package test scripts
  • Run - run debug
  • Package Build Scripts - configure package build scripts

(these options are also active in the 'Lite', read-only version of Enterprise Architect)

  • Set Font button - sets the font for the text contained in the Source Code viewer.