Search in sources :

Example 11 with SourceDocument

use of org.rstudio.studio.client.workbench.views.source.model.SourceDocument in project rstudio by rstudio.

the class Source method openFileFromServer.

private void openFileFromServer(final FileSystemItem file, final TextFileType fileType, final ResultCallback<EditingTarget, ServerError> resultCallback) {
    final Command dismissProgress = globalDisplay_.showProgress("Opening file...");
    server_.openDocument(file.getPath(), fileType.getTypeId(), uiPrefs_.defaultEncoding().getValue(), new ServerRequestCallback<SourceDocument>() {

        @Override
        public void onError(ServerError error) {
            dismissProgress.execute();
            pMruList_.get().remove(file.getPath());
            Debug.logError(error);
            if (resultCallback != null)
                resultCallback.onFailure(error);
        }

        @Override
        public void onResponseReceived(SourceDocument document) {
            dismissProgress.execute();
            pMruList_.get().add(document.getPath());
            EditingTarget target = addTab(document, OPEN_INTERACTIVE);
            if (resultCallback != null)
                resultCallback.onSuccess(target);
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ServerError(org.rstudio.studio.client.server.ServerError) SourceDocument(org.rstudio.studio.client.workbench.views.source.model.SourceDocument) 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)

Aggregations

SourceDocument (org.rstudio.studio.client.workbench.views.source.model.SourceDocument)11 ServerError (org.rstudio.studio.client.server.ServerError)7 JsArrayString (com.google.gwt.core.client.JsArrayString)6 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)5 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)5 JSONString (com.google.gwt.json.client.JSONString)4 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)4 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)4 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)4 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)3 Command (com.google.gwt.user.client.Command)2 ProfileOperationResponse (org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArray (com.google.gwt.core.client.JsArray)1 Scheduler (com.google.gwt.core.client.Scheduler)1 HashMap (java.util.HashMap)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 Handler (org.rstudio.core.client.command.Handler)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 Operation (org.rstudio.core.client.widget.Operation)1