Search in sources :

Example 1 with ProfileOperationRequest

use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest 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 2 with ProfileOperationRequest

use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest in project rstudio by rstudio.

the class ProfilerPresenter method onStartProfiler.

@Handler
public void onStartProfiler() {
    dependencyManager_.withProfvis(profilerDependecyUserAction_, new Command() {

        @Override
        public void execute() {
            ProfileOperationRequest request = ProfileOperationRequest.create("");
            server_.startProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {

                @Override
                public void onResponseReceived(ProfileOperationResponse response) {
                    if (response.getErrorMessage() != null) {
                        globalDisplay_.showErrorMessage("Profiler Error", response.getErrorMessage());
                        return;
                    }
                    pSourceWindowManager_.get().ensureVisibleSourcePaneIfNecessary();
                    response_ = response;
                    sourceServer_.newDocument(FileTypeRegistry.PROFILER.getTypeId(), null, (JsObject) ProfilerContents.create(response.getFileName(), null, null, true).cast(), new SimpleRequestCallback<SourceDocument>("Show Profiler") {

                        @Override
                        public void onResponseReceived(SourceDocument response) {
                            currentDocId_ = response.getId();
                        }

                        @Override
                        public void onError(ServerError error) {
                            Debug.logError(error);
                        }
                    });
                }

                @Override
                public void onError(ServerError error) {
                    Debug.logError(error);
                    globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
                }
            });
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) SourceDocument(org.rstudio.studio.client.workbench.views.source.model.SourceDocument) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) ProfileOperationResponse(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse) ProfileOperationRequest(org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest) Handler(org.rstudio.core.client.command.Handler)

Example 3 with ProfileOperationRequest

use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest in project rstudio by rstudio.

the class ProfilerPresenter method onStopProfiler.

@Handler
public void onStopProfiler() {
    ProfileOperationRequest request = ProfileOperationRequest.create(response_ != null ? response_.getFileName() : null);
    response_ = null;
    server_.stopProfiling(request, new ServerRequestCallback<ProfileOperationResponse>() {

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

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
            globalDisplay_.showErrorMessage("Failed to Stop Profiler", error.getMessage());
        }
    });
}
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) Handler(org.rstudio.core.client.command.Handler)

Aggregations

ServerError (org.rstudio.studio.client.server.ServerError)3 ProfileOperationRequest (org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationRequest)3 ProfileOperationResponse (org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse)3 Handler (org.rstudio.core.client.command.Handler)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 Command (com.google.gwt.user.client.Command)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1 SourceDocument (org.rstudio.studio.client.workbench.views.source.model.SourceDocument)1