use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class History method onHistoryRemoveEntries.
@Handler
void onHistoryRemoveEntries() {
// get selected indexes (bail if there is no selection)
final ArrayList<Integer> selectedRowIndexes = view_.getRecentCommandsSelectedRowIndexes();
if (selectedRowIndexes.size() < 1) {
globalDisplay_.showErrorMessage("Error", "No history entries currently selected.");
return;
}
// bring view to front
view_.bringToFront();
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Remove Entries", "Are you sure you want to remove the selected entries from " + "the history?", new ProgressOperation() {
public void execute(final ProgressIndicator indicator) {
indicator.onProgress("Removing items...");
// for each selected row index we need to calculate
// the offset from the bottom
int rowCount = view_.getRecentCommandsRowsDisplayed();
JsArrayNumber bottomIndexes = (JsArrayNumber) JsArrayNumber.createArray();
for (int i = 0; i < selectedRowIndexes.size(); i++) bottomIndexes.push(rowCount - selectedRowIndexes.get(i) - 1);
server_.removeHistoryItems(bottomIndexes, new VoidServerRequestCallback(indicator));
}
}, true);
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class RSConnectDeploy method onAddFileClick.
private void onAddFileClick() {
FileDialogs dialogs = RStudioGinjector.INSTANCE.getFileDialogs();
final FileSystemItem sourceDir = FileSystemItem.createDir(source_.getDeployDir());
dialogs.openFile("Select File", RStudioGinjector.INSTANCE.getRemoteFileSystemContext(), sourceDir, new ProgressOperationWithInput<FileSystemItem>() {
@Override
public void execute(FileSystemItem input, ProgressIndicator indicator) {
if (input != null) {
String path = input.getPathRelativeTo(sourceDir);
if (path == null) {
display_.showMessage(GlobalDisplay.MSG_INFO, "Cannot Add File", "Only files in the same folder as the " + "document (" + sourceDir + ") or one of its " + "sub-folders may be added.");
return;
} else {
// see if the file is already in the list (we don't
// want to duplicate an existing entry)
ArrayList<String> files = getFileList();
for (String file : files) {
if (file.equals(path)) {
indicator.onCompleted();
return;
}
}
addFileToList(path);
filesAddedManually_.add(path);
}
}
indicator.onCompleted();
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class RSConnect method onRSConnectDeployInitiated.
@Override
public void onRSConnectDeployInitiated(final RSConnectDeployInitiatedEvent event) {
// shortcut: when deploying static content we don't need to do any linting
if (event.getSettings().getAsStatic()) {
doDeployment(event);
return;
}
// get lint results for the file or directory being deployed, as
// appropriate
server_.getLintResults(event.getSource().getDeployKey(), new ServerRequestCallback<RSConnectLintResults>() {
@Override
public void onResponseReceived(RSConnectLintResults results) {
if (results.getErrorMessage().length() > 0) {
display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Lint Failed", "The content you tried to publish could not be checked " + "for errors. Do you want to proceed? \n\n" + results.getErrorMessage(), false, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Publish Anyway"
doDeployment(event);
indicator.onCompleted();
}
}, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Cancel"
indicator.onCompleted();
}
}, "Publish Anyway", "Cancel", false);
} else if (results.hasLint()) {
display_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Publish Content Issues Found", "Some issues were found in your content, which may " + "prevent it from working correctly after publishing. " + "Do you want to review these issues or publish anyway? ", false, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Review Issues" -- we automatically show the
// markers so they're already behind the dialog.
indicator.onCompleted();
}
}, new ProgressOperation() {
@Override
public void execute(ProgressIndicator indicator) {
// "Publish Anyway"
doDeployment(event);
indicator.onCompleted();
}
}, "Review Issues", "Publish Anyway", true);
} else {
// no lint and no errors -- good to go for deployment
doDeployment(event);
}
}
@Override
public void onError(ServerError error) {
// we failed to lint, which is not encouraging, but we don't want to
// fail the whole deployment lest a balky linter prevent people from
// getting their work published, so forge on ahead.
doDeployment(event);
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class DocUpdateSentinel method saveWithSuspendedAutoSave.
private void saveWithSuspendedAutoSave(String path, String fileType, String encoding, final ProgressIndicator progress) {
autosaver_.suspend();
doSave(path, fileType, encoding, new ProgressIndicator() {
public void onProgress(String message) {
onProgress(message, null);
}
public void onProgress(String message, Operation onCancel) {
if (progress != null)
progress.onProgress(message, onCancel);
}
public void clearProgress() {
autosaver_.resume();
if (progress != null)
progress.clearProgress();
}
public void onCompleted() {
autosaver_.resume();
if (progress != null)
progress.onCompleted();
}
public void onError(String message) {
autosaver_.resume();
if (progress != null)
progress.onError(message);
}
});
}
use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.
the class ConnectionsPresenter method onNewConnection.
public void onNewConnection() {
// if r session bussy, fail
if (commands_.interruptR().isEnabled()) {
showError("The R session is currently busy. Wait for completion or " + "interrupt the current session and retry.");
return;
}
// get the context
server_.getNewConnectionContext(new DelayedProgressRequestCallback<NewConnectionContext>("New Connection...") {
@Override
protected void onSuccess(final NewConnectionContext context) {
// show dialog
NewConnectionWizard newConnectionWizard = new NewConnectionWizard(context, new ProgressOperationWithInput<ConnectionOptions>() {
@Override
public void execute(ConnectionOptions result, ProgressIndicator indicator) {
indicator.onCompleted();
eventBus_.fireEvent(new PerformConnectionEvent(result.getConnectVia(), result.getConnectCode()));
}
});
newConnectionWizard.showModal();
}
});
}
Aggregations