use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Synctex method forwardSearch.
// NOTE: the original design was for a single internal pdf viewer. for
// that configuration we could keep a global pdfPath_ around and be
// confident that it was always correct. we were also globally managing
// the state of the synctex command based on any external viewer closing.
// now that we optionally support desktop viewers for synctex this
// assumption may not hold -- specfically there might be multiple active
// PDF viewers for different document or we might not know that the
// external viewer has closed . we have explicitly chosen to
// avoid the complexity of tracking distinct viewer states. if we want
// to do this we probably should do the following:
//
// - always keep the the syncex command available in all editors
// so long as there is at least one preview window alive; OR
//
// - for cases where we do know whether the window is still alive
// editors could dynamically show/hide their synctex button
// based on that more granular state
//
public boolean forwardSearch(final String pdfFile, SourceLocation sourceLocation) {
if (handleDesktopSynctex()) {
// apply concordane
final ProgressIndicator indicator = getSyncProgress();
server_.applyForwardConcordance(pdfFile, sourceLocation, new ServerRequestCallback<SourceLocation>() {
@Override
public void onResponseReceived(SourceLocation sourceLocation) {
indicator.onCompleted();
if (sourceLocation != null) {
Desktop.getFrame().externalSynctexView(pdfFile, sourceLocation.getFile(), sourceLocation.getLine(), sourceLocation.getColumn());
}
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
return true;
} else // use internal viewer
{
doForwardSearch(targetFile_, sourceLocation);
return true;
}
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class RoxygenHelper method insertRoxygenSkeletonSetMethod.
private void insertRoxygenSkeletonSetMethod(TokenCursor cursor) {
final Position startPos = cursor.currentPosition();
String call = extractCall(cursor);
if (call == null)
return;
server_.getSetMethodCall(call, new ServerRequestCallback<SetMethodCall>() {
@Override
public void onResponseReceived(SetMethodCall response) {
if (hasRoxygenBlock(startPos)) {
amendExistingRoxygenBlock(startPos.getRow() - 1, response.getGeneric(), response.getParameterNames(), response.getParameterTypes(), "param", RE_ROXYGEN_PARAM);
} else {
insertRoxygenTemplate(response.getGeneric(), response.getParameterNames(), response.getParameterTypes(), "param", "method", 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 insertRoxygenSkeletonS4Class.
private void insertRoxygenSkeletonS4Class(TokenCursor cursor) {
final Position startPos = cursor.currentPosition();
String setClassCall = extractCall(cursor);
if (setClassCall == null)
return;
server_.getSetClassCall(setClassCall, new ServerRequestCallback<SetClassCall>() {
@Override
public void onResponseReceived(SetClassCall response) {
if (hasRoxygenBlock(startPos)) {
amendExistingRoxygenBlock(startPos.getRow() - 1, response.getClassName(), response.getSlots(), null, "slot", RE_ROXYGEN_SLOT);
} else {
insertRoxygenTemplate(response.getClassName(), response.getSlots(), response.getTypes(), "slot", "S4 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 RPubsUploader method performUpload.
// Private methods --------------------------------------------------------
private void performUpload(final String title, final String rmdFile, final String htmlFile, final String uploadId, final WindowEx progressWindow, final boolean modify) {
// record progress window
uploadProgressWindow_ = progressWindow;
// subscribe to notification of upload completion
eventRegistrations_.add(eventBus_.addHandler(RPubsUploadStatusEvent.TYPE, new RPubsUploadStatusEvent.Handler() {
@Override
public void onRPubsPublishStatus(RPubsUploadStatusEvent event) {
// make sure it applies to our context
RPubsUploadStatusEvent.Status status = event.getStatus();
if (!status.getContextId().equals(contextId_))
return;
uploadInProgress_ = false;
onUploadComplete(true);
if (!StringUtil.isNullOrEmpty(status.getError())) {
if (progressWindow != null)
progressWindow.close();
new ConsoleProgressDialog("Upload Error Occurred", status.getError(), 1).showModal();
} else {
if (progressWindow != null) {
progressWindow.replaceLocationHref(status.getContinueUrl());
} else {
globalDisplay_.openWindow(status.getContinueUrl());
}
}
}
}));
// initiate the upload
server_.rpubsUpload(contextId_, title, rmdFile == null ? "" : rmdFile, htmlFile, uploadId == null ? "" : uploadId, modify, new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean response) {
if (!response.booleanValue()) {
onUploadComplete(false);
globalDisplay_.showErrorMessage("Error", "Unable to continue " + "(another publish is currently running)");
}
}
@Override
public void onError(ServerError error) {
onUploadComplete(false);
globalDisplay_.showErrorMessage("Error", error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class BreakpointManager method setFunctionBreakpoints.
// Private methods ---------------------------------------------------------
private void setFunctionBreakpoints(FileFunction function) {
ArrayList<String> steps = new ArrayList<String>();
final ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
for (Breakpoint breakpoint : breakpoints_) {
if (function.containsBreakpoint(breakpoint)) {
steps.add(breakpoint.getFunctionSteps());
breakpoints.add(breakpoint);
}
}
server_.setFunctionBreakpoints(function.functionName, function.fileName, function.packageName, steps, new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void v) {
for (Breakpoint breakpoint : breakpoints) {
breakpoint.setState(Breakpoint.STATE_ACTIVE);
}
notifyBreakpointsSaved(breakpoints, true);
}
@Override
public void onError(ServerError error) {
discardUnsettableBreakpoints(breakpoints);
}
});
}
Aggregations