Search in sources :

Example 31 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class ProfilerPresenter method buildHtmlPath.

public void buildHtmlPath(final OperationWithInput<ProfileOperationResponse> continuation, final Operation onError, final String path) {
    ProfileOperationRequest request = ProfileOperationRequest.create(path);
    server_.openProfile(request, new ServerRequestCallback<ProfileOperationResponse>() {

        @Override
        public void onResponseReceived(ProfileOperationResponse response) {
            if (response.getErrorMessage() != null) {
                globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
                onError.execute();
                return;
            }
            continuation.execute(response);
        }

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
            globalDisplay_.showErrorMessage("Failed to Open Profile", error.getMessage());
            onError.execute();
        }
    });
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest)

Example 32 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class ApplicationClientInit method execute.

public void execute(final ServerRequestCallback<SessionInfo> requestCallback, final boolean retryOnTransmissionError) {
    // reset internal state 
    timedOut_ = false;
    timeoutTimer_ = null;
    // send the request
    final ServerRequestCallback<SessionInfo> rpcRequestCallback = new ServerRequestCallback<SessionInfo>() {

        @Override
        public void onResponseReceived(SessionInfo sessionInfo) {
            if (!timedOut_) {
                cancelTimeoutTimer();
                requestCallback.onResponseReceived(sessionInfo);
            }
        }

        @Override
        public void onError(ServerError error) {
            if (!timedOut_) {
                cancelTimeoutTimer();
                if ((error.getCode() == ServerError.TRANSMISSION) && retryOnTransmissionError) {
                    // transmission error can occur due to a race 
                    // condition when switching projects or versions, for
                    // this case wait 1000ms then retry
                    new Timer() {

                        @Override
                        public void run() {
                            // retry (specify flag to ensure we only retry once)
                            execute(requestCallback, false);
                        }
                    }.schedule(1000);
                } else {
                    requestCallback.onError(error);
                }
            }
        }
    };
    server_.clientInit(rpcRequestCallback);
    // wait for 60 seconds then ask the user if they want to issue an 
    // interrupt to the server
    int timeoutMs = 60000;
    timeoutTimer_ = new Timer() {

        public void run() {
            // set timed out flag
            timedOut_ = true;
            // cancel our request
            rpcRequestCallback.cancel();
            // ask the user if they want to attempt to interrupt the server
            globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, // caption
            "Initializing RStudio", // message
            "The RStudio server is taking a long time to respond. It is " + "possible that your R session has become unresponsive. " + "Do you want to terminate the currently running R session?", // don't include cancel
            false, // Yes operation
            new Operation() {

                public void execute() {
                    // call interrupt then call this method back on success
                    server_.abort(null, new ServerRequestCallback<Void>() {

                        @Override
                        public void onResponseReceived(Void response) {
                            // reload the application
                            reloadWithDelay(1000);
                        }

                        @Override
                        public void onError(ServerError error) {
                            // if we get an error during interrupt then just
                            // forward the error on to the original handler
                            requestCallback.onError(error);
                        }
                    });
                }
            }, // No operation
            new Operation() {

                public void execute() {
                    // keep trying (reload to clear out any crufty app
                    // or networking state)
                    reloadWithDelay(1);
                }
            }, // Cancel operation (none)
            null, "Terminate R", "Keep Waiting", // default to No
            false);
        }
    };
    // activate the timer
    timeoutTimer_.schedule(timeoutMs);
}
Also used : Timer(com.google.gwt.user.client.Timer) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) Operation(org.rstudio.core.client.widget.Operation) Void(org.rstudio.studio.client.server.Void)

Example 33 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class ChunkSatelliteWindow method onInitialize.

@Override
protected void onInitialize(LayoutPanel mainPanel, JavaScriptObject params) {
    chunkWindowParams_ = params.cast();
    String title = "RStudio: Notebook Output";
    Window.setTitle(title);
    ChunkOutputHost chunkOutputHost = new ChunkOutputHost() {

        @Override
        public void onOutputRemoved(final ChunkOutputWidget widget) {
        }

        @Override
        public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
        }
    };
    chunkOutputWidget_ = new ChunkOutputWidget(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, // can close
    false, chunkOutputHost, ChunkOutputSize.Full);
    Element ele = chunkOutputWidget_.getElement();
    ele.addClassName(ThemeStyles.INSTANCE.selectableText());
    // Append the chunkOutputWidget as an HTML element, not as a widget.
    // Why? Chunks are widgets that are attached to the ACE editor as HTML
    // elements, not as widgets. The reason being that GWT does not support
    // triggering events for widgets that are not attached to their hierarchy.
    // Therefore, if we attach this element as a widget, GWT will remove 
    // events in some cases which will cause functionality to be lost.
    mainPanel.getElement().appendChild(chunkOutputWidget_.getElement());
    chunkOutputWidget_.getElement().getStyle().setHeight(100, Unit.PCT);
    mainPanel.addStyleName("ace_editor");
    pEventBus_.get().addHandler(ChunkSatelliteCodeExecutingEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkSatelliteCacheEditorStyleEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkPlotRefreshedEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkPlotRefreshFinishedEvent.TYPE, this);
    pEventBus_.get().addHandler(ChunkChangeEvent.TYPE, this);
    pEventBus_.get().addHandler(RmdChunkOutputFinishedEvent.TYPE, this);
    pEventBus_.get().addHandler(RmdChunkOutputEvent.TYPE, this);
    Window.addWindowClosingHandler(new ClosingHandler() {

        @Override
        public void onWindowClosing(ClosingEvent arg0) {
            server_.cleanReplayNotebookChunkPlots(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId(), new ServerRequestCallback<Void>() {

                @Override
                public void onError(ServerError error) {
                }
            });
        }
    });
    pEventBus_.get().fireEventToMainWindow(new ChunkSatelliteWindowOpenedEvent(chunkWindowParams_.getDocId(), chunkWindowParams_.getChunkId()));
}
Also used : ChunkSatelliteWindowOpenedEvent(org.rstudio.studio.client.workbench.views.source.editors.text.events.ChunkSatelliteWindowOpenedEvent) ChunkOutputHost(org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost) ServerError(org.rstudio.studio.client.server.ServerError) Element(com.google.gwt.dom.client.Element) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) ClosingEvent(com.google.gwt.user.client.Window.ClosingEvent) ClosingHandler(com.google.gwt.user.client.Window.ClosingHandler)

Example 34 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class RoxygenHelper method insertRoxygenSkeletonSetRefClass.

private void insertRoxygenSkeletonSetRefClass(TokenCursor cursor) {
    final Position startPos = cursor.currentPosition();
    String call = extractCall(cursor);
    if (call == null)
        return;
    server_.getSetRefClassCall(call, new ServerRequestCallback<SetRefClassCall>() {

        @Override
        public void onResponseReceived(SetRefClassCall response) {
            if (hasRoxygenBlock(startPos)) {
                amendExistingRoxygenBlock(startPos.getRow() - 1, response.getClassName(), response.getFieldNames(), response.getFieldTypes(), "field", RE_ROXYGEN_FIELD);
            } else {
                insertRoxygenTemplate(response.getClassName(), response.getFieldNames(), response.getFieldTypes(), "field", "reference class", startPos);
            }
        }

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

Example 35 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class RoxygenHelper method insertRoxygenSkeletonSetGeneric.

private void insertRoxygenSkeletonSetGeneric(TokenCursor cursor) {
    final Position startPos = cursor.currentPosition();
    String call = extractCall(cursor);
    if (call == null)
        return;
    server_.getSetGenericCall(call, new ServerRequestCallback<SetGenericCall>() {

        @Override
        public void onResponseReceived(SetGenericCall response) {
            if (hasRoxygenBlock(startPos)) {
                amendExistingRoxygenBlock(startPos.getRow() - 1, response.getGeneric(), response.getParameters(), null, "param", RE_ROXYGEN_PARAM);
            } else {
                insertRoxygenTemplate(response.getGeneric(), response.getParameters(), null, "param", "generic function", startPos);
            }
        }

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

Aggregations

ServerError (org.rstudio.studio.client.server.ServerError)109 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)26 JsArrayString (com.google.gwt.core.client.JsArrayString)22 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)20 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)18 Void (org.rstudio.studio.client.server.Void)16 ArrayList (java.util.ArrayList)13 JsArray (com.google.gwt.core.client.JsArray)12 Command (com.google.gwt.user.client.Command)11 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)10 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)9 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)9 Operation (org.rstudio.core.client.widget.Operation)8 Handler (org.rstudio.core.client.command.Handler)7 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)7 JSONString (com.google.gwt.json.client.JSONString)6 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)6 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)6 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)6 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)6