private void beginRTask(final IToolService r, final IProgressMonitor monitor) throws CoreException { synchronized (this) { while (fRProcess != null) { if (fRTask == 1) { monitor.subTask("Waiting for package check..."); try { wait(); } catch (final InterruptedException e) { if (monitor.isCanceled()) { throw new CoreException(Status.CANCEL_STATUS); } } } else { final Status status = new Status( IStatus.ERROR, RCore.PLUGIN_ID, NLS.bind( "Another package manager task for ''{0}'' is already running in ''{0}''", fREnv.getName(), fRProcess.getLabel(ITool.DEFAULT_LABEL))); // r.handleStatus(status, monitor); throw new CoreException(status); } } fRProcess = r.getTool(); fRTask = 2; } }
@Override public void apply(final ITool process) { process .getQueue() .add( new AbstractRToolRunnable( "r/renv/rpkg.apply", //$NON-NLS-1$ "Perform Package Manager Operations") { @Override protected void run(final IRToolService r, final IProgressMonitor monitor) throws CoreException { runApply(r, monitor); } }); }
@Override public void loadPkgs( final ITool rTool, final List<? extends IRPkgInfoAndData> pkgs, final boolean expliciteLocation) { final RPkgOperator op = new RPkgOperator(this); rTool .getQueue() .add( new AbstractStatetRRunnable( "r/renv/pkgs.load", //$NON-NLS-1$ "Load R Packages") { @Override protected void run(final IRConsoleService r, final IProgressMonitor monitor) throws CoreException { checkNewCommand(r, monitor); op.loadPkgs(pkgs, expliciteLocation, r, monitor); } }); }
@Override public void perform(final ITool rTool, final List<? extends RPkgAction> actions) { if (actions.isEmpty()) { return; } final String label = (actions.get(0).getAction() == RPkgAction.UNINSTALL) ? "Uninstall R Packages" : "Install/Update R Packages"; final RPkgOperator op = new RPkgOperator(this); rTool .getQueue() .add( new AbstractStatetRRunnable("r/renv/pkgs.inst", label) { // $NON-NLS-1$ @Override protected void run(final IRConsoleService r, final IProgressMonitor monitor) throws CoreException { beginRTask(r, monitor); try { checkNewCommand(r, monitor); op.runActions(actions, r, monitor); } catch (final UnexpectedRDataException | CoreException e) { throw new CoreException( new Status( IStatus.ERROR, RCore.PLUGIN_ID, 0, "An error occurred when installing and updating R packages.", e)); } finally { endRTask(); r.briefAboutChange(0x10); // packages } } }); }