コード例 #1
0
  private SubscriberChangeEvent[] handleRemovedRoot(IResource removedRoot) {
    // Determine if any of the roots of the compare are affected
    List removals = new ArrayList(resources.length);
    for (int j = 0; j < resources.length; j++) {
      IResource root = resources[j];
      if (removedRoot.getFullPath().isPrefixOf(root.getFullPath())) {
        // The root is no longer managed by CVS
        removals.add(root);
        try {
          tree.flushVariants(root, IResource.DEPTH_INFINITE);
        } catch (TeamException e) {
          CVSProviderPlugin.log(e);
        }
      }
    }
    if (removals.isEmpty()) {
      return new SubscriberChangeEvent[0];
    }

    // Adjust the roots of the subscriber
    List newRoots = new ArrayList(resources.length);
    newRoots.addAll(Arrays.asList(resources));
    newRoots.removeAll(removals);
    resources = (IResource[]) newRoots.toArray(new IResource[newRoots.size()]);

    // Create the deltas for the removals
    SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[removals.size()];
    for (int i = 0; i < deltas.length; i++) {
      deltas[i] =
          new SubscriberChangeEvent(
              this, ISubscriberChangeEvent.ROOT_REMOVED, (IResource) removals.get(i));
    }
    return deltas;
  }
コード例 #2
0
 /**
  * @param resources
  * @param tags
  */
 public void resetRoots(IResource[] resources, CVSTag[] tags) {
   if (this.resources != null) {
     List removed = new ArrayList();
     for (int i = 0; i < this.resources.length; i++) {
       IResource resource = this.resources[i];
       removed.add(new SubscriberChangeEvent(this, ISubscriberChangeEvent.ROOT_REMOVED, resource));
     }
     this.resources = new IResource[0];
     fireTeamResourceChange(
         (ISubscriberChangeEvent[]) removed.toArray(new ISubscriberChangeEvent[removed.size()]));
     if (tree != null) {
       tree.dispose();
       tree = null;
     }
   }
   this.resources = resources;
   MultiTagResourceVariantTree multiTree =
       new MultiTagResourceVariantTree(
           new SessionResourceVariantByteStore(), getCacheFileContentsHint());
   for (int i = 0; i < tags.length; i++) {
     multiTree.addResource(resources[i], tags[i]);
   }
   tree = multiTree;
 }
コード例 #3
0
  /* (non-Javadoc)
   * @see org.eclipse.team.core.subscribers.ITeamResourceChangeListener#teamResourceChanged(org.eclipse.team.core.subscribers.TeamDelta[])
   */
  public void subscriberResourceChanged(ISubscriberChangeEvent[] deltas) {
    List outgoingDeltas = new ArrayList(deltas.length);
    for (int i = 0; i < deltas.length; i++) {
      ISubscriberChangeEvent delta = deltas[i];
      if ((delta.getFlags() & ISubscriberChangeEvent.ROOT_REMOVED) != 0) {
        IResource resource = delta.getResource();
        outgoingDeltas.addAll(Arrays.asList(handleRemovedRoot(resource)));
      } else if ((delta.getFlags() & ISubscriberChangeEvent.SYNC_CHANGED) != 0) {
        IResource resource = delta.getResource();
        try {
          if (isSupervised(resource)) {
            outgoingDeltas.add(new SubscriberChangeEvent(this, delta.getFlags(), resource));
          }
        } catch (TeamException e) {
          // Log and ignore
          CVSProviderPlugin.log(e);
        }
      }
    }

    fireTeamResourceChange(
        (SubscriberChangeEvent[])
            outgoingDeltas.toArray(new SubscriberChangeEvent[outgoingDeltas.size()]));
  }