use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Packages method withPackageInstallContext.
private void withPackageInstallContext(final OperationWithInput<PackageInstallContext> operation) {
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Retrieving package installation context...");
server_.getPackageInstallContext(new SimpleRequestCallback<PackageInstallContext>() {
@Override
public void onResponseReceived(PackageInstallContext context) {
indicator.onCompleted();
operation.execute(context);
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Packages method onInstallPackage.
void onInstallPackage() {
withPackageInstallContext(new OperationWithInput<PackageInstallContext>() {
@Override
public void execute(final PackageInstallContext installContext) {
if (installContext.isDefaultLibraryWriteable()) {
continueInstallPackage(installContext);
} else {
globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Create Package Library", "Would you like to create a personal library '" + installContext.getDefaultUserLibraryPath() + "' " + "to install packages into?", false, new // Yes operation
Operation() {
@Override
public void execute() {
ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error Creating Library");
server_.initDefaultUserLibrary(new VoidServerRequestCallback(indicator) {
@Override
protected void onSuccess() {
// call this function back recursively
// so we can retrieve the updated
// PackageInstallContext from the server
onInstallPackage();
}
});
}
}, new // No operation
Operation() {
@Override
public void execute() {
globalDisplay_.showMessage(MessageDialog.WARNING, "Install Packages", "Unable to install packages (default library '" + installContext.getDefaultLibraryPath() + "' is " + "not writeable)");
}
}, true);
}
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class FilesCopy method copyNextFile.
private void copyNextFile(final ArrayList<FileSystemItem> filesQueue, final FileSystemItem targetDirectory, final Command completedCommand) {
// terminate if there are no files left
if (filesQueue.size() == 0) {
if (completedCommand != null)
completedCommand.execute();
return;
}
// remove the first file from the list
final FileSystemItem sourceFile = filesQueue.remove(0);
// determine the default name and default selection
final String COPY_PREFIX = "CopyOf";
String defaultName = COPY_PREFIX + sourceFile.getName();
int defaultSelectionLength = COPY_PREFIX.length() + sourceFile.getStem().length();
// show prompt for new filename
final String objectName = sourceFile.isDirectory() ? "Folder" : "File";
globalDisplay_.promptForText("Copy " + objectName, "Enter a name for the copy of '" + sourceFile.getName() + "':", defaultName, 0, defaultSelectionLength, null, new ProgressOperationWithInput<String>() {
public void execute(String input, ProgressIndicator progress) {
progress.onProgress("Copying " + objectName.toLowerCase() + "...");
String targetFilePath = targetDirectory.completePath(input);
final FileSystemItem targetFile = FileSystemItem.createFile(targetFilePath);
server_.copyFile(sourceFile, targetFile, false, new VoidServerRequestCallback(progress) {
@Override
protected void onSuccess() {
// copy the next file in the queue
copyNextFile(filesQueue, targetDirectory, completedCommand);
}
});
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class History method onClearHistory.
@Handler
void onClearHistory() {
view_.bringToFront();
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "Confirm Clear History", "Are you sure you want to clear all history entries?", new ProgressOperation() {
public void execute(final ProgressIndicator indicator) {
indicator.onProgress("Clearing history...");
server_.clearHistory(new VoidServerRequestCallback(indicator));
}
}, true);
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Source method onNewSweaveDoc.
@Handler
public void onNewSweaveDoc() {
// set concordance value if we need to
String concordance = new String();
if (uiPrefs_.alwaysEnableRnwConcordance().getValue()) {
RnwWeave activeWeave = rnwWeaveRegistry_.findTypeIgnoreCase(uiPrefs_.defaultSweaveEngine().getValue());
if (activeWeave.getInjectConcordance())
concordance = "\\SweaveOpts{concordance=TRUE}\n";
}
final String concordanceValue = concordance;
// show progress
final ProgressIndicator indicator = new GlobalProgressDelayer(globalDisplay_, 500, "Creating new document...").getIndicator();
// get the template
server_.getSourceTemplate("", "sweave.Rnw", new ServerRequestCallback<String>() {
@Override
public void onResponseReceived(String templateContents) {
indicator.onCompleted();
// add in concordance if necessary
final boolean hasConcordance = concordanceValue.length() > 0;
if (hasConcordance) {
String beginDoc = "\\begin{document}\n";
templateContents = templateContents.replace(beginDoc, beginDoc + concordanceValue);
}
newDoc(FileTypeRegistry.SWEAVE, templateContents, new ResultCallback<EditingTarget, ServerError>() {
@Override
public void onSuccess(EditingTarget target) {
int startRow = 4 + (hasConcordance ? 1 : 0);
target.setCursorPosition(Position.create(startRow, 0));
}
});
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
Aggregations