Search in sources :

Example 21 with ProgressIndicator

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);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) JsArrayNumber(com.google.gwt.core.client.JsArrayNumber) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ConsoleResetHistoryHandler(org.rstudio.studio.client.workbench.views.console.events.ConsoleResetHistoryHandler) SelectionCommitHandler(org.rstudio.core.client.events.SelectionCommitHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) HistoryEntriesAddedHandler(org.rstudio.studio.client.workbench.views.history.events.HistoryEntriesAddedHandler) FetchCommandsHandler(org.rstudio.studio.client.workbench.views.history.events.FetchCommandsHandler) Handler(org.rstudio.core.client.command.Handler)

Example 22 with ProgressIndicator

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();
        }
    });
}
Also used : FileDialogs(org.rstudio.studio.client.common.FileDialogs) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ArrayList(java.util.ArrayList)

Example 23 with ProgressIndicator

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);
        }
    });
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) RSConnectLintResults(org.rstudio.studio.client.rsconnect.model.RSConnectLintResults)

Example 24 with ProgressIndicator

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);
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) Operation(org.rstudio.core.client.widget.Operation)

Example 25 with ProgressIndicator

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();
        }
    });
}
Also used : NewConnectionContext(org.rstudio.studio.client.workbench.views.connections.model.NewConnectionContext) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) PerformConnectionEvent(org.rstudio.studio.client.workbench.views.connections.events.PerformConnectionEvent) NewConnectionWizard(org.rstudio.studio.client.workbench.views.connections.ui.NewConnectionWizard) ConnectionOptions(org.rstudio.studio.client.workbench.views.connections.model.ConnectionOptions) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput)

Aggregations

ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)51 ServerError (org.rstudio.studio.client.server.ServerError)26 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)16 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)15 Handler (org.rstudio.core.client.command.Handler)12 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)8 ProgressOperation (org.rstudio.core.client.widget.ProgressOperation)7 Command (com.google.gwt.user.client.Command)6 JsArrayString (com.google.gwt.core.client.JsArrayString)5 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)5 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)5 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Operation (org.rstudio.core.client.widget.Operation)4 SourceLocation (org.rstudio.studio.client.common.synctex.model.SourceLocation)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)3 JSONString (com.google.gwt.json.client.JSONString)3 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)3