private boolean isDeletedRemotely(SyncInfo info) {
   int kind = info.getKind();
   if (kind == (SyncInfo.INCOMING | SyncInfo.DELETION)) return true;
   if (SyncInfo.getDirection(kind) == SyncInfo.CONFLICTING && info.getRemote() == null)
     return true;
   return false;
 }
Example #2
0
  /** {@inheritDoc} */
  public boolean accept(Object element) {
    boolean passes = true;

    if (element instanceof IFile) {

      IFile file = (IFile) element;
      IProject project = file.getProject();

      if (RepositoryProvider.isShared(project)) {

        RepositoryProvider provider = RepositoryProvider.getProvider(project);

        if (provider != null) {

          Subscriber subscriber = provider.getSubscriber();

          if (subscriber != null) {

            try {
              SyncInfo synchInfo = subscriber.getSyncInfo(file);

              if (synchInfo != null) {
                int kind = synchInfo.getKind();
                passes = (SyncInfo.getDirection(kind) & SyncInfo.OUTGOING) == SyncInfo.OUTGOING;
              }
            } catch (TeamException e) {
              CheckstyleLog.log(e);
            }
          }
        }
      }
    }
    return passes;
  }
  @Override
  public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final SyncInfo[] infos = getSyncInfoSet().getSyncInfos();
    if (Utils.isEmpty(infos)) {
      return;
    }

    for (SyncInfo syncInfo : infos) {
      if (SyncInfo.getDirection(syncInfo.getKind()) == SyncInfo.INCOMING) {
        logger.warn("Request to apply incoming change to remote");
        StringBuffer strBuff = new StringBuffer("Change is ");
        strBuff
            .append(getDirectionString(syncInfo))
            .append(".\n\nAre you sure you want to override ")
            .append(getDirectionString(syncInfo))
            .append(" ")
            .append(getDeltaString(syncInfo))
            .append(" and apply local ")
            .append(getReverseDeltaString(syncInfo))
            .append(" to server?");
        ConfirmRunnable confirm = new ConfirmRunnable("Incoming Change Found", strBuff.toString());
        Display.getDefault().syncExec(confirm);
        if (!confirm.getResult()) {
          return;
        }
      }
    }

    try {
      applyToServer(getSubscriber(), infos, monitor);
    } catch (InterruptedException e) {
      logger.warn("Operation cancelled: " + e.getMessage());
    } catch (InvocationTargetException e) {
      Throwable cause = e.getTargetException();
      if (cause instanceof InsufficientPermissionsException) {
        DialogUtils.getInstance()
            .presentInsufficientPermissionsDialog((InsufficientPermissionsException) cause);
      } else {
        logger.error("Unable to apply change to server", e);
        showErrorAsync(e, true, "Unable to apply change to server");
      }
    }
  }