public class SubscriberResourceMappingContext extends RemoteResourceMappingContext
SyncInfoFilter
to determine whether the local contents differ from the remote contents.
This allows the context to be used for different operations (check-in,
update and replace).FILE_CONTENTS_REQUIRED, NONE
LOCAL_CONTEXT
Constructor and Description |
---|
SubscriberResourceMappingContext(Subscriber subscriber,
boolean autoRefresh)
Create a resource mapping context for the given subscriber
|
Modifier and Type | Method and Description |
---|---|
boolean |
contentDiffers(IFile file,
IProgressMonitor monitor) |
static RemoteResourceMappingContext |
createContext(Subscriber subscriber)
Return a resource mapping context suitable for comparison operations.
|
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[] |
fetchMembers(IContainer container,
IProgressMonitor monitor)
Returns the combined members of the base and remote resources corresponding
to the given container.
|
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.
|
IProject[] |
getProjects()
Return the list of projects that apply to this context.
|
boolean |
hasLocalChange(IResource resource,
IProgressMonitor monitor)
For three-way comparisons, this method indicates whether local
modifications have been made to the given resource.
|
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.
|
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. |
protected void |
refresh(IResource[] resources,
int depth,
int flags,
IProgressMonitor monitor)
Refresh the subscriber and cache the fact that the resources were refreshed by
calling the
refreshed method. |
void |
refresh(ResourceTraversal[] traversals,
int flags,
IProgressMonitor monitor)
Refresh the known remote state for any resources covered by the given
traversals.
|
protected void |
refreshed(IResource[] resources,
int depth)
Record the fact that the resources have been refreshed to the given depth.
|
void |
setAutoRefresh(boolean autoRefresh)
Set whether the context should refresh the state of resources
when their state is requested.
|
fetchBaseMembers, fetchRemoteMembers
public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh)
subscriber
- the subscriber
from the local contentsautoRefresh
- whether the context should auto-refresh when queriedpublic static RemoteResourceMappingContext createContext(Subscriber subscriber)
subscriber
- the subscriberpublic final boolean hasRemoteChange(IResource resource, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
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 RemoteResourceMappingContext.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.
hasRemoteChange
in class RemoteResourceMappingContext
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 boolean hasLocalChange(IResource resource, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
RemoteResourceMappingContext.hasRemoteChange(IResource, IProgressMonitor)
.hasLocalChange
in class RemoteResourceMappingContext
resource
- the resource being testedmonitor
- a progress monitorCoreException
- if the contents could not be compared. Reasons
include:
IResourceStatus.RESOURCE_WRONG_TYPE
).public final IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
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.
fetchRemoteContents
in class RemoteResourceMappingContext
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 final IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
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.
fetchBaseContents
in class RemoteResourceMappingContext
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 final IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
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.
fetchMembers
in class RemoteResourceMappingContext
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 final void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException
RemoteResourceMappingContext
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
RemoteResourceMappingContext.hasRemoteChange(IResource, IProgressMonitor)
and
RemoteResourceMappingContext.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
RemoteResourceMappingContext.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
RemoteResourceMappingContext.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 RemoteResourceMappingContext.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.
refresh
in class RemoteResourceMappingContext
traversals
- the resource traversals that indicate which resources
are to be refreshedflags
- additional refresh behavior. For instance, if
RemoteResourceMappingContext.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. RemoteResourceMappingContext.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:
protected void refresh(IResource[] resources, int depth, int flags, IProgressMonitor monitor) throws TeamException
refreshed
method. The default implementation only refreshes
the state and does not fetch contents in the FILE_CONTENTS_REQUIRED
flag is passed. It is up to subclass to handle this.resources
- the resources to be refresheddepth
- the depth of the refreshflags
- the flags that indicate extra state that should be fetchedmonitor
- a progress monitorTeamException
protected final void refreshed(IResource[] resources, int depth)
resources
- the resources that were refresheddepth
- the depth to which the resources were refreshedpublic void setAutoRefresh(boolean autoRefresh)
autoRefresh
- whether the context should refresh the state of resources
when their state is requestedpublic boolean isThreeWay()
RemoteResourceMappingContext
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.isThreeWay
in class RemoteResourceMappingContext
public boolean contentDiffers(IFile file, IProgressMonitor monitor) throws CoreException
CoreException
public IProject[] getProjects()
RemoteResourceMappingContext
getProjects
in class RemoteResourceMappingContext
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.