Search in sources :

Example 1 with NotebookExecRange

use of org.rstudio.studio.client.rmarkdown.model.NotebookExecRange in project rstudio by rstudio.

the class NotebookQueueState method executeChunk.

public void executeChunk(ChunkExecUnit chunk) {
    if (isExecuting()) {
        String chunkId = notebook_.getRowChunkId(chunk.getScope().getPreamble().getRow());
        if (chunkId == null)
            return;
        NotebookQueueUnit unit = getUnit(chunkId);
        if (unit == null) {
            // unit is not in the queue; add it
            queueChunkRange(chunk);
        } else if (chunk.getRange() != null) {
            // only part of the chunk needs to be executed
            NotebookExecRange execRange = getNotebookExecRange(chunk.getScope(), chunk.getRange());
            // (note: doesn't handle overlapping)
            if (unit.hasPendingRange(execRange))
                return;
            // unit is in the queue, modify it
            unit.addPendingRange(execRange);
            // redraw the pending lines
            renderQueueLineState(chunk.getScope(), unit);
            server_.updateNotebookExecQueue(unit, NotebookDocQueue.QUEUE_OP_UPDATE, "", new VoidServerRequestCallback());
        }
    } else {
        List<ChunkExecUnit> chunks = new ArrayList<ChunkExecUnit>();
        chunks.add(chunk);
        executeChunks("Run Chunk", chunks);
    }
}
Also used : NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit) ArrayList(java.util.ArrayList) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) NotebookExecRange(org.rstudio.studio.client.rmarkdown.model.NotebookExecRange)

Aggregations

ArrayList (java.util.ArrayList)1 NotebookExecRange (org.rstudio.studio.client.rmarkdown.model.NotebookExecRange)1 NotebookQueueUnit (org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)1 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)1