use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class DataEditingTarget method updateData.
public void updateData(final DataItem data) {
final Widget originalWidget = progressPanel_.getWidget();
clearDisplay();
final String oldCacheKey = getCacheKey();
HashMap<String, String> props = new HashMap<String, String>();
data.fillProperties(props);
server_.modifyDocumentProperties(doc_.getId(), props, new SimpleRequestCallback<Void>("Error") {
@Override
public void onResponseReceived(Void response) {
server_.removeCachedData(oldCacheKey, new ServerRequestCallback<Void>() {
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
data.fillProperties(doc_.getProperties());
reloadDisplay();
}
@Override
public void onError(ServerError error) {
super.onError(error);
progressPanel_.setWidget(originalWidget);
}
});
}
use of org.rstudio.studio.client.server.ServerError 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);
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Source method openNotebook.
private void openNotebook(final FileSystemItem rmdFile, final SourceDocumentResult doc, final ResultCallback<EditingTarget, ServerError> resultCallback) {
if (!StringUtil.isNullOrEmpty(doc.getDocPath())) {
// this happens if we created the R Markdown file, or if the R Markdown
// file on disk matched the one inside the notebook
openFileFromServer(rmdFile, FileTypeRegistry.RMARKDOWN, resultCallback);
} else if (!StringUtil.isNullOrEmpty(doc.getDocId())) {
// this happens when we have to open an untitled buffer for the the
// notebook (usually because the of a conflict between the Rmd on disk
// and the one in the .nb.html file)
server_.getSourceDocument(doc.getDocId(), new ServerRequestCallback<SourceDocument>() {
@Override
public void onResponseReceived(SourceDocument doc) {
// create the editor
EditingTarget target = addTab(doc, OPEN_INTERACTIVE);
// show a warning bar
if (target instanceof TextEditingTarget) {
((TextEditingTarget) target).showWarningMessage("This notebook has the same name as an R Markdown " + "file, but doesn't match it.");
}
resultCallback.onSuccess(target);
}
@Override
public void onError(ServerError error) {
globalDisplay_.showErrorMessage("Notebook Open Failed", "This notebook could not be opened. " + "If the error persists, try removing the " + "accompanying R Markdown file. \n\n" + error.getMessage());
resultCallback.onFailure(error);
}
});
}
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Source method onShowProfiler.
public void onShowProfiler(OpenProfileEvent event) {
String profilePath = event.getFilePath();
String htmlPath = event.getHtmlPath();
String htmlLocalPath = event.getHtmlLocalPath();
// first try to activate existing
for (int idx = 0; idx < editors_.size(); idx++) {
String path = editors_.get(idx).getPath();
if (path != null && profilePath.equals(path)) {
ensureVisible(false);
view_.selectTab(idx);
return;
}
}
// create new profiler
ensureVisible(true);
if (event.getDocId() != null) {
server_.getSourceDocument(event.getDocId(), new ServerRequestCallback<SourceDocument>() {
@Override
public void onResponseReceived(SourceDocument response) {
addTab(response, OPEN_INTERACTIVE);
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
globalDisplay_.showErrorMessage("Source Document Error", error.getUserMessage());
}
});
} else {
server_.newDocument(FileTypeRegistry.PROFILER.getTypeId(), null, (JsObject) ProfilerContents.create(profilePath, htmlPath, htmlLocalPath, event.getCreateProfile()).cast(), new SimpleRequestCallback<SourceDocument>("Show Profiler") {
@Override
public void onResponseReceived(SourceDocument response) {
addTab(response, OPEN_INTERACTIVE);
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
globalDisplay_.showErrorMessage("Source Document Error", error.getUserMessage());
}
});
}
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class SourceWindowManager method assignSourceDocWindowId.
private void assignSourceDocWindowId(String docId, String windowId, final Command onComplete) {
// assign locally
JsArray<SourceDocument> docs = getSourceDocs();
for (int i = 0; i < docs.length(); i++) {
SourceDocument doc = docs.get(i);
if (doc.getId() == docId) {
// it
if (doc.getSourceWindowId() == windowId)
return;
doc.assignSourceWindowId(windowId);
break;
}
}
// create the new property map
HashMap<String, String> props = new HashMap<String, String>();
props.put(SOURCE_WINDOW_ID, windowId);
// update the doc window ID on the server
server_.modifyDocumentProperties(docId, props, new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void v) {
if (onComplete != null)
onComplete.execute();
}
@Override
public void onError(ServerError error) {
display_.showErrorMessage("Can't Move Doc", "The document could not be " + "moved to a different window: \n" + error.getMessage());
}
});
}
Aggregations