use of org.rstudio.core.client.widget.OperationWithInput in project rstudio by rstudio.
the class RmdOutput method onRmdRenderCompleted.
@Override
public void onRmdRenderCompleted(RmdRenderCompletedEvent event) {
renderInProgress_ = false;
// that instead
if (onRenderCompleted_ != null) {
onRenderCompleted_.execute();
onRenderCompleted_ = null;
return;
}
// ignore failures and completed Shiny docs (the latter are handled when
// the server starts rather than when the render process is finished)
final RmdRenderResult result = event.getResult();
if (result.isShinyDocument()) {
shinyDoc_ = null;
return;
}
if (result.hasShinyContent() && !result.isShinyDocument()) {
// If the result has Shiny content but wasn't rendered as a Shiny
// document, suggest rendering as a Shiny document instead
new ShinyDocumentWarningDialog(new OperationWithInput<Integer>() {
@Override
public void execute(Integer input) {
switch(input) {
case ShinyDocumentWarningDialog.RENDER_SHINY_NO:
if (result.getSucceeded())
displayRenderResult(result);
break;
case ShinyDocumentWarningDialog.RENDER_SHINY_ONCE:
rerenderAsShiny(result);
break;
case ShinyDocumentWarningDialog.RENDER_SHINY_ALWAYS:
events_.fireEvent(new ConvertToShinyDocEvent(result.getTargetFile()));
break;
}
}
}).showModal();
} else if (result.getSucceeded()) {
displayRenderResult(event.getResult());
}
}
use of org.rstudio.core.client.widget.OperationWithInput in project rstudio by rstudio.
the class Packages method doUpdatePackages.
private void doUpdatePackages(final PackageInstallContext installContext) {
new CheckForUpdatesDialog(globalDisplay_, new ServerDataSource<JsArray<PackageUpdate>>() {
public void requestData(ServerRequestCallback<JsArray<PackageUpdate>> requestCallback) {
server_.checkForPackageUpdates(requestCallback);
}
}, new OperationWithInput<ArrayList<PackageUpdate>>() {
@Override
public void execute(ArrayList<PackageUpdate> updates) {
InstallCommand cmd = buildUpdatePackagesCommand(updates, installContext);
executeWithLoadedPackageCheck(cmd);
}
}, new Operation() {
@Override
public void execute() {
// cancel emits an empty console input line to clear
// the busy indicator
events_.fireEvent(new SendToConsoleEvent("", true));
}
}).showModal();
}
use of org.rstudio.core.client.widget.OperationWithInput in project rstudio by rstudio.
the class SourceBuildHelper method withSaveFilesBeforeCommand.
private void withSaveFilesBeforeCommand(final Command command, final Command cancelCommand, String commandSource) {
if (uiPrefs_.saveAllBeforeBuild().getValue()) {
sourceShim_.saveAllUnsaved(command);
} else {
String alwaysSaveOption = !uiPrefs_.saveAllBeforeBuild().getValue() ? "Always save files before build" : null;
ArrayList<UnsavedChangesTarget> unsavedSourceDocs = sourceShim_.getUnsavedChanges(Source.TYPE_FILE_BACKED);
if (unsavedSourceDocs.size() > 0) {
new UnsavedChangesDialog(commandSource, alwaysSaveOption, unsavedSourceDocs, new OperationWithInput<UnsavedChangesDialog.Result>() {
@Override
public void execute(Result result) {
if (result.getAlwaysSave()) {
uiPrefs_.saveAllBeforeBuild().setGlobalValue(true);
uiPrefs_.writeUIPrefs();
}
sourceShim_.handleUnsavedChangesBeforeExit(result.getSaveTargets(), command);
}
}, cancelCommand).showModal();
} else {
command.execute();
}
}
}
use of org.rstudio.core.client.widget.OperationWithInput in project rstudio by rstudio.
the class Plots method onSavePlotAsPdf.
void onSavePlotAsPdf() {
view_.bringToFront();
final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
indicator.onProgress("Preparing to export plot...");
// get the default directory
final FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
// get context
server_.getUniqueSavePlotStem(defaultDir.getPath(), new SimpleRequestCallback<String>() {
@Override
public void onResponseReceived(String stem) {
indicator.onCompleted();
Size size = getPlotSize();
final SavePlotAsPdfOptions currentOptions = uiPrefs_.get().savePlotAsPdfOptions().getValue();
exportPlot_.savePlotAsPdf(globalDisplay_, server_, session_.getSessionInfo(), defaultDir, stem, currentOptions, pixelsToInches(size.width), pixelsToInches(size.height), new OperationWithInput<SavePlotAsPdfOptions>() {
@Override
public void execute(SavePlotAsPdfOptions options) {
if (!SavePlotAsPdfOptions.areEqual(options, currentOptions)) {
UIPrefs prefs = uiPrefs_.get();
prefs.savePlotAsPdfOptions().setGlobalValue(options);
prefs.writeUIPrefs();
}
}
});
}
@Override
public void onError(ServerError error) {
indicator.onError(error.getUserMessage());
}
});
}
use of org.rstudio.core.client.widget.OperationWithInput in project rstudio by rstudio.
the class SVNCommandHandler method onVcsResolve.
@Handler
void onVcsResolve() {
ArrayList<StatusAndPath> items = display_.getSelectedItems();
if (items.size() == 0)
return;
final ArrayList<String> paths = new ArrayList<String>();
boolean conflict = false;
for (StatusAndPath item : items) {
paths.add(item.getPath());
if ("C".equals(item.getStatus()))
conflict = true;
else if (item.isDirectory())
conflict = true;
}
Operation resolveOperation = new Operation() {
@Override
public void execute() {
new SVNResolveDialog(paths.size(), "Resolve", new OperationWithInput<String>() {
@Override
public void execute(String input) {
server_.svnResolve(input, paths, new ProcessCallback("SVN Resolve"));
}
}).showModal();
}
};
if (conflict) {
resolveOperation.execute();
} else {
String message = (paths.size() > 1 ? "None of the selected paths appear to have conflicts." : "The selected path does not appear to have conflicts.") + "\n\nDo you want to resolve anyway?";
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_WARNING, "No Conflicts Detected", message, resolveOperation, true);
}
}
Aggregations