Exemple #1
0
  @Override
  public boolean performFinish() {

    if (controller != null) {
      try {
        // do upgrade
        controller.finish(new NullProgressMonitor());

        Display.getDefault()
            .asyncExec(
                new Runnable() {
                  @Override
                  public void run() {
                    DialogUtils.getInstance()
                        .closeMessage(
                            UpgradeMessages.getString("UpgradeWizard.Complete.title"),
                            UpgradeMessages.getString(
                                "UpgradeWizard.Complete.message",
                                new String[] {
                                  getUpgradeController().getUpgradeModel().getProjectName(),
                                  getUpgradeController().getUpgradeModel().getIdeReleaseName()
                                }));
                  }
                });

      } catch (InterruptedException e) {
        logger.warn("Operation canceled: " + e.getMessage());

      } catch (InvocationTargetException e) {
        Throwable cause = e.getTargetException();
        if (cause instanceof InsufficientPermissionsException) {
          DialogUtils.getInstance()
              .presentInsufficientPermissionsDialog((InsufficientPermissionsException) cause);
        } else if (cause instanceof InvalidLoginException) {
          // log failure
          logger.warn(
              "Unable to upgrade components: " + ForceExceptionUtils.getRootCauseMessage(cause));
          // choose further project create direction
          DialogUtils.getInstance()
              .invalidLoginDialog(ForceExceptionUtils.getRootCauseMessage(cause));
        } else {
          logger.error("Unable to upgrade components", ForceExceptionUtils.getRootCause(cause));
          StringBuffer strBuff = new StringBuffer();
          strBuff
              .append("Unable to upgrade components:\n\n")
              .append(ForceExceptionUtils.getStrippedRootCauseMessage(e))
              .append("\n\n ");
          Utils.openError("Upgrade Error", strBuff.toString());
        }
      } catch (Exception e) {
        Utils.openError(e, true, "Unable to complete upgrade:\n\n" + e.getMessage());
        return false;
      } finally {
        this.controller.dispose();
      }
    }
    return true;
  }
Exemple #2
0
 @Override
 public boolean performCancel() {
   int result =
       DialogUtils.getInstance()
           .yesNoMessage(
               UpgradeMessages.getString("UpgradeWizard.Cancel.title"),
               UpgradeMessages.getString("UpgradeWizard.Cancel.message"),
               MessageDialog.WARNING);
   return !(result > 0);
 }
  @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");
      }
    }
  }