use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class EnvironmentPresenter method onClearWorkspace.
void onClearWorkspace() {
view_.bringToFront();
final List<String> objectNames = view_.getSelectedObjects();
new ClearAllDialog(objectNames.size(), new ProgressOperationWithInput<Boolean>() {
@Override
public void execute(Boolean includeHidden, ProgressIndicator indicator) {
indicator.onProgress("Removing objects...");
if (objectNames.size() == 0) {
server_.removeAllObjects(includeHidden, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
view_.clearSelection();
view_.clearObjects();
}
});
} else {
server_.removeObjects(objectNames, new VoidServerRequestCallback(indicator) {
@Override
public void onSuccess() {
view_.clearSelection();
for (String obj : objectNames) {
view_.removeObject(obj);
}
}
});
}
}
}).showModal();
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class PathBreadcrumbWidget method browse.
private void browse() {
if (Desktop.isDesktop()) {
FileSystemContext tempContext = RStudioGinjector.INSTANCE.getRemoteFileSystemContext();
RStudioGinjector.INSTANCE.getFileDialogs().chooseFolder("Go To Folder", tempContext, null, new ProgressOperationWithInput<FileSystemItem>() {
public void execute(FileSystemItem input, ProgressIndicator indicator) {
if (input == null)
return;
context_.cd(input.getPath());
indicator.onCompleted();
}
});
} else {
context_.messageDisplay().promptForText("Go To Folder", "Path to folder (use ~ for home directory):", "", new OperationWithInput<String>() {
@Override
public void execute(String input) {
if (input == null)
return;
context_.cd(input);
}
});
}
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class DependencyManager method processDependencyRequest.
private void processDependencyRequest(final DependencyRequest req) {
// convert dependencies to JsArray, excluding satisfied dependencies
final JsArray<Dependency> deps = JsArray.createArray().cast();
for (int i = 0; i < req.dependencies.length; i++) {
boolean satisfied = false;
for (Dependency d : satisfied_) {
if (req.dependencies[i].isEqualTo(d)) {
satisfied = true;
break;
}
}
if (!satisfied)
deps.push(req.dependencies[i]);
}
// if no unsatisfied dependencies were found, we're done already
if (deps.length() == 0) {
req.onComplete.execute(true);
return;
}
// create progress indicator
final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 250, req.progressCaption + "...").getIndicator();
// query for unsatisfied dependencies
server_.unsatisfiedDependencies(deps, req.silentEmbeddedUpdate, new ServerRequestCallback<JsArray<Dependency>>() {
@Override
public void onResponseReceived(final JsArray<Dependency> unsatisfiedDeps) {
progress.onCompleted();
updateSatisfied(deps, unsatisfiedDeps);
// if we've satisfied all dependencies then execute the command
if (unsatisfiedDeps.length() == 0) {
req.onComplete.execute(true);
return;
}
// check to see if we can satisfy the version requirement for all
// dependencies
String unsatisfiedVersions = "";
for (int i = 0; i < unsatisfiedDeps.length(); i++) {
if (!unsatisfiedDeps.get(i).getVersionSatisfied()) {
unsatisfiedVersions += unsatisfiedDeps.get(i).getName() + " " + unsatisfiedDeps.get(i).getVersion();
String version = unsatisfiedDeps.get(i).getAvailableVersion();
if (version.isEmpty())
unsatisfiedVersions += " is not available\n";
else
unsatisfiedVersions += " is required but " + version + " is available\n";
}
}
if (!unsatisfiedVersions.isEmpty()) {
// error if we can't satisfy requirements
globalDisplay_.showErrorMessage(StringUtil.isNullOrEmpty(req.userAction) ? "Packages Not Found" : req.userAction, "Required package versions could not be found:\n\n" + unsatisfiedVersions + "\n" + "Check that getOption(\"repos\") refers to a CRAN " + "repository that contains the needed package versions.");
req.onComplete.execute(false);
} else {
// otherwise ask the user if they want to install the
// unsatisifed dependencies
final CommandWithArg<Boolean> installCommand = new CommandWithArg<Boolean>() {
@Override
public void execute(Boolean confirmed) {
// bail if user didn't confirm
if (!confirmed) {
req.onComplete.execute(false);
return;
}
// the incoming JsArray from the server may not serialize
// as expected when this code is executed from a satellite
// (see RemoteServer.sendRequestViaMainWorkbench), so we
// clone it before passing to the dependency installer
JsArray<Dependency> newArray = JsArray.createArray().cast();
newArray.setLength(unsatisfiedDeps.length());
for (int i = 0; i < unsatisfiedDeps.length(); i++) {
newArray.set(i, unsatisfiedDeps.get(i));
}
installDependencies(newArray, req.silentEmbeddedUpdate, req.onComplete);
}
};
if (req.userPrompt != null) {
req.userPrompt.execute(describeDepPkgs(unsatisfiedDeps), new Command() {
@Override
public void execute() {
installCommand.execute(true);
}
});
} else {
confirmPackageInstallation(req.userAction, unsatisfiedDeps, installCommand);
}
}
}
@Override
public void onError(ServerError error) {
progress.onError(error.getUserMessage());
req.onComplete.execute(false);
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class Synctex method doInverseSearch.
private void doInverseSearch(JavaScriptObject pdfLocationObject) {
PdfLocation pdfLocation = pdfLocationObject.cast();
final ProgressIndicator indicator = getSyncProgress();
server_.synctexInverseSearch(pdfLocation, new ServerRequestCallback<SourceLocation>() {
@Override
public void onResponseReceived(SourceLocation location) {
indicator.onCompleted();
if (location != null)
goToSourceLocation(location);
}
@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 Synctex method forwardSearch.
// NOTE: the original design was for a single internal pdf viewer. for
// that configuration we could keep a global pdfPath_ around and be
// confident that it was always correct. we were also globally managing
// the state of the synctex command based on any external viewer closing.
// now that we optionally support desktop viewers for synctex this
// assumption may not hold -- specfically there might be multiple active
// PDF viewers for different document or we might not know that the
// external viewer has closed . we have explicitly chosen to
// avoid the complexity of tracking distinct viewer states. if we want
// to do this we probably should do the following:
//
// - always keep the the syncex command available in all editors
// so long as there is at least one preview window alive; OR
//
// - for cases where we do know whether the window is still alive
// editors could dynamically show/hide their synctex button
// based on that more granular state
//
public boolean forwardSearch(final String pdfFile, SourceLocation sourceLocation) {
if (handleDesktopSynctex()) {
// apply concordane
final ProgressIndicator indicator = getSyncProgress();
server_.applyForwardConcordance(pdfFile, sourceLocation, new ServerRequestCallback<SourceLocation>() {
@Override
public void onResponseReceived(SourceLocation sourceLocation) {
indicator.onCompleted();
if (sourceLocation != null) {
Desktop.getFrame().externalSynctexView(pdfFile, sourceLocation.getFile(), sourceLocation.getLine(), sourceLocation.getColumn());
}
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
return true;
} else // use internal viewer
{
doForwardSearch(targetFile_, sourceLocation);
return true;
}
}
Aggregations