diff options
Diffstat (limited to 'bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java')
-rw-r--r-- | bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java | 144 |
1 files changed, 72 insertions, 72 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java index f202ca6e3..04b85e69f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/subscribers/SubscriberResourceCollector.java @@ -32,19 +32,19 @@ import org.eclipse.team.core.subscribers.Subscriber; */ public abstract class SubscriberResourceCollector implements IResourceChangeListener, ISubscriberChangeListener { - Subscriber subscriber; - - /** - * Create the collector and register it as a listener with the workspace - * and the subscriber. - * @param subscriber the subscriber to be associated with this collector - */ - public SubscriberResourceCollector(Subscriber subscriber) { - Assert.isNotNull(subscriber); - this.subscriber = subscriber; + Subscriber subscriber; + + /** + * Create the collector and register it as a listener with the workspace + * and the subscriber. + * @param subscriber the subscriber to be associated with this collector + */ + public SubscriberResourceCollector(Subscriber subscriber) { + Assert.isNotNull(subscriber); + this.subscriber = subscriber; ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); subscriber.addListener(this); - } + } /** * Returns the <code>Subscriber</code> associated with this collector. @@ -55,9 +55,9 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList return subscriber; } - /** - * De-register the listeners for this collector. - */ + /** + * De-register the listeners for this collector. + */ public void dispose() { getSubscriber().removeListener(this); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); @@ -65,14 +65,14 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList @Override public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) { - try { - beginInput(); + try { + beginInput(); IResource[] roots = getRoots(); for (int i = 0; i < deltas.length; i++) { switch (deltas[i].getFlags()) { case ISubscriberChangeEvent.SYNC_CHANGED : if (isAllRootsIncluded() || isDescendantOfRoot(deltas[i].getResource(), roots)) { - change(deltas[i].getResource(), IResource.DEPTH_ZERO); + change(deltas[i].getResource(), IResource.DEPTH_ZERO); } break; case ISubscriberChangeEvent.ROOT_REMOVED : @@ -85,42 +85,42 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList break; } } - } finally { - endInput(); - } + } finally { + endInput(); + } } - /** - * This method is invoked at the beginning of a subscriber change event - * or resource delta event. The endInput method will be invoked at some point - * following this. There may be several invocations of remove or change - * in between. - */ - protected void beginInput() { - // Do nothing by default - } - - /** - * The processing of the resource or subscriber delta has finished. - * Subclasses can accumulate removals and changes and handle them - * at this point to allow batched change events. - */ - protected void endInput() { - // Do nothing by default - } + /** + * This method is invoked at the beginning of a subscriber change event + * or resource delta event. The endInput method will be invoked at some point + * following this. There may be several invocations of remove or change + * in between. + */ + protected void beginInput() { + // Do nothing by default + } + + /** + * The processing of the resource or subscriber delta has finished. + * Subclasses can accumulate removals and changes and handle them + * at this point to allow batched change events. + */ + protected void endInput() { + // Do nothing by default + } @Override public void resourceChanged(IResourceChangeEvent event) { - try { - beginInput(); + try { + beginInput(); processDelta(event.getDelta(), getRoots()); - } finally { - endInput(); - } + } finally { + endInput(); + } } - /** + /** * Process the resource delta and posts all necessary events to the background * event handler. * @@ -133,8 +133,8 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList if (resource.getType() == IResource.PROJECT) { // Handle projects that should be removed from the collector if (((kind & IResourceDelta.REMOVED) != 0) /* deleted project */ - || (delta.getFlags() & IResourceDelta.OPEN) != 0 && !((IProject) resource).isOpen() /* closed project */ - || !isAncestorOfRoot(resource, roots)) /* not within subscriber roots */ { + || (delta.getFlags() & IResourceDelta.OPEN) != 0 && !((IProject) resource).isOpen() /* closed project */ + || !isAncestorOfRoot(resource, roots)) /* not within subscriber roots */ { // If the project has any entries in the sync set, remove them if (hasMembers(resource)) { remove(resource); @@ -178,8 +178,8 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList * Return the root resources that are to be considered by this handler. * These may be either the subscriber roots or a set of resources that are * contained by the subscriber's roots. - * @return the root resources that are to be considered by this handler - */ + * @return the root resources that are to be considered by this handler + */ protected IResource[] getRoots() { return getSubscriber().roots(); } @@ -188,38 +188,38 @@ public abstract class SubscriberResourceCollector implements IResourceChangeList * Return whether the given resource, which is not * within the roots of this handler, has children * that are. - * @param resource the resource - * @return whether the resource has children that are being considered - * by this handler. - */ - protected abstract boolean hasMembers(IResource resource); - - /** - * The resource is no longer of concern to the subscriber. - * Remove the resource and any of it's descendants - * from the set of resources being collected. - * @param resource the resource to be removed along with its - * descendants. - */ - protected abstract void remove(IResource resource); - - /** - * The resource sync state has changed to the depth specified. - * @param resource the resource - * @param depth the depth - */ - protected abstract void change(IResource resource, int depth); + * @param resource the resource + * @return whether the resource has children that are being considered + * by this handler. + */ + protected abstract boolean hasMembers(IResource resource); + + /** + * The resource is no longer of concern to the subscriber. + * Remove the resource and any of it's descendants + * from the set of resources being collected. + * @param resource the resource to be removed along with its + * descendants. + */ + protected abstract void remove(IResource resource); + + /** + * The resource sync state has changed to the depth specified. + * @param resource the resource + * @param depth the depth + */ + protected abstract void change(IResource resource, int depth); /** * Return whether all roots of a subscriber are included or * if the collector is only consider a subset of the resources. - * @return whether all roots of a subscriber are included - */ + * @return whether all roots of a subscriber are included + */ protected boolean isAllRootsIncluded() { return true; } - private boolean isAncestorOfRoot(IResource parent, IResource[] roots) { + private boolean isAncestorOfRoot(IResource parent, IResource[] roots) { // Always traverse into projects in case a root was removed if (parent.getType() == IResource.ROOT) return true; for (int i = 0; i < roots.length; i++) { |