Compare user interface

The compare user interface is a visual tool that helps to display the differences between two versions of a file or codebase. It's often used in version control systems like Git to understand the changes and modifications made between commits, as well as to review code changes before merging them.

The Compare user interface consists of three compartments:

The top compartment lists the changes made between two versions of a model. The bottom two compartments display these versions side-by-side. Selecting a change in the list will highlight the specific modifications in both the original as well as modified models.

The two key features of the compare user interface are as follows:

Hint: You can double-click the header of a compartment to maximize that compartment and hide all the others. Double-click the header again to make all compartments visible.

As you can see there are several buttons and menus available in the Compare user interface. Many of these apply only for merge sessions, and are therefore disabled for a compare session.

In This Topic:

Switch Compare Viewer

The Compare tool supports comparing many kinds of files, not just UML model files created in Model RealTime. For each kind of supported file one or many content types may apply. Each content type corresponds to a particular compare viewer which controls the overall appearance of the Compare user interface.

The Compare tool uses the file extension of the compared files to find a default content type to use for the compare session. For example, for model files (.emx, .efx etc.) the default content type is called "Model RealTime Model Content Type". When this content type is used, the Compare user interface will consist of the three compartments that were mentioned previously.

You can use the menu that appears immediately to the right of the text "Structural changes" to switch to using a different content type and compare viewer. As you can see in the picture above, the content type "Text" is also available for model files. If you choose this content type the Compare tool will treat the compared files as plain text files and the Compare user interface will change to just show two compartments, where the models are shown as text files:

Switching to a non-default content type, such as Text, can sometimes help you better understand what a particular change relates to. However, in most cases the default content type will be the most appropriate to use.

Reorganize Contributors

Before starting to look at any of the changes in the change list, it's a good idea to first check so that the correct model versions were chosen as the left and right contributor. As said previously Compare/Merge reports changes as "what happened to the left contributor compared to the right contributor" or, put differently, "what changes are required to be made in the right contributor to make it equal with the left contributor". If you by mistake choose the contributors in the wrong order when doing a compare, you will see Add changes when Delete changes were expected, and vice versa. If this happens you can easily swap the order of the contributor models by using the Reorganize Contributors button. When pressing the button a dialog appears that lets you swap the order of the contributor models:

If the compare is three-way an ancestor contributor will also be shown here.

Close the dialog by pressing the Restart button to relaunch the compare session with reordered contributors.

Browse Button

The Browse button is a toggle button which, if pressed, switches the Compare user interface to a so called browse mode. In this mode only two compartments (three in case of three-way compare) are visible, one for each contributor model.

In the browse mode you can explore the contributor models in more detail than what is otherwise possible. Each compartment will show three tabs that let you explore the model in different ways:

Note that you can also explore the contributor models using the regular Properties view and Code view. See Exploring the Contributor Models to learn more about this.

Preferences Menu

The Preferences menu is located in the top-right corner of the Compare user interface. It contains a Preferences command that opens the preference page for Compare/Merge. The menu also repeats some of the commands from the toolbar.

Add Task

The Add Task button creates a Compare/Merge task for the change that is selected in the change list. You can for example use this as a means of reviewing changes in a model. See Compare/Merge Tasks for more information.

Save List of Changes

This button allows you to save the list of changes to a textual log file. You will be asked if you want to save only the changes that are currently visible (i.e. not the ones that are hidden because you have applied a filter), or if you want to save all the changes.

The dialog uses the term delta, which is just a fancy name for a change. See Delta Tree Configuration for more information about how the change list can be filtered.

Sub Compare Button

This button becomes enabled when you select a change in the change list that relates to a changed code snippet or documentation comment. Such changes are best explored using a textual sub compare session. See Sub Compare for more information about what this is.

For a code snippet that contains C++ code the default sub merge command is Compare As C++ Source File which means that the compare tool provided by CDT will be used for comparing the code snippets. However, you can also do the sub compare by choosing Compare As Text in the button menu. In this case the base text compare tool provided by Eclipse will be used.

If you choose Compare As… in the Sub Compare button menu a dialog appears that lets you choose both which tool to use for the sub compare, and also in which order the contributors should be set for the sub compare session:

Usually there is no reason to swap the contributors with this dialog since the default order is the same as is used for the corresponding left and right contributor models in the enclosing model compare session.

Next/Previous Buttons

You can use these buttons to go through the changes in the change list, as an alternative to clicking on the changes one by one.

Delta Tree Configuration

Sometimes the number of changes in the change list can be so large that it becomes impractical to show them all at the same time. In this case you can use the Delta Tree Configuration button to apply a filter so that some of the changes become hidden. If you press the button the following dialog appears:

The bottom drop down menus allow you to configure how to sort and structure the changes that are shown in the change list. The default sorting is to sort according to the number of dependent changes, so that changes that have many dependent changes appear before changes that have few dependent changes. See Dependent Changes for more information about what a dependent change is. You can also choose to sort by model element name, by the change description ("Delta Label") or not to sort at all. The default structuring of changes is "Hierarchy Structure" which means that changes are grouped into a hierarchy corresponding to the hierarchy of the changed model elements. There are several other alternatives for how to structure the change list, including "Flat Structure" which means that changes are not grouped at all but appear in a single flat list.

The Filters list shows all the different kinds of changes that may appear in the change list. See Types of Changes for more information about what the different kinds of changes mean. Note also that some filters simply work by filtering out all changes that are related to a certain kind of element, regardless of the type of changes:

It can also be useful to filter out all changes that are not related to code changes, by choosing “Show code changes only”.

You can create your own custom filter by pressing the Add button:

This dialog lets you create a filter that

For example, if you want to filter out all changes that relate to attributes that start with the prefix "He" you may create a filter with the meta-class "Property" selected in the lower list and with the following description pattern: He*

The Delta Tree Configuration button also has a button menu that lets you turn on or off filters quickly:

The commands in this button menu let you do the same kind of filtering, sorting and structuring of the change list as the Delta Tree Configuration dialog described above. In addition it contains a few other commands that affect what is shown in the change list:

Change List Compartment

The change list shows all (or a subset of, if a delta tree filter has been applied) the changes between the left and right contributor models. The changes are always presented as related to the left contributor model. For example, if the left contributor contains an attribute that the right contributor does not contain, the change list will contain an Add change for that attribute:

You can right-click on a change in the change list and perform the Navigate – Show in Project Explorer command in order to try to locate the changed model element in the model that is loaded in the Model RealTime workspace. Doing so can help you better understand the context of a particular change, but the navigation will of course only work if the changed element exists in the workspace model. Depending on the kind of changed element there may also be other useful navigation commands in the Navigate context menu. For example, if the changed element is shown on a diagram you can navigate to that diagram.

The description text for a change in the change list can sometimes be quite long. If the text is too long to fit in the change list compartment, you can look in the Model RealTime status bar which also shows the description of the selected change.

Another approach Model RealTime uses to avoid very long descriptions of changes is to put some of the information about the selected change in a separate text area. This text area is located just below the change list. For example, for the attribute shown in the picture above the text area will contain text that tells you what type the added attribute has:

Here we can see that the type of the added attribute is the primitive C++ type 'int'. There may also be a more detailed technical description of the change. For example, above we can see that the attribute "x" was added as one of the owned attributes of the capsule "HelloWorld". Note that this text area is by default hidden (to save user interface space). You can make it visible by means of the command Show description section in the Delta Tree Configuration button menu.

The changes shown in the change list compartment are by default grouped into a hierarchy. You may encounter the following groups of changes:

Note that grouping is also used within the top-level groups mentioned above. The purpose of such sub-groups is

If you prefer to not group changes into a hierarchy you can select "Flat Structure" in the Delta Tree Configuration button menu. In this menu you also have choices for sorting the list of changes.

In case of a three-way Compare session the change list compartment will have tabs that show three lists of changes:

Contributor Model Compartments

These two compartments show the left and right contributor models. When you select a change in the change list the changed element is highlighted in both the left and right contributor model in order to visualize the impact of the selected change. If the changed element does not exist in one of the contributors, the nearest container element is highlighted instead. Also, a line is drawn between the contributor models to indicate how they are related by the selected change. For example, if a change describes that an operation "doSmth" was added in the capsule "MyTopCapsule" in the left contributor model, the contributor model compartments may look like this:

The contributor model compartments provide different tabs in order to present the change in different ways. Depending on the type of change that is selected in the change list, different tabs will be available. Sometimes you may have to switch to a different tab to fully understand exactly what has changed. The following tabs are used:

In case of a three-way compare the Diagram tab has a button _Show Ancestor Diagram_ (![](images/show-ancestor.png)) in the upper right corner which allows the diagrams from the ancestor and the contributor models to be overlaid graphically. This can sometimes help you understand what was changed in the diagram.

In the case of a three-way compare (i.e., when a common ancestor model is available) there will be a button called "Show All Contributor Panes" in the upper right corner of the contributor model compartments. If you press this button you will see the common ancestor model in the middle between the contributor models. You will also see how each change in the contributor models relates to the common ancestor model by means of lines drawn between the compartments. It can for example look like this:

This extended view is possible to show only when doing a three-way compare, because then two sets of changes are computed by the Compare tool:

  1. The changes between the left contributor and the common ancestor.

  2. The changes between the right contributor and the common ancestor.

So if you are unsure whether you are actually doing a two-way or three-way compare, you can check if the "Show All Contributor Panes" button is visible or not. This information is also shown in the tooltip for the Compare editor: