Eclipse 3.0 - Plan item

Support Logical Resources

This document outlines the state of the Eclipse Platform Support Logical Resources plan item. Interested parties should review this document and verify that their use cases are reflected in the requirements then later that the solution provided satisfies their needs. Feedback is strongly encouraged and may be provided on the platform-vcm-dev mailing list or in the bug report for this plan item.

This is the plan item:

"The Eclipse Platform supports a strong physical view of projects, files, and folders in the workspace. However, there are many situations where a physical view is not the most salient or useful for many purposes. In some cases, multiple distinct objects happen to be stored in a single file, like an archive. Conversely, in other cases, something that is logically a single object is stored across multiple files. This discrepancy between logical and physical creates problems for common operations such as searching, comparing, and versioning, which need to work in the physical realm. Eclipse should support some way of mapping between a logical view and the physical organization of files on disk."

Last Modified: July 2nd, 2003


By definition Eclipse supports logical resources. It's a "an open extensible IDE for anything and nothing in particular". The applications that are built with it can be tailored to a particular problem domain and the workbench extensions can be used to provide support for the logical model. What Eclipse really doesn't support is integrating tools at the logical model. It's simple, to integrate two plugins into Eclipse either plugin A and B have to know about each other, or both plugins have to depend on some common plugin. While the first option is satisfactory for a few cases, the second case is the most common and the most problematic. To illustrate, the Eclipse SDK contains several plugins that are based on the Resources plugin (e.g. Team, Search, Compare, JDT). When an application is packaged based on the SDK, because the plugins in the SDK are resource based it isn't possible to integrate plugins at the logical level.

As you will see later, even the users of the SDK (JDT+CVS+Resources) can observe some of the problems associated with the lack of support for logical resources and the implicit mapping to physical resources. The lack of a logical integration point causes the co-existance of plugins in Eclipse to be error prone for the user. The next sections will examine the relationships between logical and physical resources and outline the visible problems with Eclipse 2.1.

Existing Bugs

Bug 32582 logical to physical mapping problem , 1 model element = 2 Files problem
Bug 3979 [CVS Decorator] show version info works incorrectly for sub packages (1GFDIEB)

Logical Resources

Whereas logical resources are elements of the application that model the data/processes of a particular problem domain, the physical resources are the file system resources (e.g. files and folders) into which an application will eventually transform their application model for storage. Applications that don't use file system resources are not being considered as part of this plan item. For example, an application that stores it's application data directly into a database.

The following table enumerates concrete examples of how logical and physical resources are used in current applications integrated into Eclipse.

Table 1: Example logical to physical uses


logical (1) <-> (*) physical

one logical to many physical

(1a) EJB maps to several physical files: (WSAD + XDE Tester). This is the most common case we have found.


Note: If one of the logical resource's files was deleted who would remember that the file used to exist and is an outgoing deletion or that there is an incoming addition to the logical resource?

(1b) Composite Object (logical) maps to several changed physical resources. (Rational XDE)

Note: With 1 to many relationship there is always the complication that arises if the logical element maps to files in an other project? This would cause many problems in the current Team plugin.

logical (*) <-> (1) physical

many logical to one physical

(2a) Methods in a class map to their containing class file. (JDT)

(2b) Archive files (zip, jar) can be seen as a logical and the contents of the archive all map to the same physical.(JTD + all)

logical (1) <-> (1) physical

one logical to one physical

(3a) A Java Package maps to a folder but a package does not include sub folders (e.g. they are shallow). (JDT)

(3b) A UML class maps to a file. For example, in a UML application a class could be stored in a single file called 'x435dsds.umlclass'. The reason it's a logical is that the user of the application will never be concerned about the actual file name or even the folder it's stored in. (XDE)

Not very adaptable

Object contributions and decorators are key mechanisms for providing rich integration between tools. Using object contributions and adaptable objects, any plugin can provide actions and decorators that will show in another plugin's view.

Since IResource is the lowest common integration class and is strongly mapped to its physical storage as files and folders, the integration point for actions and decorators cannot be the logical types in the view. The actions will consequently use the adaptable type from the selection to perform the action or the decorator the resource from the getImage request.

Here is an example to illustrate the problem with the CVS plugin. When running a CVS commit action in the packages view the action doesn't know that the IFolder is a Java package and is a shallow namespace. It will use the selection and traverse the selected IContainer using IContainer.members() and commit all child resources. This is the same when the CVS outgoing decorator is shown on a package. It will reflect the deep outgoing state of the IContainer. This can lead to unexpected behavior because the user expected the action to run on the model that the action was displayed on.

Example object contribution for the CVS commit action:

<extension point="org.eclipse.ui.popupMenus">
tooltip="Commit resource to CVS repository"
</action> <objectContribution> </extension>

Example code run in the commit action to calculate the resources to commit:

public static Object[] getSelectedAdaptables(ISelection selection)    {
  ArrayList result = null;
  if (!selection.isEmpty()) {
    result = new ArrayList();
    Iterator elements = ((IStructuredSelection) selection).iterator();
    while (elements.hasNext()) {
      Object adapter = getAdapter(, IResource.class);
      if (c.isInstance(adapter)) {
   if (result != null && !result.isEmpty()) {
   return (Object[])result.toArray((Object[])Array.newInstance(IResource.class, result.size()));
  return (Object[])Array.newInstance(IResource.class, 0);

Example code for defining an IResource adaptable decorator:

    <decorator objectClass="org.eclipse.core.resources.IResource"
     lightweight= "true"
     quadrant = "BOTTOM_RIGHT"


When the CVS decorator decorates a logical container in a view, the desire is to decorate parents with the dirty indicator if one or more of their logical children are dirty. To do this properly, the decorator would need to query the dirty status of each of the logical children of the container. This can be a costly operation as each child may itself be a logical container. We have optimized the dirty decoration by caching folder dirty states. This optimization becomes far more complicated with logical models where the caching must be based on this alternate model (i.e. the state must be cached for each model).

In addition, often decorators rely on IResource change events to re-calculate some new state. In the case of a logical elements representing several physical resources there is no easy way of associated a IResource change event to its files and the actual logical element.


It would be nice to see the Java logical view in the Synchronize view or the CVS Repositories View. However, the entries in these views may not be IResources so an IResource independent mapping mechanism would be required. This could be a considerable amount if work for anyone providing a logical model. This problem is partly being addressed by the introduction of customizable content providers as described in the Generic Navigator item.

Also if an action prompts the user, for example to add resources to CVS, what icons and labels are used in the dialog? It would be nice to show those that are most familiar to the user.

Change Sets

Consider a user's action as a logical change, for example, the user renames a class using the JDT refactoring action. In the user's mind he 'renamed a class' and as a result there has been many other file changes. Currently there is not way of capturing these logical actions and associating the set of affected resources. This problem manifests itself more in tools where almost every change to the model has side effects.

File based tools

Some tools that integrate into Eclipse are file based and don't use IResources. And thus wouldn't be able to operation logical elements.

Proposed Solution

Part of the solution is to introduce a logical resource element that can be the basis for integration between plugins. Our proposed solution will attempt to solve the most common uses described in Table1, namely examples 1a, 1b and 3a. The generic navigator plan item should address the 2b and 3b examples by providing extensions that would allow a logical model to be available to other plugins for display purposes. Finally, 2a is currently solved with the existing IResource adapter mechanism.

Naturally another possible solution would be to change IResource to not be analogous to file system resources. However this scope of change is beyond the 3.0 timeframe and would cause, in my opinion, non-justifiable breaking changes to all plugins.


An interface will be added to the Resources plugin that will allow binding logical elements to physical ones. The interface is purposely simple with logical model manipulations ommitted. A client can't use this interface to display logical models or gain any interesting additional knowledge about it. In fact, the only way that a plugin will be able to gain access to the model for those purposes, would be via the navigator extensions proposed in the generic nagivator plan item.

Current plugins that add object contributions to IResource (CVS, Search, Compare) would have to also add them to ILogicalResource and honour the biddings provided by the logical resource. Moreover, the plugins that adapted to IResource to these object contributions shown in the context menu should no longer adapt the IResource and instead implement ILogicalResource.

  /** * A logical resource is an element of an application that 
 models the * data/processes of a particular problem domain. Eventually a 
 logical resource * must transform the application model for storage using a 
 file system

 * resource. * This class provides the bridge between a logical element and 
 the physical * resource(s) into which it is stored. On the other hand it
 doesn't provide * hierarchical access to the
 model. * *
IResource */ public interface ILogicalResource {
	 * Returns the project which contains this logical resource.

	 * This is a resource handle operation; neither the resource 
	 * nor the resulting project need exist.
	 * @return the project handle
	public IProject getProject();
	 * Returns the file system resource(s) for this logical resources. The
	 * returned resources must be contained within the same project.
	 * A logical element should return the same list of resources regardless
	 * of the existance of the files on the file system. For example, if a
	 * logical resource called "form" maps to "/p1/form.xml" and "/p1/"
    * then whether form.xml or existed, they should be returned
    * by this method.
	 * The traversal of the returned IResources should be done considering
	 * the isDeep flag. If a logical resource maps to a folder
	 * then the folder's child resources can only be visited if the folder is
	 * deep.
	public IResource[] getPhysicalResources();
	 * Optimization check for tools that should not run operations that traverse
	 * into child folders.
	 * @return 
	public boolean isDeep();


- ObjectContributions have to be duplicated in the plugins that would like to provide both contributions for IResource and ILogicalResource.

- Logical classes (e.g. java model, UML) have to implement the interface instead of adapting to it. This is a limitation of the current objectContribution story in the workbench.

- Plugins that add object contributions will have to modify their actions to handle logical resources. There should be some standard UI components for showing the mappings. For instance you could show the logical model at the top and in a details part the physical files/folders that will be affected by the operation.