Search in sources :

Example 1 with FixedTextArea

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

the class ProjectPackratPreferencesPane method initialize.

@Override
protected void initialize(RProjectOptions options) {
    Styles styles = RES.styles();
    Label label = new Label("Packrat is a dependency management tool that makes your " + "R code more isolated, portable, and reproducible by " + "giving your project its own privately managed package " + "library.");
    spaced(label);
    add(label);
    PackratContext context = options.getPackratContext();
    RProjectPackratOptions packratOptions = options.getPackratOptions();
    chkUsePackrat_ = new CheckBox("Use packrat with this project");
    chkUsePackrat_.setValue(context.isPackified());
    chkUsePackrat_.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue())
                verifyPrerequisites();
            else
                manageUI(false);
        }
    });
    spaced(chkUsePackrat_);
    add(chkUsePackrat_);
    chkAutoSnapshot_ = new CheckBox("Automatically snapshot local changes");
    chkAutoSnapshot_.setValue(packratOptions.getAutoSnapshot());
    lessSpaced(chkAutoSnapshot_);
    add(chkAutoSnapshot_);
    String vcsName = session_.getSessionInfo().getVcsName();
    chkVcsIgnoreLib_ = new CheckBox(vcsName + " ignore packrat library");
    chkVcsIgnoreLib_.setValue(packratOptions.getVcsIgnoreLib());
    lessSpaced(chkVcsIgnoreLib_);
    add(chkVcsIgnoreLib_);
    chkVcsIgnoreSrc_ = new CheckBox(vcsName + " ignore packrat sources");
    chkVcsIgnoreSrc_.setValue(packratOptions.getVcsIgnoreSrc());
    lessSpaced(chkVcsIgnoreSrc_);
    add(chkVcsIgnoreSrc_);
    chkUseCache_ = new CheckBox("Use global cache for installed packages");
    chkUseCache_.setValue(packratOptions.getUseCache());
    spaced(chkUseCache_);
    add(chkUseCache_);
    panelExternalPackages_ = new VerticalPanel();
    panelExternalPackages_.add(new LabelWithHelp("External packages (comma separated):", "packrat_external_packages", false));
    taExternalPackages_ = new FixedTextArea(3);
    taExternalPackages_.addStyleName(styles.externalPackages());
    taExternalPackages_.setText(StringUtil.join(Arrays.asList(JsUtil.toStringArray(packratOptions.getExternalPackages())), ", "));
    taExternalPackages_.getElement().getStyle().setMarginBottom(8, Unit.PX);
    panelExternalPackages_.add(taExternalPackages_);
    add(panelExternalPackages_);
    widgetLocalRepos_ = new LocalRepositoriesWidget();
    String[] localRepos = JsUtil.toStringArray(packratOptions.getLocalRepos());
    for (int i = 0; i < localRepos.length; ++i) {
        widgetLocalRepos_.addItem(localRepos[i]);
    }
    add(widgetLocalRepos_);
    manageUI(context.isPackified());
    HelpLink helpLink = new HelpLink("Learn more about Packrat", "packrat", false);
    helpLink.getElement().getStyle().setMarginTop(15, Unit.PX);
    nudgeRight(helpLink);
    add(helpLink);
}
Also used : RProjectPackratOptions(org.rstudio.studio.client.projects.model.RProjectPackratOptions) LabelWithHelp(org.rstudio.core.client.widget.LabelWithHelp) Label(com.google.gwt.user.client.ui.Label) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) CheckBox(com.google.gwt.user.client.ui.CheckBox) FixedTextArea(org.rstudio.core.client.widget.FixedTextArea) LocalRepositoriesWidget(org.rstudio.core.client.widget.LocalRepositoriesWidget) HelpLink(org.rstudio.studio.client.common.HelpLink) PackratContext(org.rstudio.studio.client.packrat.model.PackratContext)

Example 2 with FixedTextArea

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

Aggregations

Label (com.google.gwt.user.client.ui.Label)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 FixedTextArea (org.rstudio.core.client.widget.FixedTextArea)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 Image (com.google.gwt.user.client.ui.Image)1 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 CommandWithArg (org.rstudio.core.client.CommandWithArg)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1 LabelWithHelp (org.rstudio.core.client.widget.LabelWithHelp)1 LocalRepositoriesWidget (org.rstudio.core.client.widget.LocalRepositoriesWidget)1 Operation (org.rstudio.core.client.widget.Operation)1 ProgressImage (org.rstudio.core.client.widget.ProgressImage)1 ThemedButton (org.rstudio.core.client.widget.ThemedButton)1 HelpLink (org.rstudio.studio.client.common.HelpLink)1 PackratContext (org.rstudio.studio.client.packrat.model.PackratContext)1