platform-vcm-home/docs/online/team3.1/logical-physical-mappings.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8, Tue Feb 22 14:26:18 2005 UTC revision 1.9, Fri Feb 25 16:18:02 2005 UTC
# Line 46  Line 46 
46      contains a set of resources and a depth flag that indicates the depth to which      contains a set of resources and a depth flag that indicates the depth to which
47      the resources in the traversal are associated with the originating model object.      the resources in the traversal are associated with the originating model object.
48      Resource traversals are provided to a client by a resource mapping in order      Resource traversals are provided to a client by a resource mapping in order
49      to describe the contents of a model in such a way that the client (e.g a repository      to describe the contents of a model in such a way that the client (e.g. a
50      provider) can perform its operations in as efficient a means as possible.      repository provider) can perform its operations in as efficient a means as
51      Methods of interest are:      possible. Methods of interest are:
52      <ul>      <ul>
53        <li><code>getResources()</code></li>        <li><code>getResources()</code></li>
54        <li><code>getDepth()</code></li>        <li><code>getDepth()</code></li>
# Line 70  Line 70 
70  <p>Plugins that adapted their model objects to <code>IResource</code> in order  <p>Plugins that adapted their model objects to <code>IResource</code> in order
71    to get resource specific actions shown in the context menu can now adapt to    to get resource specific actions shown in the context menu can now adapt to
72    <code>ResourceMapping</code> if a richer description of how the object adapts    <code>ResourceMapping</code> if a richer description of how the object adapts
73    to resources is benefitial. However, they are not required to do so if there    to resources is beneficial. However, they are not required to do so if there
74    is no benefit. For instance a Java compilation unit (i.e. *.java file shown    is no benefit. For instance a Java compilation unit (i.e. *.java file shown
75    in a JDT view) that now currently adapts to <code>IFile</code> need not adapt    in a JDT view) that now currently adapts to <code>IFile</code> need not adapt
76    to <code>ResourceMapping</code> since nothing is gained. However, a Java package    to <code>ResourceMapping</code> since nothing is gained. However, a Java package
# Line 93  Line 93 
93        return new Class[] {ResourceMapping.class};        return new Class[] {ResourceMapping.class};
94     }     }
95  }</pre>  }</pre>
96  <p>For popup menu contribuions, it is not required that the model objects implement  <p>For popup menu contributions, it is not required that the model objects implement
97    the <code>IAdaptable</code> interface. However, if they do, they must ensure    the <code>IAdaptable</code> interface. However, if they do, they must ensure
98    that the Platform adapter manager is consulted. This can be done by either subclassing    that the Platform adapter manager is consulted. This can be done by either subclassing
99    <code>PlatformObject</code> or by using the following line of code:</p>    <code>PlatformObject</code> or by using the following line of code:</p>
100  <blockquote>  <blockquote>
101    <p><code>Platform.getAdapterManager().getAdapter(Object, Class)</code></p>    <p><code>Platform.getAdapterManager().getAdapter(Object, Class)</code></p>
102  </blockquote>  </blockquote>
103  <p>The above is the preferrable approach. However, the model object can implement  <p>The above is the preferable approach. However, the model object can implement
104    the IAdaptable interface and provide a <code>getAdapter(Class)</code> implementation    the IAdaptable interface and provide a <code>getAdapter(Class)</code> implementation
105    that creates returns an instance of <code>ResourceMapping</code> explicitly    that creates returns an instance of <code>ResourceMapping</code> explicitly
106    when asked for one. This is a more straightforward approach but the least desirable    when asked for one. This is a more straightforward approach but the least desirable
# Line 112  Line 112 
112    for this purpose. When objects are being adapted to <code>IResource</code> in    for this purpose. When objects are being adapted to <code>IResource</code> in
113    the context of object contributions, the workbench first tries to adapt the    the context of object contributions, the workbench first tries to adapt the
114    resource to <code>IContributorResourceAdapter</code> before trying to adapt    resource to <code>IContributorResourceAdapter</code> before trying to adapt
115    to <code>IResource</code> directly. A new sub-iterface of this interface, <code>IContributorResourceAdapter2</code>,    to <code>IResource</code> directly. A new sub-interface of this interface, <code>IContributorResourceAdapter2</code>,
116    has been added which provides the same capability for <code>ResourceMapping</code>.    has been added which provides the same capability for <code>ResourceMapping</code>.
117    The only difference is that the model provider shoudl register a factory for<code>    The only difference is that the model provider should register a factory for<code>
118    IContributorResourceAdapter</code> since the Workbench does an <em>instanceof</em>    IContributorResourceAdapter</code> since the Workbench does an <em>instanceof</em>
119    check to see if the contributed adapter is also an instance of <code>IContributorResourceAdapter2</code>.</p>    check to see if the contributed adapter is also an instance of <code>IContributorResourceAdapter2</code>.</p>
120  <p>The implementation of the <code>ResourceMapping</code> subclass for a Java  <p>The implementation of the <code>ResourceMapping</code> subclass for a Java
# Line 135  Line 135 
135        }        }
136     }     }
137  }</pre>  }</pre>
138  <p>This is a fairly straightforward mapping so the implementaion is not complex.  <p>This is a fairly straightforward mapping so the implementation is not complex.
139    The complexity of the resource mapping implementation will, of course, vary    The complexity of the resource mapping implementation will, of course, vary
140    from model to model. The <code>EMFResourceMapping</code> example used above    from model to model. The <code>EMFResourceMapping</code> example used above
141    is implemented in the example and it a much more complicated implementation.</p>    is implemented in the example and it a much more complicated implementation.</p>
# Line 153  Line 153 
153  </ol>  </ol>
154  <p>First of all, plugins that add object contributions to <code>IResource</code>  <p>First of all, plugins that add object contributions to <code>IResource</code>
155    (CVS, Search, Compare) can now add them to <code>ResourceMapping</code> instead,    (CVS, Search, Compare) can now add them to <code>ResourceMapping</code> instead,
156    if the action can apply to multiple resources. Here is an XML snipet that contributes    if the action can apply to multiple resources. Here is an XML snippet that contributes
157    a menu action to objects that adapt to resource mappings:</p>    a menu action to objects that adapt to resource mappings:</p>
158  <pre style="background-color: rgb(204, 204, 255);">   &lt;extension<br>       point=&quot;org.eclipse.ui.popupMenus&quot;&gt;<br>       &lt;objectContribution<br>            adaptable=&quot;true&quot;<br>            objectClass=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;<br>            id=&quot;org.eclipse.example.library.ResourceMappingContributions&quot;&gt;<br>         &lt;action<br>               label=&quot;Show Resource Mappings&quot;<br>               class=&quot;org.eclipse.example.library.contributions.ShowResourceMappingsAction&quot;<br>               menubarPath=&quot;additions&quot;<br>               id=&quot;org.eclipse.example.library.showMappings&quot;/&gt;         <br>        &lt;/objectContribution&gt;<br>   &lt;/extension&gt;</pre>  <pre style="background-color: rgb(204, 204, 255);">   &lt;extension<br>       point=&quot;org.eclipse.ui.popupMenus&quot;&gt;<br>       &lt;objectContribution<br>            adaptable=&quot;true&quot;<br>            objectClass=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;<br>            id=&quot;org.eclipse.example.library.ResourceMappingContributions&quot;&gt;<br>         &lt;action<br>               label=&quot;Show Resource Mappings&quot;<br>               class=&quot;org.eclipse.example.library.contributions.ShowResourceMappingsAction&quot;<br>               menubarPath=&quot;additions&quot;<br>               id=&quot;org.eclipse.example.library.showMappings&quot;/&gt;         <br>        &lt;/objectContribution&gt;<br>   &lt;/extension&gt;</pre>
159  <p>Contributions to <code>ResourceMapping</code> will automatically apply to objects  <p>Contributions to <code>ResourceMapping</code> will automatically apply to objects
160    that adapt to <code>IResource</code>. This transitive association is handled    that adapt to <code>IResource</code>. This transitive association is handled
161    by the Workbench.</p>    by the Workbench.</p>
162  <p>Filtering of the contributions to resource mappings can be done using action  <p>Filtering of the contributions to resource mappings can be done using action
163    filters or expressions. An expression for filtering by project persistant property    filters or expressions. An expression for filtering by project persistent property
164    has been added to allow repository providers to have their menus appear on projects    has been added to allow repository providers to have their menus appear on projects
165    that are mapped to their repositories.</p>    that are mapped to their repositories.</p>
166  <pre style="background-color: rgb(204, 204, 255);">   &lt;extension<br>       point=&quot;org.eclipse.ui.popupMenus&quot;&gt;<br>      &lt;objectContribution<br>            objectClass=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;<br>            adaptable=&quot;true&quot;<br>            id=&quot;org.eclipse.team.ccvs.ui.ResourceMapperContributions&quot;&gt;<br>             &lt;enablement&gt;<br>           &lt;adapt type=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;&gt;<br>              &lt;test  <pre style="background-color: rgb(204, 204, 255);">   &lt;extension<br>       point=&quot;org.eclipse.ui.popupMenus&quot;&gt;<br>      &lt;objectContribution<br>            objectClass=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;<br>            adaptable=&quot;true&quot;<br>            id=&quot;org.eclipse.team.ccvs.ui.ResourceMapperContributions&quot;&gt;<br>             &lt;enablement&gt;<br>           &lt;adapt type=&quot;org.eclipse.core.resources.mapping.ResourceMapping&quot;&gt;<br>              &lt;test
# Line 177  Line 177 
177    resource and the depth as input into an operation that the action delegates    resource and the depth as input into an operation that the action delegates
178    to do the work. As an example, if the user performs a CVS update on a java package    to do the work. As an example, if the user performs a CVS update on a java package
179    and the java package resource mapping maps to a folder of depth one, CVS would    and the java package resource mapping maps to a folder of depth one, CVS would
180    issue an appropriat command (&quot;cvs update -l&quot; for those who are curious)    issue an appropriate command (&quot;cvs update -l&quot; for those who are curious)
181    which would perform a shallow update on the folder the pakcage represents.</p>    which would perform a shallow update on the folder the package represents.</p>
182  <h3><a name="ResourceMappingContext"></a>Resource Mapping Context</h3>  <h3><a name="ResourceMappingContext"></a>Resource Mapping Context</h3>
183  <p>One of the advantages of a Resouce Mapping API is that it allows plug-ins to  <p>One of the advantages of a Resource Mapping API is that it allows plug-ins
184    implement any operations they desire in terms of resource mappings (e.g. CVS    to implement any operations they desire in terms of resource mappings (e.g.
185    update, CVS commit, CVS tag, dirty decoration, etc.). However, the API that    CVS update, CVS commit, CVS tag, dirty decoration, etc.). However, the API that
186    has been introduced so far deals only with the local state of the model. When    has been introduced so far deals only with the local state of the model. When
187    working with a model that may be shared between developers, you end up in a    working with a model that may be shared between developers, you end up in a
188    situation where the remote state of the model (i.e. the state of the model that    situation where the remote state of the model (i.e. the state of the model that
# Line 198  Line 198 
198    models may change over time. For instance, the resources that constitute a model    models may change over time. For instance, the resources that constitute a model
199    element may depend of the contents of a manifest file (or some other similar    element may depend of the contents of a manifest file (or some other similar
200    mechanism). In order for the resource mapping to return the proper traversal,    mechanism). In order for the resource mapping to return the proper traversal,
201    it must access the remote contents of the manifest file (if it differes from    it must access the remote contents of the manifest file (if it differs from
202    the local contents) in order to see if there are additional resources that need    the local contents) in order to see if there are additional resources that need
203    to be included. These additional resources may not exist in the workspace but    to be included. These additional resources may not exist in the workspace but
204    the repository provider would know how to make sure they did when the selected    the repository provider would know how to make sure they did when the selected
# Line 212  Line 212 
212  <p>A <code>ResourceMapping</code> need only worry about a context supplied to  <p>A <code>ResourceMapping</code> need only worry about a context supplied to
213    the <code>getTraversals</code> method in cases were the resources that make    the <code>getTraversals</code> method in cases were the resources that make
214    up a model change over time and the relationship between the model and resources    up a model change over time and the relationship between the model and resources
215    cannot be described by a simple traversal that is gauranteed to encompass those    cannot be described by a simple traversal that is guaranteed to encompass those
216    resources (and only those resources) that consitute the model. For example,    resources (and only those resources) that constitute the model. For example,
217    although the resources of a Java package may change over time, the package can    although the resources of a Java package may change over time, the package can
218    be described as a folder of depth of one so a resource mapping for java packages    be described as a folder of depth of one so a resource mapping for java packages
219    would not ned to make use of the resource mapping context. </p>    would not ned to make use of the resource mapping context. </p>
# Line 241  Line 241 
241    
242     }<br>}</pre>     }<br>}</pre>
243  <p>Notice that there are two sets of resources included in the model: those derived  <p>Notice that there are two sets of resources included in the model: those derived
244    from the local contents of the HTML file in the worspace and the contents of    from the local contents of the HTML file in the workspace and the contents of
245    the file remotely. In either of these two sets, there may be resources that    the file remotely. In either of these two sets, there may be resources that
246    do not exist in the workspace. For instance, the local HTML file may contain    do not exist in the workspace. For instance, the local HTML file may contain
247    a relative link to an image that does not exist in the workspace. This resource    a relative link to an image that does not exist in the workspace. This resource
# Line 252  Line 252 
252  <p>Any client that is providing the ability of sharing workspace resources through  <p>Any client that is providing the ability of sharing workspace resources through
253    a repository and is supporting ResourceMappings should provide an appropriate    a repository and is supporting ResourceMappings should provide an appropriate
254    context for determining the relevant remote state of the model resources. The    context for determining the relevant remote state of the model resources. The
255    context provides three basic quieries:</p>    context provides three basic queries:</p>
256  <ul>  <ul>
257    <li>Does the local contents differ from the remote contents</li>    <li>Does the local contents differ from the remote contents</li>
258    <li>What are the remote contents of a file</li>    <li>What are the remote contents of a file</li>
259    <li>What are the remote memebers of a folder</li>    <li>What are the remote members of a folder</li>
260  </ul>  </ul>
261  <p>The answer to the first question above depends on the type of operation that  <p>The answer to the first question above depends on the type of operation that
262    is being performed:</p>    is being performed:</p>
# Line 281  Line 281 
281    generated by EMF. It requires Eclipse 3.1 M5 and EMF SDK 2.0.1.</p>    generated by EMF. It requires Eclipse 3.1 M5 and EMF SDK 2.0.1.</p>
282  <p> The model is persisted in several types of files:</p>  <p> The model is persisted in several types of files:</p>
283  <ul>  <ul>
284    <li>*.library files which contain the name of a library and one ofr more book    <li>*.library files which contain the name of a library and one or more book
285      copy records which reference a bokk and indicate the number of copies of the      copy records which reference a book and indicate the number of copies of the
286      book the libraries contain.</li>      book the libraries contain.</li>
287    <li>*.books files which contain one or more books. Each book has serveral properties    <li>*.books files which contain one or more books. Each book has several properties
288      (name, number of pages, etc.) as well as a reference to the book's author.</li>      (name, number of pages, etc.) as well as a reference to the book's author.</li>
289    <li>*.writers files which contain one or more writers. Each writer has properties    <li>*.writers files which contain one or more writers. Each writer has properties
290      (e.g. name) as weel as references to one or more books that have been authored      (e.g. name) as well as references to one or more books that have been authored
291      by the writer.</li>      by the writer.</li>
292  </ul>  </ul>
293  <p>The following screenshot shows an example Library.</p>  <p>The following screenshot shows an example Library.</p>
# Line 296  Line 296 
296  <ul>  <ul>
297    <li>My.writers: contains &quot;Bob&quot;</li>    <li>My.writers: contains &quot;Bob&quot;</li>
298    <li>My.books: contains &quot;The Life of Bob&quot;</li>    <li>My.books: contains &quot;The Life of Bob&quot;</li>
299    <li>mylib.library: contains copeis of the &quot;Life of Bob&quot;</li>    <li>mylib.library: contains copies of the &quot;Life of Bob&quot;</li>
300  </ul>  </ul>
301  <p>For the purposes of this example, model containment is determined by following  <p>For the purposes of this example, model containment is determined by following
302    all the references from the file containing the selected model element to all    all the references from the file containing the selected model element to all
# Line 304  Line 304 
304    would be My.writers, since Bob is contained in that file, and My.books since    would be My.writers, since Bob is contained in that file, and My.books since
305    Bob wrote a book in that book catalog. The resources associated with the Main    Bob wrote a book in that book catalog. The resources associated with the Main
306    Library would be mylib.library, My.books, since the library contains a book    Library would be mylib.library, My.books, since the library contains a book
307    from that catalog, and My.writers, since the it contains Bob, the auther of    from that catalog, and My.writers, since the it contains Bob, the author of
308    that book.</p>    that book.</p>
309  <p>There are three files of interest in the example code, all of them in the org.eclipse.team.examples.library.adapt  <p>There are three files of interest in the example code, all of them in the org.eclipse.team.examples.library.adapt
310    plugin.</p>    plugin.</p>
311  <ul>  <ul>
312    <li><em>org.eclipse.team.examples.library.adapt/plugin.xml</em>: containes the    <li><em>org.eclipse.team.examples.library.adapt/plugin.xml</em>: contains the
313      adapter factory registration and an object contribution to <code>ResourceMapping</code>.</li>      adapter factory registration and an object contribution to <code>ResourceMapping</code>.</li>
314    <li><em>org.eclipse.team.examples.library.adapt/src/org/eclipse/team/examples/library/adapt/EMFResourceMapping</em>:    <li><em>org.eclipse.team.examples.library.adapt/src/org/eclipse/team/examples/library/adapt/EMFResourceMapping</em>:
315      The resource mapping from the Library model to resources. This is basically      The resource mapping from the Library model to resources. This is basically
316      a worst-case mapping that uses EMF to traverse the modle for file references.      a worst-case mapping that uses EMF to traverse the model for file references.
317      Read the class javadoc for more information.</li>      Read the class javadoc for more information.</li>
318    <li><em>org.eclipse.team.examples.library.adapt/src/org/eclipse/team/examples/library/adapt/ShowResourceMappingsAction</em>:    <li><em>org.eclipse.team.examples.library.adapt/src/org/eclipse/team/examples/library/adapt/ShowResourceMappingsAction</em>:
319      The action that shows the resource mapping. At the time of writting it uses      The action that shows the resource mapping. At the time of writing it uses
320      internal Team UI classes but the intention is to make these classes (or at      internal Team UI classes but the intention is to make these classes (or at
321      least the funtionality they provide) API in 3.1.</li>      least the functionality they provide) API in 3.1.</li>
322  </ul>  </ul>
323  <p>There is also a read-me file (<em>org.eclipse.team.examples.library.adapt/readme.html</em>)  <p>There is also a read-me file (<em>org.eclipse.team.examples.library.adapt/readme.html</em>)
324    that contains instructions on how to use the example. </p>    that contains instructions on how to use the example. </p>
# Line 368  Line 368 
368    that a model may not make use of the context to determine which resource should    that a model may not make use of the context to determine which resource should
369    be included in the mapping. In either case, this is only an issue for models    be included in the mapping. In either case, this is only an issue for models
370    that may add or remove resources at the root level. In reality, the number of    that may add or remove resources at the root level. In reality, the number of
371    these cases may be small bu the effects will be noticable since operations may    these cases may be small but the effects will be noticeable since operations
372    exclude resources. These cases can be handled by falling back to operations    may exclude resources. These cases can be handled by falling back to operations
373    on the resources themselves.<br>    on the resources themselves.<br>
374  </p>  </p>
375  </body>  </body>

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9