Search in sources :

Example 11 with TextEditingTarget

use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.

the class Source method withTarget.

private void withTarget(String id, CommandWithArg<TextEditingTarget> command, Command onFailure) {
    EditingTarget target = StringUtil.isNullOrEmpty(id) ? activeEditor_ : getEditingTargetForId(id);
    if (target == null) {
        if (onFailure != null)
            onFailure.execute();
        return;
    }
    if (!(target instanceof TextEditingTarget)) {
        if (onFailure != null)
            onFailure.execute();
        return;
    }
    command.execute((TextEditingTarget) target);
}
Also used : TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)

Example 12 with TextEditingTarget

use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.

the class Source method pasteFileContentsAtCursor.

private void pasteFileContentsAtCursor(final String path, final String encoding) {
    if (activeEditor_ != null && activeEditor_ instanceof TextEditingTarget) {
        final TextEditingTarget target = (TextEditingTarget) activeEditor_;
        server_.getFileContents(path, encoding, new ServerRequestCallback<String>() {

            @Override
            public void onResponseReceived(String content) {
                target.insertCode(content, false);
            }

            @Override
            public void onError(ServerError error) {
                Debug.logError(error);
            }
        });
    }
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) JSONString(com.google.gwt.json.client.JSONString) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 13 with TextEditingTarget

use of org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget in project rstudio by rstudio.

the class Source method reindent.

private void reindent() {
    if (activeEditor_ != null && activeEditor_ instanceof TextEditingTarget) {
        TextEditingTarget editor = (TextEditingTarget) activeEditor_;
        editor.getDocDisplay().reindent();
    }
}
Also used : TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)

Aggregations

TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)13 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)5 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)5 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)5 ServerError (org.rstudio.studio.client.server.ServerError)4 JsArrayString (com.google.gwt.core.client.JsArrayString)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 JSONString (com.google.gwt.json.client.JSONString)2 Command (com.google.gwt.user.client.Command)2 AppCommand (org.rstudio.core.client.command.AppCommand)2 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)2 InputEditorDisplay (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorDisplay)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)1 SelectionHandler (com.google.gwt.event.logical.shared.SelectionHandler)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)1 Handler (org.rstudio.core.client.command.Handler)1 EditableFileType (org.rstudio.studio.client.common.filetypes.EditableFileType)1 OpenSourceFileHandler (org.rstudio.studio.client.common.filetypes.events.OpenSourceFileHandler)1