| 43 |
</ul> |
</ul> |
| 44 |
</li> |
</li> |
| 45 |
<li><strong>ResourceTraversal</strong>: A <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/ResourceTraversal.java?rev=HEAD&content-type=text/vnd.viewcvs-markup"><code>ResourceTraversal</code></a> |
<li><strong>ResourceTraversal</strong>: A <a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.core.resources/src/org/eclipse/core/resources/mapping/ResourceTraversal.java?rev=HEAD&content-type=text/vnd.viewcvs-markup"><code>ResourceTraversal</code></a> |
| 46 |
simply contains a set of resources and a depth flag that indicates the depth |
contains a set of resources and a depth flag that indicates the depth to which |
| 47 |
to which the resources in the traversal are associated with the originating |
the resources in the traversal are associated with the originating model object. |
| 48 |
model object. Resource traversals are provided to a client by a resource mapping |
Resource traversals are provided to a client by a resource mapping in order |
| 49 |
in order to describe the contents of a model in sich a way that a repository |
to describe the contents of a model in such a way that the client (e.g a repository |
| 50 |
provider can perform its operations in as efficient a means as possible. Methods |
provider) can perform its operations in as efficient a means as possible. |
| 51 |
of interest are: |
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> |
| 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 benefitial. However, they are not required to do so if there |
| 74 |
is no benefit. For instance a Java class that now currently adapts to <code>IFile</code> |
is no benefit. For instance a Java compilation unit (i.e. *.java file shown |
| 75 |
need not adapt to <code>ResourceMapping</code> since nothing is gained. However, |
in a JDT view) that now currently adapts to <code>IFile</code> need not adapt |
| 76 |
a Java package should adapt to <code>ResourceMapping</code> in order to indicate |
to <code>ResourceMapping</code> since nothing is gained. However, a Java package |
| 77 |
that the package is only the files in the corresponding folder and not the subfolders.</p> |
should adapt to <code>ResourceMapping</code> in order to indicate that the package |
| 78 |
|
is only the files in the corresponding folder and not the subfolders.</p> |
| 79 |
<p>The preferred way to adapt model elements to a resource mapping is to use an |
<p>The preferred way to adapt model elements to a resource mapping is to use an |
| 80 |
adapter factory. The following is the XML markup for contributing an adapter |
adapter factory. The following is the XML markup for contributing an adapter |
| 81 |
factory in a plugin manifest. </p> |
factory in a plugin manifest. </p> |
| 94 |
} |
} |
| 95 |
}</pre> |
}</pre> |
| 96 |
<p>For popup menu contribuions, it is not required that the model objects implement |
<p>For popup menu contribuions, 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> |
| 135 |
contributions to <code>ResourceMapping</code> (for those for which this is |
contributions to <code>ResourceMapping</code> (for those for which this is |
| 136 |
appropriate).</li> |
appropriate).</li> |
| 137 |
<li>Update their actions to work on <code>ResourceMapping</code> instead of |
<li>Update their actions to work on <code>ResourceMapping</code> instead of |
| 138 |
IResource and respect the depth constraints provided in the traversals.</li> |
<code>IResource</code> and respect the depth constraints provided in the traversals.</li> |
| 139 |
<li>(Optional) provide a <code>ResourceMappingContext</code> if they manage |
<li>(Optional) provide a <code>ResourceMappingContext</code> if they manage |
| 140 |
remote resources (more on this <a href="#ResourceMappingContext">below</a>)</li> |
remote resources (more on this <a href="#ResourceMappingContext">below</a>)</li> |
| 141 |
</ol> |
</ol> |
| 142 |
<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> |
| 143 |
(CVS, Search, Compare) can now add them to <code>ResourceMapping</code> instead, |
(CVS, Search, Compare) can now add them to <code>ResourceMapping</code> instead, |
| 144 |
if the action can apply to multiple resources. Here is an XML snipet:</p> |
if the action can apply to multiple resources. Here is an XML snipet that contributes |
| 145 |
|
a menu action to objects that adapt to resource mappings:</p> |
| 146 |
<pre style="background-color: rgb(204, 204, 255);"> <extension<br> point="org.eclipse.ui.popupMenus"><br> <objectContribution<br> adaptable="true"<br> objectClass="org.eclipse.core.resources.mapping.ResourceMapping"<br> id="org.eclipse.example.library.ResourceMappingContributions"><br> <action<br> label="Show Resource Mappings"<br> class="org.eclipse.example.library.contributions.ShowResourceMappingsAction"<br> menubarPath="additions"<br> id="org.eclipse.example.library.showMappings"/> <br> </objectContribution><br> </extension></pre> |
<pre style="background-color: rgb(204, 204, 255);"> <extension<br> point="org.eclipse.ui.popupMenus"><br> <objectContribution<br> adaptable="true"<br> objectClass="org.eclipse.core.resources.mapping.ResourceMapping"<br> id="org.eclipse.example.library.ResourceMappingContributions"><br> <action<br> label="Show Resource Mappings"<br> class="org.eclipse.example.library.contributions.ShowResourceMappingsAction"<br> menubarPath="additions"<br> id="org.eclipse.example.library.showMappings"/> <br> </objectContribution><br> </extension></pre> |
| 147 |
<p>Contributions to <code>ResourceMapping</code> will automatically apply to objects |
<p>Contributions to <code>ResourceMapping</code> will automatically apply to objects |
| 148 |
that adapt to <code>IResource</code>. This transitive association is handled |
that adapt to <code>IResource</code>. This transitive association is handled |
| 149 |
by the Workbench.</p> |
by the Workbench.</p> |
| 150 |
<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 |
| 151 |
filters or expressions although expressions are perferrable. An expression for |
filters or expressions. An expression for filtering by project persistant property |
| 152 |
filtering by project persistant property has been added to allow repository |
has been added to allow repository providers to have their menus appear on projects |
| 153 |
providers to have their menus appear on projects that are mapped to their repositories.</p> |
that are mapped to their repositories.</p> |
| 154 |
<pre style="background-color: rgb(204, 204, 255);"> <extension<br> point="org.eclipse.ui.popupMenus"><br> <objectContribution<br> objectClass="org.eclipse.core.resources.mapping.ResourceMapping"<br> adaptable="true"<br> id="org.eclipse.team.ccvs.ui.ResourceMapperContributions"><br> <enablement><br> <adapt type="org.eclipse.core.resources.mapping.ResourceMapping"><br> <test |
<pre style="background-color: rgb(204, 204, 255);"> <extension<br> point="org.eclipse.ui.popupMenus"><br> <objectContribution<br> objectClass="org.eclipse.core.resources.mapping.ResourceMapping"<br> adaptable="true"<br> id="org.eclipse.team.ccvs.ui.ResourceMapperContributions"><br> <enablement><br> <adapt type="org.eclipse.core.resources.mapping.ResourceMapping"><br> <test |
| 155 |
property="org.eclipse.ui.ide.projectPersistentProperty" |
property="org.eclipse.ui.ide.projectPersistentProperty" |
| 156 |
args="org.eclipse.team.core.repository=org.eclipse.team.cvs.core.cvsnature" /><br> </adapt><br> </enablement><br> <action<br> label="%UpdateAction.label"<br> definitionId="org.eclipse.team.cvs.ui.update"<br> class="org.eclipse.team.internal.ccvs.ui.actions.UpdateAction"<br> tooltip="%UpdateAction.tooltip"<br> menubarPath="team.main/group2"<br> id="org.eclipse.team.cvs.ui.update"><br> </action> |
args="org.eclipse.team.core.repository=org.eclipse.team.cvs.core.cvsnature" /><br> </adapt><br> </enablement><br> <action<br> label="%UpdateAction.label"<br> definitionId="org.eclipse.team.cvs.ui.update"<br> class="org.eclipse.team.internal.ccvs.ui.actions.UpdateAction"<br> tooltip="%UpdateAction.tooltip"<br> menubarPath="team.main/group2"<br> id="org.eclipse.team.cvs.ui.update"><br> </action> |
| 185 |
be included when updating. However, the resources that constitute some logical |
be included when updating. However, the resources that constitute some logical |
| 186 |
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 |
| 187 |
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 |
| 188 |
mechanism). In order for the ResourceMapping to return the proper traversal, |
mechanism). In order for the resource mapping to return the proper traversal, |
| 189 |
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 differes from |
| 190 |
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 |
| 191 |
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 |
| 206 |
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 |
| 207 |
would not ned to make use of the resource mapping context. </p> |
would not ned to make use of the resource mapping context. </p> |
| 208 |
<p>As a more complicated example, consider an HTML file that contains several |
<p>As a more complicated example, consider an HTML file that contains several |
| 209 |
images. Let's mak the assumption that any images references from an HTML file |
images. Let's make the assumption that any images references from an HTML file |
| 210 |
ae part of the model of that file. When updating the local contents of the HTML |
are part of the model of that file. When updating the local contents of the |
| 211 |
file from a repository, the user would expect that any new images would be included. |
HTML file from a repository, the user would expect that any new images would |
| 212 |
The getTraversals method for a ResourceMapping for the HTML file model would |
be included. The <code>getTraversals</code> method for a <code>ResourceMapping</code> |
| 213 |
look something like this:</p> |
for the HTML file model would look something like this:</p> |
| 214 |
<pre style="background-color: rgb(204, 204, 255);">public class HTMLResourceMapping extends ResourceMapping { |
<pre style="background-color: rgb(204, 204, 255);">public class HTMLResourceMapping extends ResourceMapping { |
| 215 |
private HTMLFile htmlFile; |
private HTMLFile htmlFile; |
| 216 |
getTraversals(ResourceMappingContext context, IPorgressMonitor monitor) { |
getTraversals(ResourceMappingContext context, IPorgressMonitor monitor) { |
| 217 |
IResource[] resources = htmlFile.getRsources(); |
IResource[] resources = htmlFile.getResources(); |
| 218 |
if (context != null) { |
if (context != null) { |
| 219 |
// Look for any additional resources on the server |
// Look for any additional resources on the server |
| 220 |
IFile file = htmlFile.getFile(); |
IFile file = htmlFile.getFile(); |
| 231 |
<h4>When does a client need to provide a ResourceMappingContext?</h4> |
<h4>When does a client need to provide a ResourceMappingContext?</h4> |
| 232 |
<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 |
| 233 |
a repository and is supporting ResourceMappings should provide an appropriate |
a repository and is supporting ResourceMappings should provide an appropriate |
| 234 |
context for determining the relevant remote state o the model resources. The |
context for determining the relevant remote state of the model resources. The |
| 235 |
context provides three basic quieries:</p> |
context provides three basic quieries:</p> |
| 236 |
<ul> |
<ul> |
| 237 |
<li>Does the local contents differ from the remote contents</li> |
<li>Does the local contents differ from the remote contents</li> |