Search in sources :

Example 11 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class Presentation method confirmClose.

public void confirmClose(Command onConfirmed) {
    // don't allow close if this is a tutorial
    if (currentState_.isTutorial()) {
        globalDisplay_.showMessage(MessageDisplay.MSG_WARNING, "Unable to Close", "Tutorials cannot be closed");
        return;
    }
    final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 0, "Closing Presentation...").getIndicator();
    server_.closePresentationPane(new ServerRequestCallback<Void>() {

        @Override
        public void onResponseReceived(Void resp) {
            reloadWorkbench();
        }

        @Override
        public void onError(ServerError error) {
            progress.onError(error.getUserMessage());
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) Void(org.rstudio.studio.client.server.Void)

Example 12 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class Presentation method onTutorialFeedback.

@Handler
void onTutorialFeedback() {
    EditDialog editDialog = new EditDialog("Provide Feedback", "Submit", "", false, true, new Size(450, 300), new ProgressOperationWithInput<String>() {

        @Override
        public void execute(String input, ProgressIndicator indicator) {
            if (input == null) {
                indicator.onCompleted();
                return;
            }
            indicator.onProgress("Saving feedback...");
            server_.tutorialFeedback(input, new VoidServerRequestCallback(indicator));
        }
    });
    editDialog.showModal();
}
Also used : EditDialog(org.rstudio.studio.client.workbench.views.edit.ui.EditDialog) Size(org.rstudio.core.client.Size) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JSONString(com.google.gwt.json.client.JSONString) Handler(org.rstudio.core.client.command.Handler)

Example 13 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class Presentation method onPresentationSaveAsStandalone.

@Handler
void onPresentationSaveAsStandalone() {
    // determine the default file name
    if (saveAsStandaloneDefaultPath_ == null) {
        FileSystemItem presFilePath = FileSystemItem.createFile(currentState_.getFilePath());
        saveAsStandaloneDefaultPath_ = FileSystemItem.createFile(presFilePath.getParentPath().completePath(presFilePath.getStem() + ".html"));
    }
    fileDialogs_.saveFile("Save Presentation As", fileSystemContext_, saveAsStandaloneDefaultPath_, ".html", false, new ProgressOperationWithInput<FileSystemItem>() {

        @Override
        public void execute(final FileSystemItem targetFile, ProgressIndicator indicator) {
            if (targetFile == null) {
                indicator.onCompleted();
                return;
            }
            indicator.onProgress("Saving Presentation...");
            server_.createStandalonePresentation(targetFile.getPath(), new VoidServerRequestCallback(indicator) {

                @Override
                public void onSuccess() {
                    saveAsStandaloneDefaultPath_ = targetFile;
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Handler(org.rstudio.core.client.command.Handler)

Example 14 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class Source method onNewRPresentationDoc.

@Handler
public void onNewRPresentationDoc() {
    dependencyManager_.withRMarkdown("Authoring R Presentations", new Command() {

        @Override
        public void execute() {
            fileDialogs_.saveFile("New R Presentation", fileContext_, workbenchContext_.getDefaultFileDialogDir(), ".Rpres", true, new ProgressOperationWithInput<FileSystemItem>() {

                @Override
                public void execute(final FileSystemItem input, final ProgressIndicator indicator) {
                    if (input == null) {
                        indicator.onCompleted();
                        return;
                    }
                    indicator.onProgress("Creating Presentation...");
                    server_.createNewPresentation(input.getPath(), new VoidServerRequestCallback(indicator) {

                        @Override
                        public void onSuccess() {
                            openFile(input, FileTypeRegistry.RPRESENTATION, new CommandWithArg<EditingTarget>() {

                                @Override
                                public void execute(EditingTarget arg) {
                                    server_.showPresentationPane(input.getPath(), new VoidServerRequestCallback());
                                }
                            });
                        }
                    });
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) TextEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget) EditingTarget(org.rstudio.studio.client.workbench.views.source.editors.EditingTarget) DataEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget) CodeBrowserEditingTarget(org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) FileTypeChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.FileTypeChangedHandler) Handler(org.rstudio.core.client.command.Handler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) SelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) CloseHandler(com.google.gwt.event.logical.shared.CloseHandler) ViewDataHandler(org.rstudio.studio.client.workbench.views.data.events.ViewDataHandler) SourceOnSaveChangedHandler(org.rstudio.studio.client.workbench.views.source.editors.text.events.SourceOnSaveChangedHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) OpenSourceFileHandler(org.rstudio.studio.client.common.filetypes.events.OpenSourceFileHandler)

Example 15 with ProgressIndicator

use of org.rstudio.core.client.widget.ProgressIndicator in project rstudio by rstudio.

the class WebTextInput method promptForTextWithOption.

@Override
public void promptForTextWithOption(String title, String label, String initialValue, final boolean usePasswordMask, String extraOptionPrompt, boolean extraOptionDefault, int selectionStart, int selectionLength, String okButtonCaption, final ProgressOperationWithInput<PromptWithOptionResult> okOperation, Operation cancelOperation) {
    // This variable introduces a level of pointer indirection that lets us
    // get around passing TextEntryModalDialog a reference to itself in its
    // own constructor.
    final Value<TextEntryModalDialog> pDialog = new Value<TextEntryModalDialog>(null);
    final TextEntryModalDialog dialog = new TextEntryModalDialog(title, label, initialValue, usePasswordMask, extraOptionPrompt, extraOptionDefault, false, selectionStart, selectionLength, okButtonCaption, 300, new ProgressOperationWithInput<String>() {

        @Override
        public void execute(String input, ProgressIndicator indicator) {
            PromptWithOptionResult result = new PromptWithOptionResult();
            result.input = input;
            result.extraOption = pDialog.getValue().getExtraOption();
            okOperation.execute(result, indicator);
        }
    }, cancelOperation) {

        @Override
        protected void positionAndShowDialog(final Command onCompleted) {
            setPopupPositionAndShow(new PositionCallback() {

                @Override
                public void setPosition(int offsetWidth, int offsetHeight) {
                    int left = (Window.getClientWidth() / 2) - (offsetWidth / 2);
                    int top = (Window.getClientHeight() / 2) - (offsetHeight / 2);
                    if (usePasswordMask)
                        top = 50;
                    setPopupPosition(left, top);
                    onCompleted.execute();
                }
            });
        }
    };
    pDialog.setValue(dialog, false);
    dialog.showModal();
}
Also used : TextEntryModalDialog(org.rstudio.core.client.widget.TextEntryModalDialog) Command(com.google.gwt.user.client.Command) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) Value(org.rstudio.studio.client.common.Value) PromptWithOptionResult(org.rstudio.core.client.MessageDisplay.PromptWithOptionResult)

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