Next: , Previous: The Work Space, Up: Description of the Main Windows


2.5 The Project View

The project explorer provides a view of the various components of your project hierarchy, as listed below. It is displayed by default on the left side of the main window, and can be selected by using the Project->Project View or Tools->Views->Project menu items.

Under Windows, it is possible to drop files (coming e.g. from the Explorer) in the project explorer with the following behavior: a project file dropped will be loaded; any other file will be opened in a new source editor.

project-view.jpg

The project explorer, as well as the file and outline view provide an interactive search capability allowing you to quickly search in the information currently displayed. The default key to start an interactive search is <Ctrl-i>. This will open a small window at the bottom of the explorer where you can interactively type names. The first matching name in the tree will be selected while you type it. You can then also use the <up> and <down> keys to navigate through all the items matching the current text.

The various components that are displayed are:

projects
All the sources you are working with are put under control of projects. These projects are a way to store the switches to use for the various tools, as well as a number of other properties.

They can be organized into a project hierarchy, where a root project can import other projects, with their own set of sources.

Initially, a default project is created, that includes all the sources in the current directory.

The Project View displays this project hierarchy: the top node is the root project of your application (generally, this is where the source file that contains the main subprogram will be located). Then a node is displayed for each imported project, and recursively for their own imported projects.

A given project might appear multiple times in the Project View, if it is imported by several other projects.

There exists a second display for this project view, which lists all projects with no hierarchy: all projects appear only once in the explorer, at the top level. This display might be useful for deep project hierarchies, to make it easier to find projects in the explorer.

This display is activated through the contextual menu entry Show flat view, which acts as a switch between the two displays.

A special icon with a pen mark is displayed if the project was modified, but not saved yet. You can choose to save it at any time by right-clicking on it. GPS will remind you to save it before any compilation, or save it automatically, if the corresponding preference is saved.

directories
The files inside a project can be organized into several physical directories on the disk. These directories are displayed under each project node in the Project View

You can chose whether you want to see the absolute path names for the directories or paths relative to the location of the project. This is done through the Show absolute paths contextual menu.

Special nodes are created for object and executables directories. No files are shown for these.

files
The source files themselves are stored in the directories, and displayed under the corresponding nodes. Note that only the source files that actually belong to the project (i.e. are written in a language supported by that project and follow its naming scheme) are actually visible. For more information on supported languages, See Supported Languages.

A given file might appear multiple times in the Project View, if the project it belongs to is imported by several other projects.

If you left click on a file and keep the button pressed, you can drop it anywhere in GPS to open an editor at that location.

entities
If you open the node for a source file, the file is parsed by one of the fast parsers integrated in GPS so that all entities declared in the project can be shown. These entities are grouped into various categories, which depend on the language. Typical categories include subprograms, packages, types, variables, tasks,...

Double-clicking on a file, or simple clicking on any entity will open a source editor and display respectively the first line in this file or the line on which the entity is defined.

If you open the search dialog through the Navigate->Find or Replace... menu, you have the possibility to search for anything in the explorer, either a file or an entity. Note that searching for an entity can be slow if you have lots of files, and/or big files.

A contextual menu, named Locate in Explorer, is also provided when inside a source editor. This will automatically search for the first entry for this file in the explorer. This contextual menu is also available in other modules, e.g. when selecting a file in the Dependency Browser.

2.5.1 The configuration variables

As described in the GNAT User's Guide, the project files can be configured through external variables (typically environment variables). This means that e.g. the exact list of source files, or the exact switches to use to compile the application can be changed when the value of these external variables is changed.

GPS provides a simple access to these variables, through a window called the Scenario View. These variables are called Configuration Variables, since they provide various scenarios for the same set of project files.

scenario-view.jpg

A combo box is displayed in this area for each environment variable the project depends on. The current value of the variable can be set simply by selecting it from the pop-down window that appears when you click on the arrow on the right of the variable name

New variables can be added through the contextual menu Project->Add Configuration Variable in the Project View. The list of possible values for a variable can be changed by clicking on the button on the left of the variable's name.

Whenever you change the value of one of the variables, the project is automatically recomputed, and the list of source files or directories is changed dynamically to reflect the new status of the project. Starting a new compilation at that point will use the new switches, and all the aspects of GPS are immediately affected according to the new setup.