Search in sources :

Example 46 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class TextEditingTarget method onClearPrerenderedOutput.

@Handler
void onClearPrerenderedOutput() {
    withSavedDoc(new Command() {

        @Override
        public void execute() {
            // determine the output path (use relative path if possible)
            String path = docUpdateSentinel_.getPath();
            String relativePath = FileSystemItem.createFile(path).getPathRelativeTo(workbenchContext_.getCurrentWorkingDir());
            if (relativePath != null)
                path = relativePath;
            final String docPath = path;
            globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Clear Prerendered Output", "This will remove all previously generated output " + "for " + docPath + " (html, prerendered data, knitr cache, etc.)." + "\n\nAre you sure you want to clear the output now?", false, new Operation() {

                @Override
                public void execute() {
                    String code = "rmarkdown::shiny_prerendered_clean(" + ConsoleDispatcher.escapedPath(docPath) + ")";
                    events_.fireEvent(new SendToConsoleEvent(code, true));
                }
            }, null, true);
        }
    });
}
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) CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 47 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class TextEditingTarget method onPreviewHTML.

@Handler
void onPreviewHTML() {
    // last ditch extended type detection
    String extendedType = extendedType_;
    extendedType = rmarkdownHelper_.detectExtendedType(docDisplay_.getCode(), extendedType, fileType_);
    if (extendedType == SourceDocument.XT_RMARKDOWN) {
        renderRmd();
    } else if (fileType_.isRd())
        previewRd();
    else if (fileType_.isRpres())
        previewRpresentation();
    else if (fileType_.isR())
        onCompileNotebook();
    else
        previewHTML();
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 48 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class TextEditingTarget method onFoldAll.

@Handler
void onFoldAll() {
    if (useScopeTreeFolding()) {
        // Fold all except anonymous braces
        HashSet<Integer> rowsFolded = new HashSet<Integer>();
        for (AceFold f : JsUtil.asIterable(docDisplay_.getFolds())) rowsFolded.add(f.getStart().getRow());
        ScopeList scopeList = new ScopeList(docDisplay_);
        scopeList.removeAll(ScopeList.ANON_BRACE);
        for (Scope scope : scopeList) {
            int row = scope.getFoldStart().getRow();
            if (!rowsFolded.contains(row))
                docDisplay_.addFoldFromRow(row);
        }
    } else {
        docDisplay_.foldAll();
    }
}
Also used : AceFold(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AceFold) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) HashSet(java.util.HashSet) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 49 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class TextEditingTarget method onClearKnitrCache.

@Handler
void onClearKnitrCache() {
    withSavedDoc(new Command() {

        @Override
        public void execute() {
            // determine the cache path (use relative path if possible)
            String path = docUpdateSentinel_.getPath();
            FileSystemItem fsi = FileSystemItem.createFile(path);
            path = fsi.getParentPath().completePath(fsi.getStem() + "_cache");
            String relativePath = FileSystemItem.createFile(path).getPathRelativeTo(workbenchContext_.getCurrentWorkingDir());
            if (relativePath != null)
                path = relativePath;
            final String docPath = path;
            globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Clear Knitr Cache", "Clearing the Knitr cache will delete the cache " + "directory for " + docPath + ". " + "\n\nAre you sure you want to clear the cache now?", false, new Operation() {

                @Override
                public void execute() {
                    String code = "unlink(" + ConsoleDispatcher.escapedPath(docPath) + ", recursive = TRUE)";
                    events_.fireEvent(new SendToConsoleEvent(code, true));
                }
            }, null, true);
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) 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) CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 50 with Handler

use of org.rstudio.core.client.command.Handler in project rstudio by rstudio.

the class TextEditingTarget method onGoToEndOfCurrentScope.

@Handler
void onGoToEndOfCurrentScope() {
    docDisplay_.focus();
    Scope scope = docDisplay_.getCurrentScope();
    if (scope != null) {
        Position end = scope.getEnd();
        if (end != null) {
            Position position = Position.create(end.getRow(), Math.max(0, end.getColumn() - 1));
            docDisplay_.setCursorPosition(position);
        }
    }
}
Also used : InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Aggregations

Handler (org.rstudio.core.client.command.Handler)55 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)20 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)19 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)19 FileChangeHandler (org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)18 HideMessageHandler (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler)18 RecordNavigationPositionHandler (org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler)18 JsArrayString (com.google.gwt.core.client.JsArrayString)12 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)12 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)11 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)10 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)9 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)8 SelectionHandler (com.google.gwt.event.logical.shared.SelectionHandler)8 Command (com.google.gwt.user.client.Command)8 ServerError (org.rstudio.studio.client.server.ServerError)7 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)7 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)6 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)6 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)6