Search in sources :

Example 36 with ProgressIndicator

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

the class RSAccountConnector method showShinyAppsDialog.

// Private methods --------------------------------------------------------
private void showShinyAppsDialog(final OperationWithInput<Boolean> onCompleted) {
    RSConnectCloudDialog dialog = new RSConnectCloudDialog(new ProgressOperationWithInput<NewRSConnectAccountResult>() {

        @Override
        public void execute(NewRSConnectAccountResult input, ProgressIndicator indicator) {
            processDialogResult(input, indicator, onCompleted);
        }
    }, new Operation() {

        @Override
        public void execute() {
            onCompleted.execute(false);
        }
    });
    dialog.showModal();
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) Operation(org.rstudio.core.client.widget.Operation) NewRSConnectAccountResult(org.rstudio.studio.client.rsconnect.model.NewRSConnectAccountResult)

Example 37 with ProgressIndicator

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

the class OptionsLoader method showOptions.

public void showOptions(final Class<?> paneClass) {
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error Reading Options");
    indicator.onProgress("Reading options...");
    server_.getRPrefs(new SimpleRequestCallback<RPrefs>() {

        @Override
        public void onResponseReceived(RPrefs rPrefs) {
            indicator.onCompleted();
            PreferencesDialog prefDialog = pPrefDialog_.get();
            prefDialog.initialize(rPrefs);
            if (paneClass != null)
                prefDialog.activatePane(paneClass);
            prefDialog.showModal();
            // if the user changes global sweave or latex options notify
            // them if this results in the current project being out
            // of sync with the global settings
            new SweaveProjectOptionsNotifier(prefDialog);
            // the mac you can actually show prefs from a satellite window)
            if (Desktop.isDesktop())
                Desktop.getFrame().bringMainFrameToFront();
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : RPrefs(org.rstudio.studio.client.workbench.prefs.model.RPrefs) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) PreferencesDialog(org.rstudio.studio.client.workbench.prefs.views.PreferencesDialog)

Example 38 with ProgressIndicator

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

the class EnvironmentPresenter method onOpenDataFile.

public void onOpenDataFile(OpenDataFileEvent event) {
    final String dataFilePath = event.getFile().getPath();
    globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Load RData", "Do you want to load the R data file \"" + dataFilePath + "\" " + "into the global environment?", new ProgressOperation() {

        public void execute(ProgressIndicator indicator) {
            consoleDispatcher_.executeCommand("load", FileSystemItem.createFile(dataFilePath));
            indicator.onCompleted();
        }
    }, true);
}
Also used : ProgressOperation(org.rstudio.core.client.widget.ProgressOperation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 39 with ProgressIndicator

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

the class DataImportOptionsUiCsv method initEvents.

void initEvents() {
    ValueChangeHandler<String> valueChangeHandler = new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ChangeHandler changeHandler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ChangeHandler delimChangeHandler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            if (delimiterListBox_.getSelectedValue() == "other") {
                globalDisplay_.promptForTextWithOption("Other Delimiter", "Please enter a single character delimiter.", "", false, "", false, new ProgressOperationWithInput<PromptWithOptionResult>() {

                    private void dismissAndUpdate(ProgressIndicator indicator, int newSelectIndex) {
                        lastDelimiterListBoxIndex_ = newSelectIndex;
                        delimiterListBox_.setSelectedIndex(newSelectIndex);
                        indicator.onCompleted();
                        updateEnabled();
                        triggerChange();
                    }

                    @Override
                    public void execute(PromptWithOptionResult result, ProgressIndicator indicator) {
                        String otherDelimiter = result.input;
                        if (otherDelimiter.length() != 1) {
                            globalDisplay_.showErrorMessage("Incorrect Delimiter", "The specified delimiter is not valid.");
                        } else {
                            for (int idxDelimiter = 0; idxDelimiter < delimiterListBox_.getItemCount(); idxDelimiter++) {
                                if (delimiterListBox_.getValue(idxDelimiter) == otherDelimiter) {
                                    dismissAndUpdate(indicator, idxDelimiter);
                                    return;
                                }
                            }
                            int selectedIndex = delimiterListBox_.getSelectedIndex();
                            delimiterListBox_.insertItem("Character " + otherDelimiter, otherDelimiter, selectedIndex - 1);
                            dismissAndUpdate(indicator, selectedIndex - 1);
                        }
                    }
                }, new Operation() {

                    @Override
                    public void execute() {
                        delimiterListBox_.setSelectedIndex(lastDelimiterListBoxIndex_);
                        updateEnabled();
                        triggerChange();
                    }
                });
            } else {
                lastDelimiterListBoxIndex_ = delimiterListBox_.getSelectedIndex();
                updateEnabled();
                triggerChange();
            }
        }
    };
    ValueChangeHandler<Boolean> booleanValueChangeHandler = new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    nameTextBox_.addValueChangeHandler(valueChangeHandler);
    delimiterListBox_.addChangeHandler(delimChangeHandler);
    quotesListBox_.addChangeHandler(changeHandler);
    escapeListBox_.addChangeHandler(changeHandler);
    columnNamesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    trimSpacesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    openDataViewerCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    naListBox_.addChangeHandler(changeHandler);
    commentListBox_.addChangeHandler(changeHandler);
    skipTextBox_.addValueChangeHandler(valueChangeHandler);
    localeButton_.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            new DataImportOptionsUiCsvLocale(new OperationWithInput<DataImportOptionsCsvLocale>() {

                @Override
                public void execute(final DataImportOptionsCsvLocale result) {
                    localeInfo_ = result;
                    updateEnabled();
                    triggerChange();
                }
            }, localeInfo_).showModal();
        }
    });
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) Operation(org.rstudio.core.client.widget.Operation) PromptWithOptionResult(org.rstudio.core.client.MessageDisplay.PromptWithOptionResult) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator)

Example 40 with ProgressIndicator

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

the class Plots method onSavePlotAsImage.

void onSavePlotAsImage() {
    view_.bringToFront();
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
    indicator.onProgress("Preparing to export plot...");
    // get the default directory
    FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
    // get context
    server_.getSavePlotContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {

        @Override
        public void onResponseReceived(SavePlotAsImageContext context) {
            indicator.onCompleted();
            exportPlot_.savePlotAsImage(globalDisplay_, server_, context, ExportPlotOptions.adaptToSize(uiPrefs_.get().exportPlotOptions().getValue(), getPlotSize()), saveExportOptionsOperation_);
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SavePlotAsImageContext(org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError)

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