Supporting Repository Operations on Logical Models

The purpose of this document is to present details of the solutions for the repository operation scenarios presented in Enabling Logical Model Integration in the Eclipse Platform.

Logical to Physical Mappings

A well integrated development environment should support 3rd party operations, such as repository provider operations, on UI model elements that map to the underlying Platform Resource model. Eclipse currently does support this for cases where there is a one-to-one mapping from a model element to a resource. However, to get full integration, one-to-many, and many-to-one should also be supported.

Performing Resource Based Operations on Logical Models

In order for resource based operations, such as repository operations, to be performed on logical models, a means to communicate resources that constitute the model elements is required. This is the purpose of the ResourceMapping API introduced in Eclipse 3.1 M5. This mapping supports a "one model element to many resource" mapping. The specifics of this support is outlined here.

The following points summarize how ResourceMappings are used to communicate the resources of a model element to a repository provider.

  1. Repository providers contribute menu operations to model elements through the Platform adaptable mechanism. The menu items will appear on any elements that adapt to ResourceMapping.
  2. When the user performs a repository operation on a model element, the contributed operation is handed the ResourceMappings obtained from the model elements.
  3. What happens next depends on what operation was chosen. For instance, a check-in (or commit) operation can use the resource mapping to check-in the appropriate files. Other operations can similarly be performed on the resources that constitute the model element.
  4. In some cases, the remote state of the model may contain additional resources. The ResourceMappingContext API is a way to allow the repository provider to communicate to the model provider the means to determine the remote state of the model so that all relevant resources can be included in the operation. For instance, an html file model may include the images shown on a page. If additional images are added to the remote state, operations such as update or merge would want to include the new images.

Once an operation is triggered, some operations may need to obtain additional input from the user or show operation feedback. Ideally, the information shown in dialogs or other views used to obtain information from or show information to the user should be consistent with the model from which the operation was launched or, in the very least, provide a link between the resources being operated on and the originating model elements. The following list outlines some of the different scenarios where this issue may occur:

Merging Logical Model Changes

One of the more complicated scenarios involving repository providers is when remote changes need to be merged with local changes. Here are the merge cases:

The interesting cases are the last two (i.e. merge involving model semantics and manual merge).

There are several complications that must be considered when formulating a solution:

A solution for presenting model based merges could take several forms:

The second approach is already supported by the compare framework and feels like a better approach. Hence, we will concentrate on that solution for the time being. Here is what this solution may involve:

The key here is that the model is in complete control of the merge of its model elements (i.e. the user may not even need to be aware of the underlying files).

Handling Many-to-One Mappings

Another interesting case involves the case where a single Platform resource contains several model elements. If the user selects a single model element and performs a repository operation on it, it will affect other model elements as well. This will be confusing to the user if they see other model elements being affected by an operation on one element. Here are some the scenarios involving this case:

Possible solutions to this problem are:

This problem has some overlap with the physical to logical problem which is covered in the "Physical to Logical" section, in the sense that, if a mechanism existed for finding all model elements from any model that are contained within a resource, this could be used as the API for the second point mentioned above.

Decorations

Decorating logical elements based on their resource mapping is problematic is some cases. The most interesting case is decorating elements to indicate that they have changed locally with respect to the repository. There are two aspects of this that are problematic:

  1. When a file contains many logical elements, only a few may be dirty when the file is dirty. However, they will all appear dirty if the file dirty state is used to determine the decoration. This can be overcome by allowing the model provider to determine model element dirty state by comparing the modified local file contents with that of the unmodified contents from the repository. Unfortunately, this requires that either the unmodified contents are cached or fetched from the server.
  2. When elements are shown in a tree, the resource mapping of a parent may not contain all the resource mappings of its children. This is due to the use of content providers in tree views that determine what the children of an element are in the tree. The only solution to this is to use model elements that contain the logic of determining their children and use a simple content provider that obtains the children from the model element. The problem with this approach is that it leads to model wrapping when alternate views are used (which is something the content provider API was supposed to solve).

 

Status

Here is the status of this work as of 3.1 M5

Open Issues

Here are the list of open issues: