use of org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit in project rstudio by rstudio.
the class TextEditingTargetNotebook method onRmdChunkOutput.
@Override
public void onRmdChunkOutput(RmdChunkOutputEvent event) {
// ignore if not targeted at this document
if (event.getOutput().getDocId() != docUpdateSentinel_.getId())
return;
// the server, so clean it up here.
if (event.getOutput().isEmpty() && !queue_.isExecuting()) {
events_.fireEvent(new ChunkChangeEvent(docUpdateSentinel_.getId(), event.getOutput().getChunkId(), event.getOutput().getRequestId(), 0, ChunkChangeEvent.CHANGE_REMOVE));
return;
}
String chunkId = event.getOutput().getChunkId();
// ignore requests performed to initialize satellite chunks
if (satelliteChunkRequestIds_.contains(event.getOutput().getRequestId()))
return;
// if this is the currently executing chunk and it has an error...
NotebookQueueUnit unit = queue_.executingUnit();
if (unit != null && unit.getChunkId() == event.getOutput().getChunkId() && event.getOutput().getType() == RmdChunkOutput.TYPE_SINGLE_UNIT && event.getOutput().getUnit().getType() == RmdChunkOutputUnit.TYPE_ERROR) {
// draw the error
Scope scope = getChunkScope(unit.getChunkId());
if (scope != null) {
int offset = scope.getBodyStart().getRow();
List<Integer> lines = unit.getExecutingLines();
for (Integer line : lines) docDisplay_.setChunkLineExecState(line + offset, line + offset, ChunkRowExecState.LINE_ERROR);
}
// error = FALSE
if (!outputs_.containsKey(chunkId) || !outputs_.get(chunkId).getOptions().error()) {
clearChunkExecQueue();
}
}
// show output in matching chunk
if (outputs_.containsKey(chunkId)) {
// by default, ensure chunks are visible if we aren't replaying them
// from the cache
boolean ensureVisible = !event.getOutput().isReplay();
int mode = queue_.getChunkExecMode(chunkId);
// no need to make chunks visible in batch mode
if (ensureVisible && mode == NotebookQueueUnit.EXEC_MODE_BATCH)
ensureVisible = false;
outputs_.get(chunkId).getOutputWidget().showChunkOutput(event.getOutput(), mode, NotebookQueueUnit.EXEC_SCOPE_PARTIAL, !queue_.isChunkExecuting(chunkId), ensureVisible);
}
}
use of org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit in project rstudio by rstudio.
the class NotebookQueueState method dequeueChunk.
public void dequeueChunk(int preambleRow) {
// find the chunk's ID
String chunkId = notebook_.getRowChunkId(preambleRow);
if (StringUtil.isNullOrEmpty(chunkId))
return;
notebook_.cleanChunkExecState(chunkId);
// clear from the execution queue and update display
for (int i = 0; i < queue_.getUnits().length(); i++) {
if (queue_.getUnits().get(i).getChunkId() == chunkId) {
NotebookQueueUnit unit = queue_.getUnits().get(i);
queue_.removeUnit(unit);
server_.updateNotebookExecQueue(unit, NotebookDocQueue.QUEUE_OP_DELETE, "", new VoidServerRequestCallback());
break;
}
}
}
use of org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit in project rstudio by rstudio.
the class NotebookQueueState method queueChunkRange.
private void queueChunkRange(ChunkExecUnit chunk) {
NotebookQueueUnit unit = unitFromScope(chunk);
renderLineState(chunk.getScope().getBodyStart().getRow(), unit.getPendingLines(), ChunkRowExecState.LINE_QUEUED);
notebook_.setChunkState(chunk.getScope(), ChunkContextToolbar.STATE_QUEUED);
queue_.addUnit(unit);
server_.updateNotebookExecQueue(unit, NotebookDocQueue.QUEUE_OP_ADD, "", new VoidServerRequestCallback());
}
use of org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit in project rstudio by rstudio.
the class NotebookQueueState method onNotebookRangeExecuted.
// Event handlers ----------------------------------------------------------
@Override
public void onNotebookRangeExecuted(NotebookRangeExecutedEvent event) {
if (queue_ == null || event.getDocId() != queue_.getDocId())
return;
Scope scope = notebook_.getChunkScope(event.getChunkId());
if (scope == null)
return;
if (isChunkExecuting(event.getChunkId())) {
if (event.getExprMode() == NotebookRangeExecutedEvent.EXPR_NEW)
executingUnit_.setExecutingRange(event.getExecRange());
else
executingUnit_.extendExecutingRange(event.getExecRange());
executingUnit_.addCompletedRange(event.getExecRange());
}
// add to console history
events_.fireEvent(new ConsoleHistoryAddedEvent(event.getCode()));
// find the queue unit and convert to lines
for (int i = 0; i < queue_.getUnits().length(); i++) {
NotebookQueueUnit unit = queue_.getUnits().get(i);
if (unit.getChunkId() == event.getChunkId()) {
List<Integer> lines = unit.linesFromRange(event.getExecRange());
renderLineState(scope.getBodyStart().getRow(), lines, ChunkRowExecState.LINE_EXECUTED);
break;
}
}
}
Aggregations