Search in sources :

Example 1 with ScopeList

use of org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList in project rstudio by rstudio.

the class NotebookQueueState method getChunkDefAtRow.

private ChunkDefinition getChunkDefAtRow(int row, String newId) {
    ChunkDefinition chunkDef;
    // if there is an existing widget just modify it in place
    LineWidget widget = docDisplay_.getLineWidgetForRow(row);
    if (widget != null && widget.getType().equals(ChunkDefinition.LINE_WIDGET_TYPE)) {
        chunkDef = widget.getData();
    } else // otherwise create a new one
    {
        if (StringUtil.isNullOrEmpty(newId))
            newId = "c" + StringUtil.makeRandomId(12);
        chunkDef = ChunkDefinition.create(row, 1, true, ChunkOutputWidget.EXPANDED, RmdChunkOptions.create(), sentinel_.getId(), newId, TextEditingTargetNotebook.getKnitrChunkLabel(row, docDisplay_, new ScopeList(docDisplay_)));
        if (newId == TextEditingTargetNotebook.SETUP_CHUNK_ID)
            chunkDef.getOptions().setInclude(false);
        RStudioGinjector.INSTANCE.getEventBus().fireEvent(new ChunkChangeEvent(sentinel_.getId(), chunkDef.getChunkId(), "", row, ChunkChangeEvent.CHANGE_CREATE));
    }
    return chunkDef;
}
Also used : ChunkChangeEvent(org.rstudio.studio.client.workbench.views.source.events.ChunkChangeEvent) ScopeList(org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList) LineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget)

Aggregations

ScopeList (org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList)1 LineWidget (org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget)1 ChunkChangeEvent (org.rstudio.studio.client.workbench.views.source.events.ChunkChangeEvent)1