use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class HelpStrategy method showPackageHelp.
private void showPackageHelp(final QualifiedName selectedItem, final CompletionPopupDisplay display) {
ParsedInfo cachedHelp = cache_.get(selectedItem);
if (cachedHelp != null) {
doShowPackageHelp(cachedHelp, display);
return;
}
final String packageName = selectedItem.name;
server_.getHelp(packageName, null, selectedItem.type, new ServerRequestCallback<HelpInfo>() {
@Override
public void onError(ServerError error) {
display.clearHelp(false);
}
@Override
public void onResponseReceived(HelpInfo response) {
if (response != null) {
ParsedInfo info = response.parse(packageName);
cache_.put(selectedItem, info);
doShowPackageHelp(info, display);
} else {
display.setHelpVisible(false);
display.clearHelp(false);
}
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class OptionsLoader method showOptions.
public void showOptions(final Class<?> paneClass) {
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error Reading Options");
indicator.onProgress("Reading options...");
server_.getRPrefs(new SimpleRequestCallback<RPrefs>() {
@Override
public void onResponseReceived(RPrefs rPrefs) {
indicator.onCompleted();
PreferencesDialog prefDialog = pPrefDialog_.get();
prefDialog.initialize(rPrefs);
if (paneClass != null)
prefDialog.activatePane(paneClass);
prefDialog.showModal();
// if the user changes global sweave or latex options notify
// them if this results in the current project being out
// of sync with the global settings
new SweaveProjectOptionsNotifier(prefDialog);
// the mac you can actually show prefs from a satellite window)
if (Desktop.isDesktop())
Desktop.getFrame().bringMainFrameToFront();
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class BuildPresenter method executeBuild.
private void executeBuild(final String type, final String subType) {
// attempt to start a build (this will be a silent no-op if there
// is already a build running)
workbenchContext_.setBuildInProgress(true);
sourceBuildHelper_.withSaveFilesBeforeCommand(new Command() {
@Override
public void execute() {
server_.startBuild(type, subType, new SimpleRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean response) {
}
@Override
public void onError(ServerError error) {
super.onError(error);
workbenchContext_.setBuildInProgress(false);
}
});
}
}, "Build");
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class DataImport method previewDataImport.
private void previewDataImport() {
Operation previewDataImportOperation = new Operation() {
@Override
public void execute() {
DataImportOptions previewImportOptions = getOptions();
if (dataImportFileChooser_.getText() == "") {
gridViewer_.setData(null);
return;
}
previewImportOptions.setMaxRows(maxRows_);
progressIndicator_.onProgress("Retrieving preview data...", new Operation() {
@Override
public void execute() {
progressIndicator_.clearProgress();
cleanPreviewResources();
server_.previewDataImportAsyncAbort(new ServerRequestCallback<Void>() {
@Override
public void onResponseReceived(Void empty) {
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
progressIndicator_.onError(error.getMessage());
}
});
}
});
server_.previewDataImportAsync(previewImportOptions, maxCols_, maxFactors_, new ServerRequestCallback<DataImportPreviewResponse>() {
@Override
public void onResponseReceived(DataImportPreviewResponse response) {
if (response == null || response.getErrorMessage() != null) {
if (response != null) {
setGridViewerData(response);
response.setColumnDefinitions(lastSuccessfulResponse_);
progressIndicator_.onError(enhancePreviewErrorMessage(response.getErrorMessage()));
}
return;
}
// Set the column definitions to allow subsequent calls to assemble
// generate preview code based on data.
importOptions_.setBaseColumnDefinitions(response);
lastSuccessfulResponse_ = response;
dataImportOptionsUi_.setPreviewResponse(response);
if (response.getLocalFiles() != null) {
localFiles_ = response.getLocalFiles();
}
gridViewer_.setOption("status", "Previewing first " + toLocaleString(maxRows_) + " entries. " + (response.getParsingErrors() > 0 ? Integer.toString(response.getParsingErrors()) + " parsing errors." : ""));
assignColumnDefinitions(response, importOptions_.getColumnDefinitions());
setGridViewerData(response);
progressIndicator_.onCompleted();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
cleanPreviewResources();
gridViewer_.setData(null);
progressIndicator_.onError(error.getMessage());
}
});
}
};
assembleDataImport(previewDataImportOperation);
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class HelpSearchOracle method requestSuggestions.
@Override
public void requestSuggestions(final Request request, final Callback callback) {
String query = request.getQuery();
server_.suggestTopics(query, new ServerRequestCallback<JsArrayString>() {
@Override
public void onError(ServerError error) {
}
@Override
public void onResponseReceived(JsArrayString suggestions) {
int maxCount = Math.min(suggestions.length(), request.getLimit());
ArrayList<SearchSuggestion> results = new ArrayList<SearchSuggestion>();
for (int i = 0; i < maxCount; i++) results.add(new SearchSuggestion(suggestions.get(i)));
callback.onSuggestionsReady(request, new Response(results));
}
});
;
}
Aggregations