Search in sources :

Example 16 with SendToConsoleEvent

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));
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)

Example 17 with SendToConsoleEvent

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);
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 18 with SendToConsoleEvent

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();
}
Also used : ImportFileSettingsDialogResult(org.rstudio.studio.client.workbench.views.environment.dataimport.ImportFileSettingsDialogResult) ImportFileSettingsDialog(org.rstudio.studio.client.workbench.views.environment.dataimport.ImportFileSettingsDialog) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) ImportFileSettings(org.rstudio.studio.client.workbench.views.environment.dataimport.ImportFileSettings) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 19 with SendToConsoleEvent

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();
    }
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) NativeKeyDownEvent(org.rstudio.core.client.events.NativeKeyDownEvent)

Example 20 with SendToConsoleEvent

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));
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)

Aggregations

SendToConsoleEvent (org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent)27 JsArrayString (com.google.gwt.core.client.JsArrayString)8 Command (com.google.gwt.user.client.Command)6 AppCommand (org.rstudio.core.client.command.AppCommand)5 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 Handler (org.rstudio.core.client.command.Handler)4 Operation (org.rstudio.core.client.widget.Operation)3 Timer (com.google.gwt.user.client.Timer)2 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)2 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)2 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)2 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)2 FileChangeHandler (org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)2 CppCompletionOperation (org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation)2 HideMessageHandler (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler)2 RecordNavigationPositionHandler (org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler)2 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1