use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ProjectPackratPreferencesPane method verifyPrerequisites.
private void verifyPrerequisites() {
final ProgressIndicator indicator = getProgressIndicator();
indicator.onProgress("Verifying prequisites...");
server_.getPackratPrerequisites(new ServerRequestCallback<PackratPrerequisites>() {
@Override
public void onResponseReceived(PackratPrerequisites prereqs) {
indicator.onCompleted();
if (prereqs.getBuildToolsAvailable()) {
if (prereqs.getPackageAvailable()) {
setUsePackrat(true);
} else {
setUsePackrat(false);
// install packrat (with short delay to allow
// the progress indicator to clear)
new Timer() {
@Override
public void run() {
dependencyManager_.withPackrat("Managing packages with packrat", new Command() {
@Override
public void execute() {
setUsePackrat(true);
}
});
}
}.schedule(250);
}
} else {
setUsePackrat(false);
// install build tools (with short delay to allow
// the progress indicator to clear)
new Timer() {
@Override
public void run() {
server_.installBuildTools("Managing packages with Packrat", new SimpleRequestCallback<Boolean>() {
});
}
}.schedule(250);
}
}
@Override
public void onError(ServerError error) {
setUsePackrat(false);
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class ProjectSourceControlPreferencesPane method confirmGitRepo.
private void confirmGitRepo(final Command onConfirmed) {
final ProgressIndicator indicator = getProgressIndicator();
indicator.onProgress("Checking for git repository...");
final String projDir = session_.getSessionInfo().getActiveProjectDir().getPath();
server_.gitHasRepo(projDir, new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean result) {
indicator.onCompleted();
if (result) {
onConfirmed.execute();
} else {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Confirm New Git Repository", "Do you want to initialize a new git repository " + "for this project?", false, new Operation() {
@Override
public void execute() {
server_.gitInitRepo(projDir, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
onConfirmed.execute();
}
@Override
public void onFailure() {
setVcsSelection(VCSConstants.NO_ID);
}
});
}
}, new Operation() {
@Override
public void execute() {
setVcsSelection(VCSConstants.NO_ID);
indicator.onCompleted();
}
}, true);
}
}
@Override
public void onError(ServerError error) {
setVcsSelection(VCSConstants.NO_ID);
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class Ignore method showDialog.
public void showDialog(final IgnoreList ignoreList, final Strategy strategy) {
// show progress
final ProgressIndicator globalIndicator = new GlobalProgressDelayer(globalDisplay_, 500, "Getting ignored files for path...").getIndicator();
// get existing ignores
final String fullPath = projPathToFullPath(ignoreList.getPath());
strategy.getIgnores(fullPath, new ServerRequestCallback<ProcessResult>() {
@Override
public void onResponseReceived(final ProcessResult result) {
globalIndicator.onCompleted();
if (checkForProcessError(strategy.getDialogCaption(), result))
return;
// show the ignore dialog
String ignored = getIgnored(ignoreList, result.getOutput());
showDialog(fullPath, ignored, strategy);
}
@Override
public void onError(ServerError error) {
globalIndicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.studio.client.server.ServerError 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.ServerError 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);
}
Aggregations