Supporting Logical Models

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

Logical Model Support Problem Categorization

The logical resource problem can be broken down into three areas that involve the Eclipse Platform. These areas can be summarized as follows:

  1. The Eclipse Platform provides conceptually generic views that are Platform Resource model (i.e. IResource) specific.
  2. Tools, such as repository providers, that operate on the Platform Resource model should also be integrated with other models (logical to physical)
  3. Model tooling needs to be able to participate in certain Platform resource model changes in order to ensure model consistency (physical to logical)

The sections that follow explore each of these points in more detail.

Generic Views

The generic views problem is independent of the others problems in the sense that it can be solved without solving the other two and vica versa. The issue boils down to there being a view with a generic title, for example the Problems view, that only displays the problems from a single model (i.e. Platform Resources). This forces other models to either associate their problems with resources or create their own view. The main issue in generalizing these views is determining the best way to combine the problems, tasks or elements from multiple models in the same view. I can think of two ways to do this:

Each of these has their advantages and disadvantages. A single view frees the user from selecting which model to look at but such a view does not scale well. A paged view provides a means of top level filtering by model (advantage or disadvantage?) but can still have scalability issues.

The shape of the implementation of generic view support would depend on which approach to displaying multiple models was chosen and the nature of the view. The shape of the solutions in the area would really need to be driven by the product teams either in the form of scenarios and workflows or prototypes (or both).

Problems View

This view seems to be of most interest to modeling tools built on top of the Platform since it deals with helping the user correct model inconsistencies. For this reason, we will outline the beginnings of a possible solution here.

Based on several discussions on this topic, the following is a list of the desired properties of a generic Problems view.

Search View

The search view already has support for searches from different model domains. This comes in two forms:

Generic Navigator

There is work in the WTP project on a generic navigator and the rumor is that this may get pushed down to the Platform sometime after 3.1.

Bookmarks View

This is similar to the Problems view but is probably a bit simpler. Solutions to the problems view apply to this view as well.

Tasks View

The Tasks view is a bit more complicated. Currently, tasks are tied to resources just like problems and bookmarks so a similar solution could be applied to the Tasks view. However, one could easily argue that tasks could be associated with multiple resources (or no resources). This makes generalizing Task related concepts more difficult than that of problems and bookmarks.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=6904

Logical to Physical

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

Physical to Logical

In Eclipse, there can typically be many different model spaces. Many of these can be considered layers on top of the Platform resource model, in the sense that the elements that constitute a model are persisted in Platform resources. When operations are launched from model elements or are performed by model tooling, consistency of the model can be maintained. However, given the presence of multiple models and multiple layers, it is always possible that operations are launched from elsewhere (i.e. the tooling of ather models) and are not aware of all the models that could be affected. For instance, deleting a file from the Resource Navigator may corrupt a higher level model that was persisted, at least partially, in that file. In this case, all the model tooling can do is make a best effort at cleaning up and notify the user of any inconsistencies that may exist.

It would be beneficial if model tooling could participate in operations that could potentially corrupt a model. This participation could take many forms:

There are several complicating factors:

  1. The set of resource operations that can corrupt a model needs to be identified.
  2. At what level should the participation take place.
  3. There may be multiple models interested in a single resource.
  4. Augmenting an operation may result in further operations that again need to go through the participation process

It should be noted that the support required for physical-to-logical could potentially be used to help in the many-to-one mapping case as well.

Status

Here is the status of this work as of 3.1 M5

Open Issues

Here are the list of open issues: