Esempio n. 1
0
  @Override
  protected void initialize(RPrefs rPrefs) {
    // general prefs
    GeneralPrefs generalPrefs = rPrefs.getGeneralPrefs();

    saveWorkspace_.setEnabled(true);
    loadRData_.setEnabled(true);
    dirChooser_.setEnabled(true);

    int saveWorkspaceIndex;
    switch (generalPrefs.getSaveAction()) {
      case SaveAction.NOSAVE:
        saveWorkspaceIndex = 1;
        break;
      case SaveAction.SAVE:
        saveWorkspaceIndex = 0;
        break;
      case SaveAction.SAVEASK:
      default:
        saveWorkspaceIndex = 2;
        break;
    }
    saveWorkspace_.getListBox().setSelectedIndex(saveWorkspaceIndex);

    loadRData_.setValue(generalPrefs.getLoadRData());
    dirChooser_.setText(generalPrefs.getInitialWorkingDirectory());

    // history prefs
    HistoryPrefs historyPrefs = rPrefs.getHistoryPrefs();

    alwaysSaveHistory_.setEnabled(true);
    removeHistoryDuplicates_.setEnabled(true);

    alwaysSaveHistory_.setValue(historyPrefs.getAlwaysSave());
    removeHistoryDuplicates_.setValue(historyPrefs.getRemoveDuplicates());

    rProfileOnResume_.setValue(generalPrefs.getRprofileOnResume());
    rProfileOnResume_.setEnabled(true);

    showLastDotValue_.setValue(generalPrefs.getShowLastDotValue());
    showLastDotValue_.setEnabled(true);

    if (rServerRVersion_ != null) rServerRVersion_.setRVersion(generalPrefs.getDefaultRVersion());

    if (rememberRVersionForProjects_ != null) {
      rememberRVersionForProjects_.setValue(generalPrefs.getRestoreProjectRVersion());
    }

    // projects prefs
    ProjectsPrefs projectsPrefs = rPrefs.getProjectsPrefs();
    restoreLastProject_.setEnabled(true);
    restoreLastProject_.setValue(projectsPrefs.getRestoreLastProject());
  }
Esempio n. 2
0
  @Override
  public boolean onApply(RPrefs rPrefs) {
    boolean restartRequired = super.onApply(rPrefs);

    if (saveWorkspace_.isEnabled()) {
      int saveAction;
      switch (saveWorkspace_.getListBox().getSelectedIndex()) {
        case 0:
          saveAction = SaveAction.SAVE;
          break;
        case 1:
          saveAction = SaveAction.NOSAVE;
          break;
        case 2:
        default:
          saveAction = SaveAction.SAVEASK;
          break;
      }

      // set general prefs
      GeneralPrefs generalPrefs =
          GeneralPrefs.create(
              saveAction,
              loadRData_.getValue(),
              rProfileOnResume_.getValue(),
              dirChooser_.getText(),
              getDefaultRVersion(),
              getRestoreProjectRVersion(),
              showLastDotValue_.getValue());
      rPrefs.setGeneralPrefs(generalPrefs);

      // set history prefs
      HistoryPrefs historyPrefs =
          HistoryPrefs.create(alwaysSaveHistory_.getValue(), removeHistoryDuplicates_.getValue());
      rPrefs.setHistoryPrefs(historyPrefs);

      // set projects prefs
      ProjectsPrefs projectsPrefs = ProjectsPrefs.create(restoreLastProject_.getValue());
      rPrefs.setProjectsPrefs(projectsPrefs);
    }

    return restartRequired;
  }
Esempio n. 3
0
 @Override
 protected RPrefs createEmptyPrefs() {
   return RPrefs.createEmpty();
 }