Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java266
1 files changed, 133 insertions, 133 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
index 3df0805ad..b1f3d8817 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
@@ -45,126 +45,126 @@ import org.eclipse.team.internal.core.TeamPlugin;
*/
public class SubscriberResourceMappingContext extends RemoteResourceMappingContext {
- private final Subscriber subscriber;
+ private final Subscriber subscriber;
- // Lists used to keep track of resources that have been refreshed
- private Set<IResource> shallowRefresh = new HashSet<>();
- private Set<IResource> deepRefresh = new HashSet<>();
- private boolean autoRefresh;
+ // Lists used to keep track of resources that have been refreshed
+ private Set<IResource> shallowRefresh = new HashSet<>();
+ private Set<IResource> deepRefresh = new HashSet<>();
+ private boolean autoRefresh;
- /**
- * Return a resource mapping context suitable for comparison operations.
- * Comparisons require that any out-of-sync resources have contents
- * that differ.
- * @param subscriber the subscriber
- * @return a resource mapping context suitable for compare operations
- */
- public static RemoteResourceMappingContext createContext(Subscriber subscriber) {
- return new SubscriberResourceMappingContext(subscriber, true);
- }
+ /**
+ * Return a resource mapping context suitable for comparison operations.
+ * Comparisons require that any out-of-sync resources have contents
+ * that differ.
+ * @param subscriber the subscriber
+ * @return a resource mapping context suitable for compare operations
+ */
+ public static RemoteResourceMappingContext createContext(Subscriber subscriber) {
+ return new SubscriberResourceMappingContext(subscriber, true);
+ }
- /**
- * Create a resource mapping context for the given subscriber
- * @param subscriber the subscriber
- * from the local contents
- * @param autoRefresh whether the context should auto-refresh when queried
- */
- public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) {
- this.subscriber = subscriber;
- this.autoRefresh = autoRefresh;
- }
+ /**
+ * Create a resource mapping context for the given subscriber
+ * @param subscriber the subscriber
+ * from the local contents
+ * @param autoRefresh whether the context should auto-refresh when queried
+ */
+ public SubscriberResourceMappingContext(Subscriber subscriber, boolean autoRefresh) {
+ this.subscriber = subscriber;
+ this.autoRefresh = autoRefresh;
+ }
- @Override
+ @Override
public final boolean hasRemoteChange(IResource resource, IProgressMonitor monitor) throws CoreException {
- try {
+ try {
monitor.beginTask(null, 100);
ensureRefreshed(resource, IResource.DEPTH_ONE, NONE, monitor);
SyncInfo syncInfo = subscriber.getSyncInfo(resource);
validateRemote(resource, syncInfo);
- if (syncInfo == null) return false;
- int direction = SyncInfo.getDirection(syncInfo.getKind());
+ if (syncInfo == null) return false;
+ int direction = SyncInfo.getDirection(syncInfo.getKind());
return direction == SyncInfo.INCOMING || direction == SyncInfo.CONFLICTING;
} finally {
monitor.done();
}
- }
+ }
- @Override
+ @Override
public boolean hasLocalChange(IResource resource, IProgressMonitor monitor) throws CoreException {
- SyncInfo syncInfo = subscriber.getSyncInfo(resource);
- if (syncInfo == null) return false;
- int direction = SyncInfo.getDirection(syncInfo.getKind());
+ SyncInfo syncInfo = subscriber.getSyncInfo(resource);
+ if (syncInfo == null) return false;
+ int direction = SyncInfo.getDirection(syncInfo.getKind());
return direction == SyncInfo.OUTGOING || direction == SyncInfo.CONFLICTING;
- }
+ }
- @Override
+ @Override
public final IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException {
- try {
+ try {
monitor.beginTask(null, 100);
- ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10));
- SyncInfo syncInfo = subscriber.getSyncInfo(file);
- IResourceVariant remote = validateRemote(file, syncInfo);
- if (remote == null) {
- return null;
- }
- return remote.getStorage(Policy.subMonitorFor(monitor, 90));
+ ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10));
+ SyncInfo syncInfo = subscriber.getSyncInfo(file);
+ IResourceVariant remote = validateRemote(file, syncInfo);
+ if (remote == null) {
+ return null;
+ }
+ return remote.getStorage(Policy.subMonitorFor(monitor, 90));
} finally {
monitor.done();
}
- }
+ }
- @Override
+ @Override
public final IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException {
- try {
+ try {
monitor.beginTask(null, 100);
- ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10));
- SyncInfo syncInfo = subscriber.getSyncInfo(file);
- IResourceVariant base = validateBase(file, syncInfo);
- if (base == null) {
- return null;
- }
- return base.getStorage(Policy.subMonitorFor(monitor, 90));
+ ensureRefreshed(file, IResource.DEPTH_ZERO, FILE_CONTENTS_REQUIRED, Policy.subMonitorFor(monitor, 10));
+ SyncInfo syncInfo = subscriber.getSyncInfo(file);
+ IResourceVariant base = validateBase(file, syncInfo);
+ if (base == null) {
+ return null;
+ }
+ return base.getStorage(Policy.subMonitorFor(monitor, 90));
} finally {
monitor.done();
}
- }
+ }
- @Override
+ @Override
public final IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException {
- try {
+ try {
monitor.beginTask(null, 100);
- ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100));
- SyncInfo syncInfo = subscriber.getSyncInfo(container);
- if (validateRemote(container, syncInfo) == null) {
- // There is no remote so return an empty array
- return new IResource[0];
- }
- return subscriber.members(container);
+ ensureRefreshed(container, IResource.DEPTH_ONE, NONE, Policy.subMonitorFor(monitor, 100));
+ SyncInfo syncInfo = subscriber.getSyncInfo(container);
+ if (validateRemote(container, syncInfo) == null) {
+ // There is no remote so return an empty array
+ return new IResource[0];
+ }
+ return subscriber.members(container);
} finally {
monitor.done();
}
- }
+ }
- @Override
+ @Override
public final void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException {
- subscriber.refresh(traversals, monitor);
- for (int i = 0; i < traversals.length; i++) {
+ subscriber.refresh(traversals, monitor);
+ for (int i = 0; i < traversals.length; i++) {
ResourceTraversal traversal = traversals[i];
refreshed(traversal.getResources(), traversal.getDepth());
}
- }
+ }
- /**
- * Refresh the subscriber and cache the fact that the resources were refreshed by
- * calling the <code>refreshed</code> method. The default implementation only refreshes
- * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code>
- * flag is passed. It is up to subclass to handle this.
- * @param resources the resources to be refreshed
- * @param depth the depth of the refresh
- * @param flags the flags that indicate extra state that should be fetched
- * @param monitor a progress monitor
- * @throws TeamException
- */
+ /**
+ * Refresh the subscriber and cache the fact that the resources were refreshed by
+ * calling the <code>refreshed</code> method. The default implementation only refreshes
+ * the state and does not fetch contents in the <code>FILE_CONTENTS_REQUIRED</code>
+ * flag is passed. It is up to subclass to handle this.
+ * @param resources the resources to be refreshed
+ * @param depth the depth of the refresh
+ * @param flags the flags that indicate extra state that should be fetched
+ * @param monitor a progress monitor
+ * @throws TeamException
+ */
protected void refresh(IResource[] resources, int depth, int flags, IProgressMonitor monitor) throws TeamException {
subscriber.refresh(resources, depth, monitor);
refreshed(resources, depth);
@@ -189,32 +189,32 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte
}
}
- /*
- * Ensure that the given resource has been refreshed to the specified depth
- * since the context has been created.
- */
- private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException {
- if (autoRefresh) {
- if (depth == IResource.DEPTH_INFINITE) {
- // If the resource or a parent was refreshed deeply, no need to do it again
- if (wasRefreshedDeeply(resource))
- return;
- // if the resource is a file, a shallow refresh is enough
- if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource))
- return;
- } else {
- if (wasRefreshedShallow(resource))
- return;
- }
- refresh(new IResource[] { resource }, depth, flags, monitor);
- }
+ /*
+ * Ensure that the given resource has been refreshed to the specified depth
+ * since the context has been created.
+ */
+ private void ensureRefreshed(IResource resource, int depth, int flags, IProgressMonitor monitor) throws TeamException {
+ if (autoRefresh) {
+ if (depth == IResource.DEPTH_INFINITE) {
+ // If the resource or a parent was refreshed deeply, no need to do it again
+ if (wasRefreshedDeeply(resource))
+ return;
+ // if the resource is a file, a shallow refresh is enough
+ if (resource.getType() == IResource.FILE && wasRefreshedShallow(resource))
+ return;
+ } else {
+ if (wasRefreshedShallow(resource))
+ return;
+ }
+ refresh(new IResource[] { resource }, depth, flags, monitor);
+ }
}
- /*
- * Look for a shallow refresh of the resource. If not there,
- * look fir a deep refresh of a parent or a shallow refresh of the
- * direct parent if the resource is a file.
- */
+ /*
+ * Look for a shallow refresh of the resource. If not there,
+ * look fir a deep refresh of a parent or a shallow refresh of the
+ * direct parent if the resource is a file.
+ */
private boolean wasRefreshedShallow(IResource resource) {
if (shallowRefresh.contains(resource))
return true;
@@ -240,45 +240,45 @@ public class SubscriberResourceMappingContext extends RemoteResourceMappingConte
* Validate that the remote resource is of the proper type and return the
* remote resource if it is OK. A return of null indicates that there is no remote.
*/
- private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException {
- if (syncInfo == null) return null;
- IResourceVariant remote = syncInfo.getRemote();
- if (remote == null) return null;
- return validateRemote(resource, remote);
- }
+ private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException {
+ if (syncInfo == null) return null;
+ IResourceVariant remote = syncInfo.getRemote();
+ if (remote == null) return null;
+ return validateRemote(resource, remote);
+ }
private IResourceVariant validateRemote(IResource resource, IResourceVariant remote) throws CoreException {
boolean containerExpected = resource.getType() != IResource.FILE;
- if (remote.isContainer() && !containerExpected) {
- throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null));
- } else if (!remote.isContainer() && containerExpected) {
- throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null));
- }
- return remote;
+ if (remote.isContainer() && !containerExpected) {
+ throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_0 + resource.getFullPath().toString(), null));
+ } else if (!remote.isContainer() && containerExpected) {
+ throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, Messages.SubscriberResourceMappingContext_1 + resource.getFullPath().toString(), null));
+ }
+ return remote;
}
/*
* Validate that the base resource is of the proper type and return the
* base resource if it is OK. A return of null indicates that there is no base.
*/
- private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException {
- if (syncInfo == null) return null;
- IResourceVariant base = syncInfo.getBase();
- if (base == null) return null;
- return validateRemote(resource, base);
- }
+ private IResourceVariant validateBase(IResource resource, SyncInfo syncInfo) throws CoreException {
+ if (syncInfo == null) return null;
+ IResourceVariant base = syncInfo.getBase();
+ if (base == null) return null;
+ return validateRemote(resource, base);
+ }
- /**
- * Set whether the context should refresh the state of resources
- * when their state is requested. The context keeps track of what
- * resources were refreshed and only auto-refreshes a resource
- * once.
- * @param autoRefresh whether the context should refresh the state of resources
- * when their state is requested
- */
- public void setAutoRefresh(boolean autoRefresh) {
- this.autoRefresh = autoRefresh;
- }
+ /**
+ * Set whether the context should refresh the state of resources
+ * when their state is requested. The context keeps track of what
+ * resources were refreshed and only auto-refreshes a resource
+ * once.
+ * @param autoRefresh whether the context should refresh the state of resources
+ * when their state is requested
+ */
+ public void setAutoRefresh(boolean autoRefresh) {
+ this.autoRefresh = autoRefresh;
+ }
@Override
public boolean isThreeWay() {

Back to the top