Search in sources :

Example 1 with ThemedButton

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

the class RPubsUploadDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    Styles styles = RESOURCES.styles();
    SimplePanel mainPanel = new SimplePanel();
    mainPanel.addStyleName(styles.mainWidget());
    VerticalPanel verticalPanel = new VerticalPanel();
    HorizontalPanel headerPanel = new HorizontalPanel();
    headerPanel.addStyleName(styles.headerPanel());
    headerPanel.add(new Image(new ImageResource2x(RESOURCES.publishLarge2x())));
    Label headerLabel = new Label("Publish to RPubs");
    headerLabel.addStyleName(styles.headerLabel());
    headerPanel.add(headerLabel);
    headerPanel.setCellVerticalAlignment(headerLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(headerPanel);
    String msg;
    if (!isPublished_ && uploadId_.isEmpty()) {
        msg = "RPubs is a free service from RStudio for sharing " + "documents on the web. Click Publish to get " + "started.";
    } else {
        msg = "This document has already been published on RPubs. You can " + "choose to either update the existing RPubs document, or " + "create a new one.";
    }
    Label descLabel = new Label(msg);
    descLabel.addStyleName(styles.descLabel());
    verticalPanel.add(descLabel);
    // if we have a generator then show title and comment UI
    if (htmlGenerator_ != null) {
        Label titleLabel = new Label("Title (optional):");
        titleLabel.addStyleName(styles.fieldLabel());
        verticalPanel.add(titleLabel);
        titleTextBox_ = new TextBox();
        titleTextBox_.addStyleName(styles.titleTextBox());
        titleTextBox_.getElement().setAttribute("spellcheck", "false");
        verticalPanel.add(titleTextBox_);
        Label commentLabel = new Label("Comment (optional):");
        commentLabel.addStyleName(styles.fieldLabel());
        verticalPanel.add(commentLabel);
        commentTextArea_ = new FixedTextArea(6);
        commentTextArea_.addStyleName(styles.commentTextArea());
        verticalPanel.add(commentTextArea_);
        // not using either for now
        titleLabel.setVisible(false);
        titleTextBox_.setVisible(false);
        commentLabel.setVisible(false);
        commentTextArea_.setVisible(false);
        previewButton_ = new ThemedButton("Preview");
        previewButton_.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                htmlGenerator_.generateStaticHtml(titleTextBox_.getText().trim(), commentTextArea_.getText().trim(), new CommandWithArg<String>() {

                    @Override
                    public void execute(String rpubsFile) {
                        globalDisplay_.showHtmlFile(rpubsFile);
                    }
                });
            }
        });
        addLeftButton(previewButton_);
    }
    HTML warningLabel = new HTML("<strong>IMPORTANT: All documents published to RPubs are " + "publicly visible.</strong> You should " + "only publish documents that you wish to share publicly.");
    warningLabel.addStyleName(styles.warningLabel());
    verticalPanel.add(warningLabel);
    ThemedButton cancelButton = createCancelButton(new Operation() {

        @Override
        public void execute() {
            // if an upload is in progress then terminate it
            if (uploader_.isUploadInProgress()) {
                uploader_.terminateUpload();
            }
        }
    });
    continueButton_ = new ThemedButton("Publish", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(false);
        }
    });
    updateButton_ = new ThemedButton("Update Existing", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(true);
        }
    });
    createButton_ = new ThemedButton("Create New", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(false);
        }
    });
    if (!isPublished_ && uploadId_.isEmpty()) {
        addOkButton(continueButton_);
        addCancelButton(cancelButton);
    } else {
        addOkButton(updateButton_);
        addButton(createButton_);
        addCancelButton(cancelButton);
    }
    mainPanel.setWidget(verticalPanel);
    return mainPanel;
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) TextBox(com.google.gwt.user.client.ui.TextBox) CommandWithArg(org.rstudio.core.client.CommandWithArg) Operation(org.rstudio.core.client.widget.Operation) Image(com.google.gwt.user.client.ui.Image) ProgressImage(org.rstudio.core.client.widget.ProgressImage) ThemedButton(org.rstudio.core.client.widget.ThemedButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FixedTextArea(org.rstudio.core.client.widget.FixedTextArea) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 2 with ThemedButton

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

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

the class ApplicationAgreementDialog method addButtons.

@Override
protected void addButtons() {
    // default button is do not accept
    ThemedButton doNotAcceptButton = new ThemedButton("I Do Not Agree", new ClickHandler() {

        public void onClick(ClickEvent event) {
            closeDialog();
            doNotAcceptOperation_.execute();
        }
    });
    addOkButton(doNotAcceptButton);
    // accept button
    ThemedButton acceptButton = new ThemedButton("I Agree", new ClickHandler() {

        public void onClick(ClickEvent event) {
            closeDialog();
            acceptOperation_.execute();
        }
    });
    addButton(acceptButton);
}
Also used : ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Example 4 with ThemedButton

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

the class RSConnect method onRSConnectDeploymentFailed.

@Override
public void onRSConnectDeploymentFailed(final RSConnectDeploymentFailedEvent event) {
    String failedPath = event.getData().getPath();
    // if this looks like an API call, process the path to get the 'bare'
    // server URL
    int pos = failedPath.indexOf("__api__");
    if (pos < 1) {
        // if not, just get the host
        pos = failedPath.indexOf("/", 10) + 1;
    }
    if (pos > 0) {
        failedPath = failedPath.substring(0, pos);
    }
    final String serverUrl = failedPath;
    new ModalDialogBase() {

        @Override
        protected Widget createMainWidget() {
            setText("Publish Failed");
            addOkButton(new ThemedButton("OK", new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    closeDialog();
                }
            }));
            HorizontalPanel panel = new HorizontalPanel();
            Image errorImage = new Image(new ImageResource2x(MessageDialogImages.INSTANCE.dialog_error2x()));
            errorImage.getElement().getStyle().setMarginTop(1, Unit.EM);
            errorImage.getElement().getStyle().setMarginRight(1, Unit.EM);
            panel.add(errorImage);
            panel.add(new HTML("<p>Your content could not be published because " + "of a problem on the server.</p>" + "<p>More information may be available on the server's home " + "page:</p>" + "<p><a href=\"" + serverUrl + "\">" + serverUrl + "</a>" + "</p>" + "<p>If the error persists, contact the server's " + "administrator.</p>" + "<p><small>Error code: " + event.getData().getHttpStatus() + "</small></p>"));
            return panel;
        }
    }.showModal();
}
Also used : ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ModalDialogBase(org.rstudio.core.client.widget.ModalDialogBase) Widget(com.google.gwt.user.client.ui.Widget) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) HTML(com.google.gwt.user.client.ui.HTML) JsArrayString(com.google.gwt.core.client.JsArrayString) Image(com.google.gwt.user.client.ui.Image)

Example 5 with ThemedButton

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

the class NewConnectionSnippetHost method createParameterizedUI.

private Grid createParameterizedUI(final NewConnectionInfo info) {
    final ArrayList<NewConnectionSnippetParts> snippetParts = parseSnippet(info.getSnippet());
    int visibleRows = snippetParts.size();
    int visibleParams = Math.min(visibleRows, maxRows_);
    // If we have a field that shares the first row, usually port:
    boolean hasSecondaryHeaderField = false;
    if (visibleParams >= 2 && snippetParts.get(0).getOrder() == snippetParts.get(1).getOrder()) {
        visibleRows--;
        visibleParams++;
        hasSecondaryHeaderField = true;
    }
    boolean showAdvancedButton = visibleRows > maxRows_;
    visibleRows = Math.min(visibleRows, maxRows_);
    final ArrayList<NewConnectionSnippetParts> secondarySnippetParts = new ArrayList<NewConnectionSnippetParts>(snippetParts.subList(visibleParams, snippetParts.size()));
    final Grid connGrid = new Grid(visibleRows + (showAdvancedButton ? 1 : 0), 4);
    connGrid.addStyleName(RES.styles().grid());
    connGrid.getCellFormatter().setWidth(0, 0, "150px");
    connGrid.getCellFormatter().setWidth(0, 1, "180px");
    connGrid.getCellFormatter().setWidth(0, 2, "60px");
    connGrid.getCellFormatter().setWidth(0, 3, "74px");
    for (int idxParams = 0, idxRow = 0; idxRow < visibleRows; idxParams++, idxRow++) {
        connGrid.getRowFormatter().setStyleName(idxRow, RES.styles().gridRow());
        final String key = snippetParts.get(idxParams).getKey();
        Label label = new Label(key + ":");
        label.addStyleName(RES.styles().label());
        connGrid.setWidget(idxRow, 0, label);
        connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
        String textboxStyle = RES.styles().textbox();
        if (idxRow == 0 && hasSecondaryHeaderField) {
            textboxStyle = RES.styles().firstTextbox();
        } else {
            connGrid.getCellFormatter().getElement(idxRow, 1).setAttribute("colspan", "4");
        }
        final TextBoxBase textboxBase;
        if (key.toLowerCase() == "parameters") {
            TextArea textarea = new TextArea();
            textarea.setVisibleLines(7);
            textarea.addStyleName(RES.styles().textarea());
            connGrid.setWidget(idxRow, 1, textarea);
            textboxBase = textarea;
        } else {
            TextBox textbox = new TextBox();
            textbox.setText(snippetParts.get(idxParams).getValue());
            textbox.addStyleName(textboxStyle);
            textboxBase = textbox;
        }
        connGrid.setWidget(idxRow, 1, textboxBase);
        textboxBase.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent arg0) {
                partsKeyValues_.put(key, textboxBase.getValue());
                updateCodePanel();
            }
        });
        if (idxRow == 0 && hasSecondaryHeaderField) {
            idxParams++;
            final String secondKey = snippetParts.get(idxParams).getKey();
            Label secondLabel = new Label(secondKey + ":");
            secondLabel.addStyleName(RES.styles().secondLabel());
            connGrid.setWidget(idxRow, 2, secondLabel);
            connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
            final TextBox secondTextbox = new TextBox();
            secondTextbox.setText(snippetParts.get(idxParams).getValue());
            secondTextbox.addStyleName(RES.styles().secondTextbox());
            connGrid.setWidget(idxRow, 3, secondTextbox);
            connGrid.getCellFormatter().getElement(idxRow, 3).setAttribute("colspan", "2");
            secondTextbox.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent arg0) {
                    partsKeyValues_.put(secondKey, secondTextbox.getValue());
                    updateCodePanel();
                }
            });
        }
    }
    if (showAdvancedButton) {
        ThemedButton pushButton = new ThemedButton("Advanced Options...", new ClickHandler() {

            public void onClick(ClickEvent event) {
                new NewConnectionSnippetDialog(new OperationWithInput<HashMap<String, String>>() {

                    @Override
                    public void execute(final HashMap<String, String> result) {
                        for (String key : result.keySet()) {
                            partsKeyValues_.put(key, result.get(key));
                        }
                        updateCodePanel();
                    }
                }, secondarySnippetParts, info).showModal();
            }
        });
        connGrid.getRowFormatter().setStyleName(visibleRows, RES.styles().lastRow());
        connGrid.getCellFormatter().getElement(visibleRows, 1).setAttribute("colspan", "4");
        connGrid.setWidget(visibleRows, 1, pushButton);
    }
    return connGrid;
}
Also used : TextArea(com.google.gwt.user.client.ui.TextArea) HashMap(java.util.HashMap) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase) ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 ThemedButton (org.rstudio.core.client.widget.ThemedButton)5 HTML (com.google.gwt.user.client.ui.HTML)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 Label (com.google.gwt.user.client.ui.Label)3 TextBox (com.google.gwt.user.client.ui.TextBox)3 Grid (com.google.gwt.user.client.ui.Grid)2 Image (com.google.gwt.user.client.ui.Image)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)1 TextArea (com.google.gwt.user.client.ui.TextArea)1 TextBoxBase (com.google.gwt.user.client.ui.TextBoxBase)1 Widget (com.google.gwt.user.client.ui.Widget)1