use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class ProjectOpener method showOpenProjectDialog.
public void showOpenProjectDialog(FileSystemContext fsContext, ProjectsServerOperations server, String defaultLocation, int defaultType, boolean showNewSession, final ProgressOperationWithInput<OpenProjectParams> onCompleted) {
initialize();
// use the default dialog on desktop mode or single-session mode
FileDialogs dialogs = RStudioGinjector.INSTANCE.getFileDialogs();
if (Desktop.isDesktop() || !RStudioGinjector.INSTANCE.getSession().getSessionInfo().getMultiSession()) {
dialogs.openFile("Open Project", fsContext, FileSystemItem.createDir(defaultLocation), "R Projects (*.Rproj)", true, new ProgressOperationWithInput<FileSystemItem>() {
@Override
public void execute(FileSystemItem input, final ProgressIndicator indicator) {
final CommandWithArg<FileSystemItem> onProjectFileReady = new CommandWithArg<FileSystemItem>() {
@Override
public void execute(FileSystemItem item) {
onCompleted.execute(new OpenProjectParams(item, null, false), indicator);
}
};
// null return values here imply a cancellation
if (input == null)
return;
if (input.isDirectory()) {
final String rprojPath = input.completePath(input.getName() + ".Rproj");
final FileSystemItem rprojFile = FileSystemItem.createFile(rprojPath);
server_.createProjectFile(rprojFile.getPath(), new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean success) {
onProjectFileReady.execute(rprojFile);
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
onProjectFileReady.execute(rprojFile);
}
});
} else {
onProjectFileReady.execute(input);
}
}
});
} else {
// in multi-session mode, we have a special dialog for opening projects
WebFileDialogs webDialogs = (WebFileDialogs) dialogs;
webDialogs.openProject(fsContext, FileSystemItem.createDir(defaultLocation), defaultType, showNewSession, onCompleted);
}
}
use of org.rstudio.core.client.widget.ProgressIndicator 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.core.client.widget.ProgressIndicator 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.core.client.widget.ProgressIndicator 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.core.client.widget.ProgressIndicator 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();
}
Aggregations