use of org.rstudio.studio.client.server.ServerRequestCallback in project rstudio by rstudio.
the class Ignore method showDialog.
private void showDialog(final String initialPath, String ignores, final Strategy strategy) {
final Display display = pDisplay_.get();
final ProgressIndicator indicator = display.progressIndicator();
display.setDialogCaption(strategy.getDialogCaption());
display.setIgnoresCaption(strategy.getIgnoresCaption());
display.setHelpLinkName(strategy.getHelpLinkName());
display.setCurrentPath(initialPath);
display.setIgnored(ignores);
display.scrollToBottom();
display.addPathChangedHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
display.setIgnored("");
indicator.onProgress("Getting ignored files for path...");
strategy.getIgnores(display.getCurrentPath(), new ServerRequestCallback<ProcessResult>() {
@Override
public void onResponseReceived(final ProcessResult result) {
indicator.clearProgress();
if (checkForProcessError(strategy.getDialogCaption(), result))
return;
display.setIgnored(result.getOutput());
display.focusIgnored();
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
});
display.saveButton().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
indicator.onProgress("Setting ignored files for path...");
strategy.setIgnores(display.getCurrentPath(), display.getIgnored(), new ServerRequestCallback<ProcessResult>() {
@Override
public void onResponseReceived(ProcessResult result) {
indicator.onCompleted();
checkForProcessError(strategy.getDialogCaption(), result);
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
});
display.showModal();
}
use of org.rstudio.studio.client.server.ServerRequestCallback in project rstudio by rstudio.
the class NewRSConnectAuthPage method pollForAuthCompleted.
private void pollForAuthCompleted() {
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
// don't keep polling once auth is complete or window is closed
if (!waitingForAuth_.getValue())
return false;
// returned for some reason, just wait for it to finish
if (runningAuthCompleteCheck_)
return true;
runningAuthCompleteCheck_ = true;
server_.getUserFromToken(result_.getServerInfo().getUrl(), result_.getPreAuthToken(), new ServerRequestCallback<RSConnectAuthUser>() {
@Override
public void onResponseReceived(RSConnectAuthUser user) {
runningAuthCompleteCheck_ = false;
// just wait and try again
if (!user.isValidUser())
return;
// user is valid--cache account info and close the
// window
result_.setAuthUser(user);
waitingForAuth_.setValue(false, true);
if (Desktop.isDesktop()) {
// on the desktop, we can close the window by name
Desktop.getFrame().closeNamedWindow(AUTH_WINDOW_NAME);
}
onUserAuthVerified();
}
@Override
public void onError(ServerError error) {
// ignore this error
runningAuthCompleteCheck_ = false;
}
});
return true;
}
}, 1000);
}
use of org.rstudio.studio.client.server.ServerRequestCallback in project rstudio by rstudio.
the class RSConnectDeploy method setPreviousInfo.
private void setPreviousInfo() {
// content as currently deployed
if (fromPrevious_ != null) {
appProgressName_.setText(fromPrevious_.getName());
appExistingName_.setText(fromPrevious_.getDisplayName());
appProgressPanel_.setVisible(true);
appInfoPanel_.setVisible(true);
final ServerRequestCallback<JsArray<RSConnectApplicationInfo>> onAppsReceived = new ServerRequestCallback<JsArray<RSConnectApplicationInfo>>() {
@Override
public void onResponseReceived(JsArray<RSConnectApplicationInfo> infos) {
// hide server progress
appProgressPanel_.setVisible(false);
// find an app with the same account, server, and name;
// when found, populate the UI with app details
boolean found = false;
if (infos != null) {
for (int i = 0; i < infos.length(); i++) {
RSConnectApplicationInfo info = infos.get(i);
if (info.getName() == fromPrevious_.getName()) {
showAppInfo(info);
found = true;
break;
}
}
}
if (!found) {
forgetPreviousDeployment();
}
}
@Override
public void onError(ServerError error) {
// it's okay if we fail here, since the application info
// display is purely informative
appProgressPanel_.setVisible(false);
showAppInfo(null);
}
};
if (!StringUtil.isNullOrEmpty(fromPrevious_.getAppId())) {
// we know this app's ID, so get its details directly
server_.getRSConnectApp(fromPrevious_.getAppId(), fromPrevious_.getAccountName(), fromPrevious_.getServer(), new ServerRequestCallback<RSConnectApplicationInfo>() {
@Override
public void onResponseReceived(RSConnectApplicationInfo info) {
// create a single-entry array with the app ID
JsArray<RSConnectApplicationInfo> infos = JsArray.createArray().cast();
if (info != null)
infos.push(info);
onAppsReceived.onResponseReceived(infos);
}
@Override
public void onError(ServerError error) {
onAppsReceived.onError(error);
}
});
} else {
// we don't know the app ID, get the apps by name
server_.getRSConnectAppList(fromPrevious_.getAccountName(), fromPrevious_.getServer(), onAppsReceived);
}
}
}
use of org.rstudio.studio.client.server.ServerRequestCallback 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.ServerRequestCallback 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());
}
});
}
});
}
Aggregations