Search in sources :

Example 21 with SendToConsoleEvent

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

Example 22 with SendToConsoleEvent

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

Example 23 with SendToConsoleEvent

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

Example 24 with SendToConsoleEvent

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));
}
Also used : SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 25 with SendToConsoleEvent

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();
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) Range(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)

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