use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class Packages method unloadPackage.
public void unloadPackage(String packageName, String libName) {
// check status to make sure the package was unloaded
checkPackageStatusOnNextConsolePrompt(packageName, libName);
StringBuilder command = new StringBuilder();
command.append("detach(\"package:");
command.append(packageName);
command.append("\", unload=TRUE)");
events_.fireEvent(new SendToConsoleEvent(command.toString(), true));
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class Packages method removePackage.
public void removePackage(final PackageInfo packageInfo) {
withPackageInstallContext(new OperationWithInput<PackageInstallContext>() {
@Override
public void execute(final PackageInstallContext installContext) {
final boolean usingDefaultLibrary = packageInfo.getLibrary().equals(installContext.getDefaultLibraryPath());
StringBuilder message = new StringBuilder();
message.append("Are you sure you wish to permanently uninstall the '");
message.append(packageInfo.getName() + "' package");
if (!usingDefaultLibrary) {
message.append(" from library '");
message.append(packageInfo.getLibrary());
message.append("'");
}
message.append("? This action cannot be undone.");
globalDisplay_.showYesNoMessage(MessageDialog.WARNING, "Uninstall Package ", message.toString(), new Operation() {
@Override
public void execute() {
StringBuilder command = new StringBuilder();
command.append("remove.packages(\"");
command.append(packageInfo.getName());
command.append("\"");
if (!usingDefaultLibrary) {
command.append(", lib=\"");
command.append(packageInfo.getLibrary());
command.append("\"");
}
command.append(")");
String cmd = command.toString();
events_.fireEvent(new SendToConsoleEvent(cmd, true));
}
}, true);
}
});
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class Packages method executeRemoveCommand.
public void executeRemoveCommand(ArrayList<PackratPackageAction> actions) {
String cmd = "remove.packages(";
if (actions.size() == 1)
cmd += "\"" + actions.get(0).getPackage() + "\"";
else {
cmd += "c(";
for (int i = 0; i < actions.size(); i++) {
cmd += "\"" + actions.get(i).getPackage() + "\"";
if (i < actions.size() - 1)
cmd += ", ";
}
cmd += ")";
}
cmd += ")";
events_.fireEvent(new SendToConsoleEvent(cmd, true));
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class History method onHistorySendToConsole.
@Handler
void onHistorySendToConsole() {
String commandString = getSelectedCommands();
commandString = StringUtil.chomp(commandString);
if (commandString.length() > 0)
events_.fireEvent(new SendToConsoleEvent(commandString, false));
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class TextEditingTarget method executeSweaveChunk.
private void executeSweaveChunk(final Scope chunk, final int mode, final boolean scrollNearTop) {
if (chunk == null)
return;
// command used to execute chunk (we may need to defer it if this
// is an Rmd document as populating params might be necessary)
final Command executeChunk = new Command() {
@Override
public void execute() {
Range range = scopeHelper_.getSweaveChunkInnerRange(chunk);
if (scrollNearTop) {
docDisplay_.navigateToPosition(SourcePosition.create(range.getStart().getRow(), range.getStart().getColumn()), true);
}
if (!range.isEmpty()) {
codeExecution_.setLastExecuted(range.getStart(), range.getEnd());
}
if (fileType_.isRmd() && docDisplay_.showChunkOutputInline()) {
// in notebook mode, an empty chunk can refer to external code,
// so always execute it
notebook_.executeChunk(chunk);
} else if (!range.isEmpty()) {
String code = scopeHelper_.getSweaveChunkText(chunk);
events_.fireEvent(new SendToConsoleEvent(code, true));
}
docDisplay_.collapseSelection(true);
}
};
// Rmd allows server-side prep for chunk execution
if (fileType_.isRmd() && !docDisplay_.showChunkOutputInline()) {
// ensure source is synced with server
docUpdateSentinel_.withSavedDoc(new Command() {
@Override
public void execute() {
// allow server to prepare for chunk execution
// (e.g. by populating 'params' in the global environment)
rmarkdownHelper_.prepareForRmdChunkExecution(docUpdateSentinel_.getId(), docUpdateSentinel_.getContents(), executeChunk);
}
});
} else {
executeChunk.execute();
}
}
Aggregations