public abstract class RemoteResourceMappingContext extends ResourceMappingContext
This class may be subclassed by clients.
ResourceMapping
,
ResourceMappingContext
Modifier and Type | Field and Description |
---|---|
static int |
FILE_CONTENTS_REQUIRED
Refresh flag constant (bit mask value 1) indicating that the mapping will
be making use of the contents of the files covered by the traversals
being refreshed.
|
static int |
NONE
Refresh flag constant (bit mask value 0) indicating that no additional
refresh behavior is required.
|
LOCAL_CONTEXT
Constructor and Description |
---|
RemoteResourceMappingContext() |
Modifier and Type | Method and Description |
---|---|
abstract IStorage |
fetchBaseContents(IFile file,
IProgressMonitor monitor)
For three-way comparisons, returns an instance of IStorage in order to
allow the caller to access the contents of the base resource that
corresponds to the given local resource.
|
IResource[] |
fetchBaseMembers(IContainer container,
IProgressMonitor monitor)
Returns the members of the base resource corresponding to the given container.
|
abstract IResource[] |
fetchMembers(IContainer container,
IProgressMonitor monitor)
Returns the combined members of the base and remote resources corresponding
to the given container.
|
abstract IStorage |
fetchRemoteContents(IFile file,
IProgressMonitor monitor)
Returns an instance of IStorage in order to allow the caller to access
the contents of the remote that corresponds to the given local resource.
|
IResource[] |
fetchRemoteMembers(IContainer container,
IProgressMonitor monitor)
Returns the members of the remote resource corresponding to the given container.
|
abstract IProject[] |
getProjects()
Return the list of projects that apply to this context.
|
abstract boolean |
hasLocalChange(IResource resource,
IProgressMonitor monitor)
For three-way comparisons, this method indicates whether local
modifications have been made to the given resource.
|
abstract boolean |
hasRemoteChange(IResource resource,
IProgressMonitor monitor)
For two-way comparisons, return whether the contents of the corresponding
remote differs from the content of the local file in the context of the
current operation.
|
abstract boolean |
isThreeWay()
Return
true if the context is associated with an operation
that is using a three-way comparison and false if it is
using a two-way comparison. |
abstract void |
refresh(ResourceTraversal[] traversals,
int flags,
IProgressMonitor monitor)
Refresh the known remote state for any resources covered by the given
traversals.
|
public static final int FILE_CONTENTS_REQUIRED
public static final int NONE
public abstract IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException
null
is returned. The provided local file handle need not exist locally. A exception
is thrown if the corresponding base resource is not a file.
This method may be long running as a server may need to be contacted to obtain the contents of the file.
file
- the local filemonitor
- a progress monitor, or null
if progress
reporting is not desirednull
is returnedCoreException
- if the contents could not be fetched. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public IResource[] fetchBaseMembers(IContainer container, IProgressMonitor monitor) throws CoreException
null
if
the base members cannot be computed, in which case clients should call
fetchMembers(IContainer, IProgressMonitor)
which returns the
combined members for the base and remote.
This method may be long running as a server may need to be contacted to obtain the members of the base resource.
This default implementation always returns null
, but subclasses
may override.
container
- the local containermonitor
- a progress monitor, or null
if progress
reporting is not desiredCoreException
- if the members could not be fetched. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public abstract IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException
This method may be long running as a server may need to be contacted to obtain the members of the container's corresponding remote resource.
container
- the local containermonitor
- a progress monitor, or null
if progress
reporting is not desiredCoreException
- if the members could not be fetched. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public abstract IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException
null
is returned. The
provided local file handle need not exist locally. A exception is thrown
if the corresponding remote resource is not a file.
This method may be long running as a server may need to be contacted to obtain the contents of the file.
file
- the local filemonitor
- a progress monitor, or null
if progress
reporting is not desirednull
is returnedCoreException
- if the contents could not be fetched. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public IResource[] fetchRemoteMembers(IContainer container, IProgressMonitor monitor) throws CoreException
null
if
the remote members cannot be computed, in which case clients should call
fetchMembers(IContainer, IProgressMonitor)
which returns the
combined members for the base and remote.
This method may be long running as a server may need to be contacted to obtain the members of the remote resource.
This default implementation always returns null
, but subclasses
may override.
container
- the local containermonitor
- a progress monitor, or null
if progress
reporting is not desiredCoreException
- if the members could not be fetched. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public abstract IProject[] getProjects()
public abstract boolean hasLocalChange(IResource resource, IProgressMonitor monitor) throws CoreException
hasRemoteChange(IResource, IProgressMonitor)
.resource
- the resource being testedmonitor
- a progress monitorCoreException
- if the contents could not be compared. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public abstract boolean hasRemoteChange(IResource resource, IProgressMonitor monitor) throws CoreException
true
if the remote contents differ from the local
contents.
For three-way comparisons, return whether the contents of the
corresponding remote differ from the contents of the base. In other
words, this method returns true
if the corresponding
remote has changed since the last time the local resource was updated
with the remote contents.
For two-way comparisons, return true
if the remote
contents differ from the local contents. In this case, this method is
equivalent to hasLocalChange(IResource, IProgressMonitor)
This can be used by clients to determine if they need to fetch the remote
contents in order to determine if the resources that constitute the model
element are different in the remote location. If the local file exists
and the remote file does not, or the remote file exists and the local
does not then the contents will be said to differ (i.e. true
is returned). Also, implementors will most likely use a timestamp based
comparison to determine if the contents differ. This may lead to a
situation where true
is returned but the actual contents
do not differ. Clients must be prepared handle this situation.
resource
- the local resourcemonitor
- a progress monitor, or null
if progress
reporting is not desiredCoreException
- if the contents could not be compared. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public abstract boolean isThreeWay()
true
if the context is associated with an operation
that is using a three-way comparison and false
if it is
using a two-way comparison.public abstract void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException
Note that this is really only a hint to the context provider. It is up to
implementors to decide, based on the provided traversals, how to
efficiently perform the refresh. In the ideal case, calls to
hasRemoteChange(IResource, IProgressMonitor)
and
fetchMembers(org.eclipse.core.resources.IContainer, org.eclipse.core.runtime.IProgressMonitor)
would not need to contact the server after a call to a
refresh with appropriate traversals. Also, ideally, if
FILE_CONTENTS_REQUIRED
is on of the flags, then the contents
for these files will be cached as efficiently as possible so that calls to
fetchRemoteContents(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor)
will also not need to contact the server. This
may not be possible for all context providers, so clients cannot assume that
the above mentioned methods will not be long running. It is still advisable
for clients to call refresh(org.eclipse.core.resources.mapping.ResourceTraversal[], int, org.eclipse.core.runtime.IProgressMonitor)
with as much details as possible since, in
the case where a provider is optimized, performance will be much better.
traversals
- the resource traversals that indicate which resources
are to be refreshedflags
- additional refresh behavior. For instance, if
FILE_CONTENTS_REQUIRED
is one of the flags, this indicates
that the client will be accessing the contents of the files covered by
the traversals. NONE
should be used when no additional
behavior is requiredmonitor
- a progress monitor, or null
if progress
reporting is not desiredCoreException
- if the refresh fails. Reasons include:
Copyright (c) 2000, 2017 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.