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;
  }
Ejemplo n.º 2
0
  public void startup() {
    loadState();
    loadCommentHistory();
    loadCommentTemplates();
    CVSProviderPlugin.getPlugin()
        .addRepositoryListener(
            new ICVSListener() {
              public void repositoryAdded(ICVSRepositoryLocation root) {
                rootAdded(root);
              }

              public void repositoryRemoved(ICVSRepositoryLocation root) {
                rootRemoved(root);
              }
            });

    IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
    store.addPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)) {
              Object newValue = event.getNewValue();
              if (newValue instanceof String) {
                try {
                  setMaxComments(Integer.parseInt((String) newValue));
                } catch (NumberFormatException e) {
                  // fail silently
                }
              }
            }
          }
        });
    setMaxComments(store.getInt(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY));
  }
  /* (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()]));
  }
 public void dispose() {
   CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().removeListener(this);
   tree.dispose();
 }
 private void initialize() {
   CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().addListener(this);
 }