Exemplo n.º 1
0
  private void runLoadPkgs(
      final ISelectedRepos repoSettings, final RService r, final IProgressMonitor monitor)
      throws CoreException {
    final boolean loadRepoPkgs =
        (fRequireLoad & (REQUIRE_REPO_PKGS)) != 0 && getReposStatus(repoSettings).isOK();
    final boolean loadInstPkgs = ((fRequireLoad & (REQUIRE_INST_PKGS)) != 0);

    FullRPkgSet pkgs = null;
    if (loadRepoPkgs) {
      fRTaskEvent.fOldPkgs = getRPkgSet();
      fRTaskEvent.fNewPkgs = pkgs = fPkgScanner.loadAvailable(repoSettings, r, monitor);
    }

    if (loadInstPkgs) {
      if (pkgs == null) {
        if (fPkgsExt != null) {
          pkgs = fPkgsExt.cloneAvailable();
        } else {
          pkgs = new FullRPkgSet(0);
        }
      }
      checkInstalled(pkgs, r, monitor);

      updateRViews(repoSettings, pkgs, r, monitor);
    }

    if (pkgs != null) {
      getWriteLock().lock();
      try {
        setPkgs();

        if (loadRepoPkgs) {
          fRequireLoad &= ~REQUIRE_REPO_PKGS;
          fPkgsStamp = fRTaskEvent.fStamp;
          fRTaskEvent.fPkgs |= AVAILABLE;
        }
        if (loadInstPkgs) {
          fRequireLoad &= ~REQUIRE_INST_PKGS;
        }
      } finally {
        getWriteLock().unlock();
      }
    }
  }
Exemplo n.º 2
0
  private void checkInstalled(
      final FullRPkgSet pkgs, final RService r, final IProgressMonitor monitor)
      throws CoreException {
    RVector<RNumericStore> libs = null;
    boolean[] update = null;

    try {
      libs =
          RDataUtil.checkRNumVector(r.evalData("rj:::.renv.checkLibs()", monitor)); // $NON-NLS-1$

      final int l = RDataUtil.checkIntLength(libs.getData());
      ITER_LIBS:
      for (int idxLib = 0; idxLib < l; idxLib++) {
        final String libPath = libs.getNames().getChar(idxLib);
        if (fLibs != null) {
          final int idx = (int) fLibs.getNames().indexOf(libPath);
          if (idx >= 0) {
            if (fLibs.getData().getNum(idx) == libs.getData().getNum(idxLib)) {
              continue ITER_LIBS;
            }
          }
        }
        if (update == null) {
          update = new boolean[l];
        }
        update[idxLib] = true;
      }

      fLibs = libs;
    } catch (final UnexpectedRDataException | CoreException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RCore.PLUGIN_ID,
              "An error occurred when checking for changed R libraries.",
              e));
    }

    if (update != null || pkgs != null) {
      if (fRTaskEvent == null) {
        fRTaskEvent = new Change(fREnv);
      }
      if (fRTaskEvent.fOldPkgs == null) {
        fRTaskEvent.fOldPkgs = getRPkgSet();
      }
      if (fPkgsExt != null || pkgs != null) {
        final FullRPkgSet newPkgs = (pkgs != null) ? pkgs : fPkgsExt.cloneAvailable();
        fRTaskEvent.fNewPkgs = newPkgs;
        fRLibPaths = RLibPaths.create(getRLibGroups(), libs, r, monitor);
        fPkgScanner.updateInstFull(fRLibPaths, update, newPkgs, fRTaskEvent, r, monitor);
      } else {
        final RPkgSet newPkgs = new RPkgSet((int) libs.getLength());
        fRTaskEvent.fNewPkgs = newPkgs;
        fRLibPaths = RLibPaths.createLight(getRLibGroups(), libs);
        fPkgScanner.updateInstLight(fRLibPaths, update, newPkgs, fRTaskEvent, r, monitor);
      }

      if (fRTaskEvent.fInstalledPkgs != null && fRTaskEvent.fInstalledPkgs.names.isEmpty()) {
        fRTaskEvent.fInstalledPkgs = null;
      }
      if (pkgs == null) {
        setPkgs();
      }
      if (fRTaskEvent.fInstalledPkgs != null && fDB != null) {
        fDB.updatePkgs(fRTaskEvent);
      }
    }
  }