/*
  * Return the selected SyncInfo for which this action is enabled.
  *
  * @return the selected SyncInfo for which this action is enabled.
  */
 private SyncInfoSet getSyncInfoSet() {
   IDiffElement[] elements = getFilteredDiffElements();
   SyncInfoSet filtered = new SyncInfoSet();
   for (int i = 0; i < elements.length; i++) {
     IDiffElement e = elements[i];
     if (e instanceof SyncInfoModelElement) {
       filtered.add(((SyncInfoModelElement) e).getSyncInfo());
     }
   }
   return filtered;
 }
 /* (non-Javadoc)
  * @see org.eclipse.team.core.synchronize.ISyncInfoSetChangeListener#syncInfoSetReset(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
  */
 public void syncInfoSetReset(SyncInfoSet set, IProgressMonitor monitor) {
   if (provider.isDisposed()) {
     set.removeSyncSetChangedListener(this);
   } else {
     reset();
   }
 }
 protected long getChangesInMode(int candidateMode) {
   SyncInfoSet participantSet = getParticipantSyncInfoSet();
   long numChanges;
   switch (candidateMode) {
     case ISynchronizePageConfiguration.OUTGOING_MODE:
       numChanges = participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
       break;
     case ISynchronizePageConfiguration.INCOMING_MODE:
       numChanges = participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
       break;
     case ISynchronizePageConfiguration.BOTH_MODE:
       numChanges =
           participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK)
               + participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
       break;
     default:
       numChanges = 0;
       break;
   }
   return numChanges;
 }
 /*
  * Return the candidate mode based on the presence of unfiltered changes
  * and the modes supported by the page.
  */
 protected int getCandidateMode() {
   SyncInfoSet participantSet = getParticipantSyncInfoSet();
   SynchronizePageConfiguration configuration = (SynchronizePageConfiguration) getConfiguration();
   long outgoingChanges = participantSet.countFor(SyncInfo.OUTGOING, SyncInfo.DIRECTION_MASK);
   if (outgoingChanges > 0) {
     if (configuration.isModeSupported(ISynchronizePageConfiguration.OUTGOING_MODE)) {
       return ISynchronizePageConfiguration.OUTGOING_MODE;
     }
     if (configuration.isModeSupported(ISynchronizePageConfiguration.BOTH_MODE)) {
       return ISynchronizePageConfiguration.BOTH_MODE;
     }
   }
   long incomingChanges = participantSet.countFor(SyncInfo.INCOMING, SyncInfo.DIRECTION_MASK);
   if (incomingChanges > 0) {
     if (configuration.isModeSupported(ISynchronizePageConfiguration.INCOMING_MODE)) {
       return ISynchronizePageConfiguration.INCOMING_MODE;
     }
     if (configuration.isModeSupported(ISynchronizePageConfiguration.BOTH_MODE)) {
       return ISynchronizePageConfiguration.BOTH_MODE;
     }
   }
   return configuration.getMode();
 }