use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class ConsoleDispatcher method executeSetWd.
public void executeSetWd(FileSystemItem dir, boolean activateConsole) {
String escaped = dir.getPath().replaceAll("\\\\", "\\\\\\\\");
if (escaped.equals("~"))
escaped = "~/";
eventBus_.fireEvent(new SendToConsoleEvent("setwd(\"" + escaped + "\")", true));
if (activateConsole)
commands_.activateConsole().execute();
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class BreakpointManager method onContextDepthChanged.
@Override
public void onContextDepthChanged(ContextDepthChangedEvent event) {
// When we move around in debug context and hit a breakpoint, the initial
// evaluation state is a temporary construction that needs to be stepped
// past to begin actually evaluating the function. Step past it
// immediately.
JsArray<CallFrame> frames = event.getCallFrames();
Set<FileFunction> activeFunctions = new TreeSet<FileFunction>();
boolean hasSourceEquiv = false;
for (int idx = 0; idx < frames.length(); idx++) {
CallFrame frame = frames.get(idx);
String functionName = frame.getFunctionName();
String fileName = frame.getFileName();
if (functionName.equals(".doTrace") && event.isServerInitiated()) {
events_.fireEvent(new SendToConsoleEvent(DebugCommander.NEXT_COMMAND, true));
}
activeFunctions.add(new FileFunction(functionName, fileName, "", false));
if (frame.isSourceEquiv()) {
activeSource_ = fileName;
hasSourceEquiv = true;
}
}
// For any functions that were previously active in the callstack but
// are no longer active, enable any pending breakpoints for those
// functions.
Set<FileFunction> enableFunctions = new TreeSet<FileFunction>();
for (FileFunction function : activeFunctions_) {
if (!activeFunctions.contains(function)) {
for (Breakpoint breakpoint : breakpoints_) {
if (breakpoint.isPendingDebugCompletion() && breakpoint.getState() == Breakpoint.STATE_INACTIVE && function.containsBreakpoint(breakpoint)) {
enableFunctions.add(function);
}
}
}
}
for (FileFunction function : enableFunctions) {
prepareAndSetFunctionBreakpoints(function);
}
// Record the new frame list.
activeFunctions_ = activeFunctions;
// breakpoints in the file we were sourcing.
if (!hasSourceEquiv && activeSource_ != null) {
activateTopLevelBreakpoints(activeSource_);
activeSource_ = null;
}
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class DataImportPresenter method getImportDatasetCommandFromMode.
public Command getImportDatasetCommandFromMode(final DataImportModes dataImportMode, final String dialogTitle, final String path) {
return new Command() {
@Override
public void execute() {
DataImportDialog dataImportDialog = new DataImportDialog(dataImportMode, dialogTitle, path, new OperationWithInput<String>() {
@Override
public void execute(final String importCode) {
eventBus_.fireEvent(new SendToConsoleEvent(importCode, true, true));
}
});
dataImportDialog.showModal();
}
};
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class Packages method doUpdatePackages.
private void doUpdatePackages(final PackageInstallContext installContext) {
new CheckForUpdatesDialog(globalDisplay_, new ServerDataSource<JsArray<PackageUpdate>>() {
public void requestData(ServerRequestCallback<JsArray<PackageUpdate>> requestCallback) {
server_.checkForPackageUpdates(requestCallback);
}
}, new OperationWithInput<ArrayList<PackageUpdate>>() {
@Override
public void execute(ArrayList<PackageUpdate> updates) {
InstallCommand cmd = buildUpdatePackagesCommand(updates, installContext);
executeWithLoadedPackageCheck(cmd);
}
}, new Operation() {
@Override
public void execute() {
// cancel emits an empty console input line to clear
// the busy indicator
events_.fireEvent(new SendToConsoleEvent("", true));
}
}).showModal();
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class ConnectionsPresenter method onPerformConnection.
@Override
public void onPerformConnection(PerformConnectionEvent event) {
String connectVia = event.getConnectVia();
String connectCode = event.getConnectCode();
if (connectVia.equals(ConnectionOptions.CONNECT_COPY_TO_CLIPBOARD)) {
DomUtils.copyCodeToClipboard(connectCode);
} else if (connectVia.equals(ConnectionOptions.CONNECT_R_CONSOLE)) {
eventBus_.fireEvent(new SendToConsoleEvent(connectCode, true));
display_.showConnectionProgress();
} else if (connectVia.equals(ConnectionOptions.CONNECT_NEW_R_SCRIPT) || connectVia.equals(ConnectionOptions.CONNECT_NEW_R_NOTEBOOK)) {
String type;
String code = connectCode;
SourcePosition cursorPosition = null;
if (connectVia.equals(ConnectionOptions.CONNECT_NEW_R_SCRIPT)) {
type = NewDocumentWithCodeEvent.R_SCRIPT;
code = code + "\n\n";
} else {
type = NewDocumentWithCodeEvent.R_NOTEBOOK;
int codeLength = code.split("\n").length;
code = "---\n" + "title: \"R Notebook\"\n" + "output: html_notebook\n" + "---\n" + "\n" + "```{r setup, include=FALSE}\n" + code + "\n" + "```\n" + "\n" + "```{r}\n" + "\n" + "```\n";
cursorPosition = SourcePosition.create(9 + codeLength, 0);
}
eventBus_.fireEvent(new NewDocumentWithCodeEvent(type, code, cursorPosition, true));
display_.showConnectionProgress();
}
}
Aggregations