Search in sources :

Example 6 with SendToConsoleEvent

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

Example 7 with SendToConsoleEvent

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;
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) TreeSet(java.util.TreeSet) CallFrame(org.rstudio.studio.client.workbench.views.environment.model.CallFrame) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 8 with SendToConsoleEvent

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

Example 9 with SendToConsoleEvent

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();
}
Also used : ServerDataSource(org.rstudio.studio.client.server.ServerDataSource) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) OperationWithInput(org.rstudio.core.client.widget.OperationWithInput) ArrayList(java.util.ArrayList) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) PackageUpdate(org.rstudio.studio.client.workbench.views.packages.model.PackageUpdate) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) CheckForUpdatesDialog(org.rstudio.studio.client.workbench.views.packages.ui.CheckForUpdatesDialog) Operation(org.rstudio.core.client.widget.Operation)

Example 10 with SendToConsoleEvent

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();
    }
}
Also used : SourcePosition(org.rstudio.studio.client.workbench.views.source.model.SourcePosition) NewDocumentWithCodeEvent(org.rstudio.studio.client.workbench.views.source.events.NewDocumentWithCodeEvent) 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