Search in sources :

Example 16 with Handler

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

the class TextEditingTarget method onCompilePDF.

@Handler
void onCompilePDF() {
    String pdfPreview = prefs_.pdfPreview().getValue();
    boolean showPdf = !pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_NONE);
    boolean useInternalPreview = pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_RSTUDIO);
    boolean useDesktopSynctexPreview = pdfPreview.equals(UIPrefsAccessor.PDF_PREVIEW_DESKTOP_SYNCTEX) && Desktop.isDesktop();
    String action = new String();
    if (showPdf && !useInternalPreview && !useDesktopSynctexPreview)
        action = "view_external";
    handlePdfCommand(action, useInternalPreview, null);
}
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 17 with Handler

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

the class TextEditingTarget method onInsertChunk.

@Handler
void onInsertChunk() {
    InsertChunkInfo info = docDisplay_.getInsertChunkInfo();
    if (info == null)
        return;
    onInsertChunk(info.getValue(), 1, 0);
}
Also used : InsertChunkInfo(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Mode.InsertChunkInfo) 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 18 with Handler

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

the class TextEditingTarget method onRenameInScope.

@Handler
void onRenameInScope() {
    docDisplay_.focus();
    // Save folds (we need to remove them temporarily for the rename helper)
    final JsArray<AceFold> folds = docDisplay_.getFolds();
    docDisplay_.unfoldAll();
    int matches = renameHelper_.renameInScope();
    if (matches <= 0) {
        if (!docDisplay_.getSelectionValue().isEmpty()) {
            String message = "No matches for '" + docDisplay_.getSelectionValue() + "'";
            view_.getStatusBar().showMessage(message, 1000);
        }
        for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
        return;
    }
    String message = "Found " + matches;
    if (matches == 1)
        message += " match";
    else
        message += " matches";
    String selectedItem = docDisplay_.getSelectionValue();
    message += " for " + selectedItem + ".";
    docDisplay_.disableSearchHighlight();
    view_.getStatusBar().showMessage(message, new HideMessageHandler() {

        private boolean onRenameFinished(boolean value) {
            for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
            return value;
        }

        @Override
        public boolean onNativePreviewEvent(NativePreviewEvent preview) {
            int type = preview.getTypeInt();
            if (docDisplay_.isPopupVisible())
                return false;
            // End if the user clicks somewhere
            if (type == Event.ONCLICK) {
                docDisplay_.exitMultiSelectMode();
                docDisplay_.clearSelection();
                docDisplay_.enableSearchHighlight();
                return onRenameFinished(true);
            } else // Otherwise, handle key events
            if (type == Event.ONKEYDOWN) {
                switch(preview.getNativeEvent().getKeyCode()) {
                    case KeyCodes.KEY_ENTER:
                        preview.cancel();
                    case KeyCodes.KEY_UP:
                    case KeyCodes.KEY_DOWN:
                    case KeyCodes.KEY_ESCAPE:
                        docDisplay_.exitMultiSelectMode();
                        docDisplay_.clearSelection();
                        docDisplay_.enableSearchHighlight();
                        return onRenameFinished(true);
                }
            }
            return false;
        }
    });
}
Also used : AceFold(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AceFold) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) JsArrayString(com.google.gwt.core.client.JsArrayString) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) 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 19 with Handler

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

the class TextEditingTarget method onExecuteCurrentFunction.

@Handler
void onExecuteCurrentFunction() {
    docDisplay_.focus();
    // HACK: This is just to force the entire function tree to be built.
    // It's the easiest way to make sure getCurrentScope() returns
    // a Scope with an end.
    docDisplay_.getScopeTree();
    Scope currentFunction = docDisplay_.getCurrentFunction(false);
    // an unclosed function
    if (currentFunction == null || currentFunction.getEnd() == null)
        return;
    Position start = currentFunction.getPreamble();
    Position end = currentFunction.getEnd();
    codeExecution_.executeRange(Range.fromPoints(start, end));
}
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)

Example 20 with Handler

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

the class TextEditingTarget method onExecuteFromCurrentLine.

@Handler
void onExecuteFromCurrentLine() {
    docDisplay_.focus();
    int startRow = docDisplay_.getSelectionStart().getRow();
    int startColumn = 0;
    Position start = Position.create(startRow, startColumn);
    codeExecution_.executeRange(Range.fromPoints(start, endPosition()));
}
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) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) 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