Ejemplo n.º 1
0
 private Label createErrorLabel() {
   Label label = new Label();
   Style style = label.getElement().getStyle();
   style.setDisplay(Display.NONE);
   style.setColor("#cc0000");
   style.setMarginTop(Widgets.defaultSpacing, Unit.PX);
   style.setMarginBottom(Widgets.defaultSpacing, Unit.PX);
   return label;
 }
Ejemplo n.º 2
0
  @Inject
  public GeneralPreferencesPane(
      RemoteFileSystemContext fsContext,
      FileDialogs fileDialogs,
      UIPrefs prefs,
      Session session,
      final GlobalDisplay globalDisplay,
      WorkbenchContext context) {
    fsContext_ = fsContext;
    fileDialogs_ = fileDialogs;
    prefs_ = prefs;
    session_ = session;

    RVersionsInfo versionsInfo = context.getRVersionsInfo();

    if (Desktop.isDesktop()) {
      if (Desktop.getFrame().canChooseRVersion()) {
        rVersion_ =
            new TextBoxWithButton(
                "R version:",
                "Change...",
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    String ver = Desktop.getFrame().chooseRVersion();
                    if (!StringUtil.isNullOrEmpty(ver)) {
                      rVersion_.setText(ver);

                      globalDisplay.showMessage(
                          MessageDialog.INFO,
                          "Change R Version",
                          "You need to quit and re-open RStudio "
                              + "in order for this change to take effect.");
                    }
                  }
                });
        rVersion_.setWidth("100%");
        rVersion_.setText(Desktop.getFrame().getRVersion());
        spaced(rVersion_);
        add(rVersion_);
      }
    } else if (versionsInfo.isMultiVersion()) {
      rServerRVersion_ = new RVersionSelectWidget(versionsInfo.getAvailableRVersions());
      add(tight(rServerRVersion_));

      rememberRVersionForProjects_ = new CheckBox("Restore last used R version for projects");

      rememberRVersionForProjects_.setValue(true);
      Style style = rememberRVersionForProjects_.getElement().getStyle();
      style.setMarginTop(5, Unit.PX);
      style.setMarginBottom(12, Unit.PX);
      add(rememberRVersionForProjects_);
    }

    Label defaultLabel = new Label("Default working directory (when not in a project):");
    nudgeRight(defaultLabel);
    add(tight(defaultLabel));
    add(dirChooser_ = new DirectoryChooserTextBox(null, null, fileDialogs_, fsContext_));
    spaced(dirChooser_);
    nudgeRight(dirChooser_);
    textBoxWithChooser(dirChooser_);

    restoreLastProject_ = new CheckBox("Restore most recently opened project at startup");
    lessSpaced(restoreLastProject_);
    add(restoreLastProject_);

    add(
        checkboxPref(
            "Restore previously open source documents at startup",
            prefs_.restoreSourceDocuments()));

    add(loadRData_ = new CheckBox("Restore .RData into workspace at startup"));
    lessSpaced(loadRData_);

    saveWorkspace_ =
        new SelectWidget(
            "Save workspace to .RData on exit:", new String[] {"Always", "Never", "Ask"});
    spaced(saveWorkspace_);
    add(saveWorkspace_);

    alwaysSaveHistory_ = new CheckBox("Always save history (even when not saving .RData)");
    lessSpaced(alwaysSaveHistory_);
    add(alwaysSaveHistory_);

    removeHistoryDuplicates_ = new CheckBox("Remove duplicate entries in history");
    spaced(removeHistoryDuplicates_);
    add(removeHistoryDuplicates_);

    showLastDotValue_ = new CheckBox("Show .Last.value in environment listing");
    lessSpaced(showLastDotValue_);
    add(showLastDotValue_);

    rProfileOnResume_ = new CheckBox("Run Rprofile when resuming suspended session");
    spaced(rProfileOnResume_);
    if (!Desktop.isDesktop()) add(rProfileOnResume_);

    // The error handler features require source references; if this R
    // version doesn't support them, don't show these options.
    if (session_.getSessionInfo().getHaveSrcrefAttribute()) {
      add(
          checkboxPref(
              "Use debug error handler only when my code contains errors",
              prefs_.handleErrorsInUserCodeOnly()));
      CheckBox chkTracebacks =
          checkboxPref(
              "Automatically expand tracebacks in error inspector",
              prefs_.autoExpandErrorTracebacks());
      chkTracebacks.getElement().getStyle().setMarginBottom(15, Unit.PX);
      add(chkTracebacks);
    }

    // provide check for updates option in desktop mode when not
    // already globally disabled
    if (Desktop.isDesktop() && !session.getSessionInfo().getDisableCheckForUpdates()) {
      add(checkboxPref("Automatically notify me of updates to RStudio", prefs_.checkForUpdates()));
    }

    saveWorkspace_.setEnabled(false);
    loadRData_.setEnabled(false);
    dirChooser_.setEnabled(false);
    alwaysSaveHistory_.setEnabled(false);
    removeHistoryDuplicates_.setEnabled(false);
    rProfileOnResume_.setEnabled(false);
    showLastDotValue_.setEnabled(false);
    restoreLastProject_.setEnabled(false);
  }
Ejemplo n.º 3
0
 @Override
 public void initialise(final GridBodyCellRenderContext context) {
   final Style style = widget.getElement().getStyle();
   style.setMarginTop((context.getCellHeight() - HEIGHT) / 2, Style.Unit.PX);
   transform(context);
 }