| 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 |
| 205 |
action was performed.</p> |
action was performed.</p> |
| 206 |
<p>In order to support these more complex models, a <code>ResourceMappingContext</code> |
<p>In order to support these more complex models, a <code>RemoteResourceMappingContext</code> |
| 207 |
can be passed to the <code>ResourceMapping#getTraversals</code> method. When |
can be passed to the <code>ResourceMapping#getTraversals</code> method. When |
| 208 |
a context is provided, the mapping can use it to ensure that all the necessary |
a context is provided, the mapping can use it to ensure that all the necessary |
| 209 |
resources are included in the traversal. If a context is not provided, the mapping |
resources are included in the traversal. If a context is not provided, the mapping |
| 210 |
can assume that only the local state is of interest. </p> |
can assume that only the local state is of interest. </p> |
| 211 |
<h4>When does a ResourceMapping need to worry about the ResourceMappingContext?</h4> |
<h4>When does a ResourceMapping need to worry about the RemoteResourceMappingContext?</h4> |
| 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 |
| 227 |
private HTMLFile htmlFile; |
private HTMLFile htmlFile; |
| 228 |
getTraversals(ResourceMappingContext context, IPorgressMonitor monitor) { |
getTraversals(ResourceMappingContext context, IPorgressMonitor monitor) { |
| 229 |
IResource[] resources = htmlFile.getResources(); |
IResource[] resources = htmlFile.getResources(); |
| 230 |
if (context != null) { |
if (context instanceof RemoteResourceMappingContext) { |
| 231 |
// Look for any additional resources on the server |
// Look for any additional resources on the server |
| 232 |
|
RemoteResourceMappingContext remoteContext = (RemoteResourceMappingContext)context; |
| 233 |
IFile file = htmlFile.getFile(); |
IFile file = htmlFile.getFile(); |
| 234 |
if (context.contentDiffers(file, monitor) { |
if (remoteContext.contentDiffers(file, monitor) { |
| 235 |
IStorage storage = context.fetchContents(file, monitor); |
IStorage storage = remoteContext.fetchContents(file, monitor); |
| 236 |
IResource[] additionalResources = getReferences(storage.getContents()); |
IResource[] additionalResources = getReferences(storage.getContents()); |
| 237 |
resources = combine(resources, additionalResources); |
resources = combine(resources, additionalResources); |
| 238 |
|
|
| 249 |
should be included so that it will be fetched if it exists remotely. As for |
should be included so that it will be fetched if it exists remotely. As for |
| 250 |
the remote file, it may contain a new copy that references additional images |
the remote file, it may contain a new copy that references additional images |
| 251 |
that should be fetched when the new remote contents are downloaded.</p> |
that should be fetched when the new remote contents are downloaded.</p> |
| 252 |
<h4>When does a client need to provide a ResourceMappingContext?</h4> |
<h4>When does a client need to provide a RemoteResourceMappingContext?</h4> |
| 253 |
<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 |
| 254 |
a repository and is supporting ResourceMappings should provide an appropriate |
a repository and is supporting ResourceMappings should provide an appropriate |
| 255 |
context for determining the relevant remote state of the model resources. The |
context for determining the relevant remote state of the model resources. The |