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();
}
});
}
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);
}
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()));
}
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);
}
});
}
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);
}
});
}
Aggregations