use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class PackratUtil method executePackratFunction.
public void executePackratFunction(String name, String args) {
// append to args
String projectArg = packratProjectArg();
if (projectArg.length() > 0) {
if (args.length() == 0)
args = projectArg;
else
args = args + ", " + projectArg;
}
String cmd = "packrat::" + name + "(" + args + ")";
eventBus_.fireEvent(new SendToConsoleEvent(cmd, true, true));
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class EnvironmentPane method executeFunctionForObject.
// Private methods ---------------------------------------------------------
private void executeFunctionForObject(String function, String objectName) {
String editCode = function + "(" + StringUtil.toRSymbolName(objectName) + ")";
SendToConsoleEvent event = new SendToConsoleEvent(editCode, true);
eventBus_.fireEvent(event);
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class EnvironmentPresenter method showImportFileDialog.
private void showImportFileDialog(FileSystemItem input, String varname) {
ImportFileSettingsDialog dialog = new ImportFileSettingsDialog(server_, sourceServer_, input, varname, "Import Dataset", new OperationWithInput<ImportFileSettingsDialogResult>() {
public void execute(ImportFileSettingsDialogResult result) {
ImportFileSettings input = result.getSettings();
String var = StringUtil.toRSymbolName(input.getVarname());
String code = var + " <- " + makeCommand(input, result.getDefaultStringsAsFactors()) + "\n View(" + var + ")";
eventBus_.fireEvent(new SendToConsoleEvent(code, true));
}
}, globalDisplay_);
dialog.showModal();
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class HelpPane method handleKeyDown.
// delegate shortcuts which occur while Help has focus
private void handleKeyDown(NativeEvent e) {
// determine whether this key-combination means we should focus find
int mod = KeyboardShortcut.getModifierValue(e);
if (mod == (BrowseCap.hasMetaKey() ? KeyboardShortcut.META : KeyboardShortcut.CTRL)) {
if (e.getKeyCode() == 'F') {
e.preventDefault();
e.stopPropagation();
WindowEx.get().focus();
findTextBox_.focus();
findTextBox_.selectAll();
return;
} else if (e.getKeyCode() == KeyCodes.KEY_ENTER) {
// extract the selected code, if any
String code = frame_.getWindow().getSelectedText();
if (code.isEmpty())
return;
// send it to the console
events_.fireEvent(new SendToConsoleEvent(code, // execute
true, // focus
false));
return;
}
}
// don't let backspace perform browser back
DomUtils.preventBackspaceCausingBrowserBack(e);
// delegate to the shortcut manager
NativeKeyDownEvent evt = new NativeKeyDownEvent(e);
ShortcutManager.INSTANCE.onKeyDown(evt);
if (evt.isCanceled()) {
e.preventDefault();
e.stopPropagation();
// since this is a shortcut handled by the main window
// we set focus to it
WindowEx.get().focus();
}
}
use of org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent in project rstudio by rstudio.
the class Packages method loadPackage.
public void loadPackage(final String packageName, final String libName) {
// check status to make sure the package was unloaded
checkPackageStatusOnNextConsolePrompt(packageName, libName);
// send the command
StringBuilder command = new StringBuilder();
command.append("library(\"");
command.append(packageName);
command.append("\"");
command.append(", lib.loc=\"");
command.append(libName.replaceAll("\\\\", "\\\\\\\\"));
command.append("\"");
command.append(")");
events_.fireEvent(new SendToConsoleEvent(command.toString(), true));
}
Aggregations