Search in sources :

Example 1 with NotebookQueueUnit

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

the class NotebookQueueState method unitFromScope.

private NotebookQueueUnit unitFromScope(ChunkExecUnit chunk) {
    // extract scope and range (use entire chunk as range if no range was
    // specified)
    final Scope scope = chunk.getScope();
    final Range range = chunk.getRange() == null ? scopeHelper_.getSweaveChunkInnerRange(chunk.getScope()) : chunk.getRange();
    // find associated chunk definition
    String id = null;
    if (chunk.getExecScope() == NotebookQueueUnit.EXEC_SCOPE_INLINE) {
        id = chunk.getScope().getLabel();
    } else {
        if (TextEditingTargetNotebook.isSetupChunkScope(scope))
            id = TextEditingTargetNotebook.SETUP_CHUNK_ID;
        ChunkDefinition def = getChunkDefAtRow(scope.getEnd().getRow(), id);
        id = def.getChunkId();
    }
    String code = docDisplay_.getCode(scope.getPreamble(), scope.getEnd());
    NotebookQueueUnit unit = NotebookQueueUnit.create(sentinel_.getId(), id, chunk.getExecMode(), chunk.getExecScope(), code);
    // add a pending range (if it has any content)
    if (!range.getStart().isEqualTo(range.getEnd()))
        unit.addPendingRange(getNotebookExecRange(scope, range));
    return unit;
}
Also used : Scope(org.rstudio.studio.client.workbench.views.source.editors.text.Scope) NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit) Range(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range) NotebookExecRange(org.rstudio.studio.client.rmarkdown.model.NotebookExecRange)

Example 2 with NotebookQueueUnit

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

the class NotebookQueueState method renderQueueState.

public void renderQueueState(boolean replay) {
    if (queue_ == null)
        return;
    JsArray<NotebookQueueUnit> units = queue_.getUnits();
    for (int i = 0; i < units.length(); i++) {
        NotebookQueueUnit unit = units.get(i);
        // get the offset into the doc 
        Scope scope = notebook_.getChunkScope(unit.getChunkId());
        if (scope == null)
            continue;
        // clean any existing error decoration from the scope when it 
        // is rendered with queued state
        notebook_.cleanScopeErrorState(scope);
        // draw the queued and executing lines
        renderQueueLineState(scope, unit);
        // update the chunk's toolbars
        notebook_.setChunkState(scope, replay && i == 0 ? ChunkContextToolbar.STATE_EXECUTING : ChunkContextToolbar.STATE_QUEUED);
    }
    // update the status bar
    beginQueueExecution();
}
Also used : Scope(org.rstudio.studio.client.workbench.views.source.editors.text.Scope) NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)

Example 3 with NotebookQueueUnit

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

the class NotebookQueueState method executeChunks.

public void executeChunks(String jobDesc, List<ChunkExecUnit> units) {
    createQueue(jobDesc);
    // create queue units from scopes
    for (ChunkExecUnit chunk : units) {
        NotebookQueueUnit unit = unitFromScope(chunk);
        queue_.addUnit(unit);
    }
    executeQueue();
}
Also used : NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)

Example 4 with NotebookQueueUnit

use of org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit 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)

Example 5 with NotebookQueueUnit

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

the class TextEditingTargetNotebook method onEditorThemeStyleChanged.

// Event handlers ----------------------------------------------------------
@Override
public void onEditorThemeStyleChanged(EditorThemeStyleChangedEvent event) {
    // update cached style 
    editorStyle_ = event.getStyle();
    ChunkOutputWidget.cacheEditorStyle(editorStyle_.getColor(), editorStyle_.getBackgroundColor(), DomUtils.extractCssValue("ace_editor", "color"));
    for (ChunkOutputUi output : outputs_.values()) {
        output.getOutputWidget().applyCachedEditorStyle();
    }
    events_.fireEvent(new ChunkSatelliteCacheEditorStyleEvent(docUpdateSentinel_.getId(), editorStyle_.getColor(), editorStyle_.getBackgroundColor(), DomUtils.extractCssValue("ace_editor", "color")));
    // update if currently executing
    if (queue_.isExecuting()) {
        NotebookQueueUnit unit = queue_.executingUnit();
        if (unit != null) {
            setChunkExecuting(unit.getChunkId(), unit.getExecMode(), unit.getExecScope());
        }
    }
}
Also used : NotebookQueueUnit(org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit) ChunkSatelliteCacheEditorStyleEvent(org.rstudio.studio.client.workbench.views.source.editors.text.events.ChunkSatelliteCacheEditorStyleEvent)

Aggregations

NotebookQueueUnit (org.rstudio.studio.client.rmarkdown.model.NotebookQueueUnit)9 Scope (org.rstudio.studio.client.workbench.views.source.editors.text.Scope)4 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)3 NotebookExecRange (org.rstudio.studio.client.rmarkdown.model.NotebookExecRange)2 ArrayList (java.util.ArrayList)1 ConsoleHistoryAddedEvent (org.rstudio.studio.client.workbench.views.console.events.ConsoleHistoryAddedEvent)1 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)1 ChunkSatelliteCacheEditorStyleEvent (org.rstudio.studio.client.workbench.views.source.editors.text.events.ChunkSatelliteCacheEditorStyleEvent)1 ChunkChangeEvent (org.rstudio.studio.client.workbench.views.source.events.ChunkChangeEvent)1