Search in sources :

Example 1 with ProgressOperationWithInput

use of org.rstudio.core.client.widget.ProgressOperationWithInput 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)

Example 2 with ProgressOperationWithInput

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

the class EnvironmentPresenter method onClearWorkspace.

void onClearWorkspace() {
    view_.bringToFront();
    final List<String> objectNames = view_.getSelectedObjects();
    new ClearAllDialog(objectNames.size(), new ProgressOperationWithInput<Boolean>() {

        @Override
        public void execute(Boolean includeHidden, ProgressIndicator indicator) {
            indicator.onProgress("Removing objects...");
            if (objectNames.size() == 0) {
                server_.removeAllObjects(includeHidden, new VoidServerRequestCallback(indicator) {

                    @Override
                    public void onSuccess() {
                        view_.clearSelection();
                        view_.clearObjects();
                    }
                });
            } else {
                server_.removeObjects(objectNames, new VoidServerRequestCallback(indicator) {

                    @Override
                    public void onSuccess() {
                        view_.clearSelection();
                        for (String obj : objectNames) {
                            view_.removeObject(obj);
                        }
                    }
                });
            }
        }
    }).showModal();
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) JsArrayString(com.google.gwt.core.client.JsArrayString) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput)

Example 3 with ProgressOperationWithInput

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

the class SavePlotAsPdfDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    ExportPlotResources.Styles styles = ExportPlotResources.INSTANCE.styles();
    Grid grid = new Grid(7, 2);
    grid.setStylePrimaryName(styles.savePdfMainWidget());
    // paper size
    grid.setWidget(0, 0, new Label("PDF Size:"));
    // paper size label
    paperSizeEditor_ = new PaperSizeEditor();
    grid.setWidget(0, 1, paperSizeEditor_);
    // orientation
    grid.setWidget(1, 0, new Label("Orientation:"));
    HorizontalPanel orientationPanel = new HorizontalPanel();
    orientationPanel.setSpacing(kComponentSpacing);
    VerticalPanel orientationGroupPanel = new VerticalPanel();
    final String kOrientationGroup = new String("Orientation");
    portraitRadioButton_ = new RadioButton(kOrientationGroup, "Portrait");
    orientationGroupPanel.add(portraitRadioButton_);
    landscapeRadioButton_ = new RadioButton(kOrientationGroup, "Landscape");
    orientationGroupPanel.add(landscapeRadioButton_);
    orientationPanel.add(orientationGroupPanel);
    grid.setWidget(1, 1, orientationPanel);
    boolean haveCairoPdf = sessionInfo_.isCairoPdfAvailable();
    if (haveCairoPdf)
        grid.setWidget(2, 0, new Label("Options:"));
    HorizontalPanel cairoPdfPanel = new HorizontalPanel();
    String label = "Use cairo_pdf device";
    if (BrowseCap.isMacintoshDesktop())
        label = label + " (requires X11)";
    chkCairoPdf_ = new CheckBox(label);
    chkCairoPdf_.getElement().getStyle().setMarginLeft(kComponentSpacing, Unit.PX);
    cairoPdfPanel.add(chkCairoPdf_);
    chkCairoPdf_.setValue(haveCairoPdf && options_.getCairoPdf());
    if (haveCairoPdf)
        grid.setWidget(2, 1, cairoPdfPanel);
    grid.setWidget(3, 0, new HTML("&nbsp;"));
    ThemedButton directoryButton = new ThemedButton("Directory...");
    directoryButton.setStylePrimaryName(styles.directoryButton());
    directoryButton.getElement().getStyle().setMarginLeft(-2, Unit.PX);
    grid.setWidget(4, 0, directoryButton);
    directoryButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            fileDialogs_.chooseFolder("Choose Directory", fileSystemContext_, FileSystemItem.createDir(directoryLabel_.getTitle().trim()), new ProgressOperationWithInput<FileSystemItem>() {

                public void execute(FileSystemItem input, ProgressIndicator indicator) {
                    if (input == null)
                        return;
                    indicator.onCompleted();
                    // update default
                    ExportPlotUtils.setDefaultSaveDirectory(input);
                    // set display
                    setDirectory(input);
                }
            });
        }
    });
    directoryLabel_ = new Label();
    setDirectory(defaultDirectory_);
    directoryLabel_.setStylePrimaryName(styles.savePdfDirectoryLabel());
    grid.setWidget(4, 1, directoryLabel_);
    Label fileNameLabel = new Label("File name:");
    fileNameLabel.setStylePrimaryName(styles.savePdfFileNameLabel());
    grid.setWidget(5, 0, fileNameLabel);
    fileNameTextBox_ = new TextBox();
    fileNameTextBox_.setText(defaultPlotName_);
    fileNameTextBox_.setStylePrimaryName(styles.savePdfFileNameTextBox());
    grid.setWidget(5, 1, fileNameTextBox_);
    // view after size
    viewAfterSaveCheckBox_ = new CheckBox("View plot after saving");
    viewAfterSaveCheckBox_.setStylePrimaryName(styles.savePdfViewAfterCheckbox());
    viewAfterSaveCheckBox_.setValue(options_.getViewAfterSave());
    grid.setWidget(6, 1, viewAfterSaveCheckBox_);
    // set default value
    if (options_.getPortrait())
        portraitRadioButton_.setValue(true);
    else
        landscapeRadioButton_.setValue(true);
    // return the widget
    return grid;
}
Also used : Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Label(com.google.gwt.user.client.ui.Label) HTML(com.google.gwt.user.client.ui.HTML) RadioButton(com.google.gwt.user.client.ui.RadioButton) TextBox(com.google.gwt.user.client.ui.TextBox) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) ThemedButton(org.rstudio.core.client.widget.ThemedButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ExportPlotResources(org.rstudio.studio.client.workbench.exportplot.ExportPlotResources) CheckBox(com.google.gwt.user.client.ui.CheckBox) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 4 with ProgressOperationWithInput

use of org.rstudio.core.client.widget.ProgressOperationWithInput 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 5 with ProgressOperationWithInput

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

the class ViewerPresenter method onViewerSaveAsWebPage.

@Handler
public void onViewerSaveAsWebPage() {
    display_.bringToFront();
    if (saveAsWebPageDefaultPath_ == null)
        saveAsWebPageDefaultPath_ = workbenchContext_.getCurrentWorkingDir();
    dependencyManager_.withRMarkdown("Saving standalone web pages", new Command() {

        @Override
        public void execute() {
            fileDialogs_.saveFile("Save As Web Page", fileSystemContext_, saveAsWebPageDefaultPath_, ".html", false, new ProgressOperationWithInput<FileSystemItem>() {

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

                        @Override
                        public void onSuccess() {
                            saveAsWebPageDefaultPath_ = targetFile.getParentPath();
                        }
                    });
                }
            });
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) ProgressOperationWithInput(org.rstudio.core.client.widget.ProgressOperationWithInput) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Aggregations

ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)5 ProgressOperationWithInput (org.rstudio.core.client.widget.ProgressOperationWithInput)5 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)3 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)3 Command (com.google.gwt.user.client.Command)2 AppCommand (org.rstudio.core.client.command.AppCommand)2 Handler (org.rstudio.core.client.command.Handler)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 CloseHandler (com.google.gwt.event.logical.shared.CloseHandler)1 SelectionHandler (com.google.gwt.event.logical.shared.SelectionHandler)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 NativePreviewHandler (com.google.gwt.user.client.Event.NativePreviewHandler)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 Grid (com.google.gwt.user.client.ui.Grid)1 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1