Search in sources :

Example 1 with RProjectPackratOptions

use of org.rstudio.studio.client.projects.model.RProjectPackratOptions 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 RProjectPackratOptions

use of org.rstudio.studio.client.projects.model.RProjectPackratOptions in project rstudio by rstudio.

the class ProjectPackratPreferencesPane method onApply.

@Override
public boolean onApply(RProjectOptions options) {
    RProjectPackratOptions packratOptions = options.getPackratOptions();
    packratOptions.setUsePackrat(chkUsePackrat_.getValue());
    packratOptions.setAutoSnapshot(chkAutoSnapshot_.getValue());
    packratOptions.setVcsIgnoreLib(chkVcsIgnoreLib_.getValue());
    packratOptions.setVcsIgnoreSrc(chkVcsIgnoreSrc_.getValue());
    packratOptions.setUseCache(chkUseCache_.getValue());
    packratOptions.setExternalPackages(JsUtil.toJsArrayString(getTextAreaValue(taExternalPackages_)));
    packratOptions.setLocalRepos(JsUtil.toJsArrayString(widgetLocalRepos_.getItems()));
    return false;
}
Also used : RProjectPackratOptions(org.rstudio.studio.client.projects.model.RProjectPackratOptions)

Aggregations

RProjectPackratOptions (org.rstudio.studio.client.projects.model.RProjectPackratOptions)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)1 Label (com.google.gwt.user.client.ui.Label)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 FixedTextArea (org.rstudio.core.client.widget.FixedTextArea)1 LabelWithHelp (org.rstudio.core.client.widget.LabelWithHelp)1 LocalRepositoriesWidget (org.rstudio.core.client.widget.LocalRepositoriesWidget)1 HelpLink (org.rstudio.studio.client.common.HelpLink)1 PackratContext (org.rstudio.studio.client.packrat.model.PackratContext)1