/**
   * Creates preferences with values loaded from store.
   *
   * @param prefs
   */
  public TaskTagsPreferences(final IPreferenceAccess prefs) {
    final String[] keywords = prefs.getPreferenceValue(PREF_TAGS);
    final List<TaskPriority> priorities = prefs.getPreferenceValue(PREF_PRIORITIES);

    if (keywords.length == priorities.size()) {
      TaskTag[] array = new TaskTag[keywords.length];
      for (int i = 0; i < array.length; i++) {
        array[i] = new TaskTag(keywords[i], priorities.get(i));
      }
      this.taskTags = new ConstArrayList<>(array);
    } else {
      this.taskTags = CollectionUtils.emptyConstList();
    }
  }
Exemple #2
0
  private void loadPrefs(final boolean custom) {
    final Change event = new Change(fREnv);
    final IPreferenceAccess prefs = PreferencesUtil.getInstancePrefs();
    getWriteLock().lock();
    try {
      if (custom) {
        fCustomRepos = prefs.getPreferenceValue(CUSTOM_REPO_PREF);
        fCustomCRAN = prefs.getPreferenceValue(CUSTOM_CRAN_MIRROR_PREF);
        fCustomBioC = prefs.getPreferenceValue(CUSTOM_BIOC_MIRROR_PREF);

        checkRepos(event);
      }
    } finally {
      getWriteLock().unlock();
    }
    fireUpdate(event);
  }
Exemple #3
0
  public RPkgManager(final IREnvConfiguration rConfig) {
    fREnv = rConfig.getReference();
    fREnvDirectory = EFS.getLocalFileSystem().getStore(REnvConfiguration.getStateLocation(fREnv));
    final String qualifier = ((AbstractPreferencesModelObject) rConfig).getNodeQualifiers()[0];
    fSelectedReposPref = new RRepoListPref(qualifier, "RPkg.Repos.repos"); // $NON-NLS-1$
    fSelectedCRANPref = new RRepoPref(qualifier, "RPkg.CRANMirror.repo"); // $NON-NLS-1$
    fBioCVersionPref = new StringPref2(qualifier, "RPkg.BioCVersion.ver"); // $NON-NLS-1$
    fSelectedBioCPref = new RRepoPref(qualifier, "RPkg.BioCMirror.repo"); // $NON-NLS-1$

    final IPreferenceAccess prefs = PreferencesUtil.getInstancePrefs();
    fAddRepos = new ArrayList<>();
    if (rConfig.getType() == IREnvConfiguration.USER_LOCAL_TYPE) {
      final String rjVersion =
          "" + ServerUtil.RJ_VERSION[0] + '.' + ServerUtil.RJ_VERSION[1]; // $NON-NLS-1$
      fAddRepos.add(
          new RRepo(
              RRepo.SPECIAL_PREFIX + "rj",
              "RJ",
              "http://download.walware.de/rj-" + rjVersion,
              null)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    fSelectedRepos =
        new SelectedRepos(
            prefs.getPreferenceValue(fSelectedReposPref),
            prefs.getPreferenceValue(fSelectedCRANPref),
            prefs.getPreferenceValue(fBioCVersionPref),
            prefs.getPreferenceValue(fSelectedBioCPref));

    fDB = DB.create(fREnv, fREnvDirectory);
    fCache = new Cache(fREnvDirectory);
    resetPkgs(rConfig);

    fFirstTime = true;
    fMirrorsStamp = fPkgsStamp = System.currentTimeMillis();
    fRequireLoad |= (REQUIRE_CRAN | REQUIRE_BIOC | REQUIRE_REPOS);
    fRequireLoad |= (REQUIRE_REPO_PKGS | REQUIRE_INST_PKGS);

    PreferencesUtil.getSettingsChangeNotifier().addManageListener(this);

    getWriteLock().lock();
    try {
      loadPrefs(true);
    } finally {
      getWriteLock().unlock();
    }
  }
 public static String[] loadTagsOnly(final IPreferenceAccess prefs) {
   return prefs.getPreferenceValue(PREF_TAGS);
 }