use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse 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();
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse 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());
}
});
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse 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());
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.profiler.model.ProfileOperationResponse in project rstudio by rstudio.
the class ProfilerEditingTarget method onActivate.
public void onActivate() {
activeProfilerEditingTarger_ = this;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
commands_.gotoProfileSource().setEnabled(hasValidPath_);
}
});
final Operation activateOperation = new Operation() {
@Override
public void execute() {
if (!htmlPathInitialized_) {
htmlPathInitialized_ = true;
htmlPath_ = getContents().getHtmlPath();
htmlLocalPath_ = getContents().getHtmlLocalPath();
isUserSaved_ = getContents().isUserSaved();
if (htmlPath_ == null) {
presenter_.buildHtmlPath(new OperationWithInput<ProfileOperationResponse>() {
@Override
public void execute(ProfileOperationResponse response) {
htmlPath_ = response.getHtmlPath();
htmlLocalPath_ = response.getHtmlLocalPath();
persistDocumentProperty("htmlPath", htmlPath_);
persistDocumentProperty("htmlLocalPath", htmlLocalPath_);
view_.showProfilePage(htmlPath_);
pSourceWindowManager_.get().maximizeSourcePaneIfNecessary();
}
}, new Operation() {
@Override
public void execute() {
server_.clearProfile(getPath(), new ServerRequestCallback<JavaScriptObject>() {
@Override
public void onResponseReceived(JavaScriptObject response) {
commands_.closeSourceDoc().execute();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
commands_.closeSourceDoc().execute();
}
});
}
}, getPath());
} else {
view_.showProfilePage(htmlPath_);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
pSourceWindowManager_.get().maximizeSourcePaneIfNecessary();
}
});
}
}
}
};
if (getId() != null && !SourceWindowManager.isMainSourceWindow()) {
sourceServer_.getSourceDocument(getId(), new ServerRequestCallback<SourceDocument>() {
@Override
public void onResponseReceived(SourceDocument document) {
doc_ = document;
activateOperation.execute();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
} else {
activateOperation.execute();
}
// This shouldn't happen though.
if (commandHandlerReg_ != null) {
Debug.log("Warning: onActivate called twice without intervening onDeactivate");
commandHandlerReg_.removeHandler();
commandHandlerReg_ = null;
}
commandHandlerReg_ = commandBinder.bind(commands_, this);
}
Aggregations