private static void initializeTextEditiongPreferences(final IPreferenceStore store) {
    //		// set the default values from ExtendedTextEditor
    //
    //	store.setValue(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE,
    // true);
    final DefaultScope scope = new DefaultScope();
    final IEclipsePreferences prefs = scope.getNode(StatetUIPlugin.PLUGIN_ID);
    final ThemeUtil theme = new ThemeUtil();

    // EditorPreferences
    prefs.putBoolean(DecorationPreferences.MATCHING_BRACKET_ENABLED_KEY, true);
    prefs.put(
        DecorationPreferences.MATCHING_BRACKET_COLOR_KEY,
        theme.getColorPrefValue(IWaThemeConstants.MATCHING_BRACKET_COLOR));

    {
      final IEclipsePreferences node =
          scope.getNode(IStatetUIPreferenceConstants.CAT_EDITOR_OPTIONS_QUALIFIER);
      final AssistPreferences assistPrefs = IStatetUIPreferenceConstants.EDITING_ASSIST_PREFERENCES;
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoActivationEnabledPref(), Boolean.TRUE);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoActivationDelayPref(), 200);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoInsertSinglePref(), Boolean.FALSE);
      PreferencesUtil.setPrefValue(scope, assistPrefs.getAutoInsertPrefixPref(), Boolean.FALSE);
      node.put(
          "Parameters.background",
          theme.getColorPrefValue(IWaThemeConstants.INFORMATION_BACKGROUND_COLOR)); // $NON-NLS-1$
      node.put(
          "Parameters.foreground",
          theme.getColorPrefValue(IWaThemeConstants.INFORMATION_COLOR)); // $NON-NLS-1$
    }
    //		store.setDefault(EDITOROUTLINE_SORT, false);
    //		store.setDefault(EDITOROUTLINE_LINKWITHEDITOR, true);
  }
Exemple #2
0
  private void checkMirrors(final Change event) {
    if ((fRequireLoad & (REQUIRE_CRAN | REQUIRE_BIOC)) != 0) {
      return;
    }

    SelectedRepos selected = fSelectedRepos;
    fAllCRAN = ConstArrayList.concat(fCustomCRAN, fRCRAN);

    RRepo selectedCRAN = selected.getCRANMirror();
    if (selected.getCRANMirror() != null) {
      selectedCRAN = Util.findRepo(fAllCRAN, selectedCRAN);
    } else if (fFirstTime && fSelectedCRANInR != null) {
      selectedCRAN = Util.getRepoByURL(fAllCRAN, fSelectedCRANInR);
    }
    if (selectedCRAN == null) {
      fRequireConfirm |= REQUIRE_CRAN;
      selectedCRAN = PreferencesUtil.getInstancePrefs().getPreferenceValue(LAST_CRAN_PREF);
      if (selectedCRAN != null) {
        selectedCRAN = Util.findRepo(fAllCRAN, selectedCRAN);
      }
      if (!fCustomCRAN.isEmpty()
          && (selectedCRAN == null || !selectedCRAN.getId().startsWith(RRepo.CUSTOM_PREFIX))) {
        selectedCRAN = fCustomCRAN.get(0);
      }
      if (fFirstTime && selectedCRAN == null) {
        selectedCRAN = fRCRANByCountry;
      }
    }

    RRepo selectedBioC = selected.getBioCMirror();
    fAllBioC = ConstArrayList.concat(fCustomBioC, fRBioC);
    if (selectedBioC != null) {
      selectedBioC = Util.findRepo(fAllBioC, selectedBioC);
    } else if (fFirstTime && fSelectedBioCInR != null) {
      selectedBioC = RPkgUtil.getRepoByURL(fAllBioC, fSelectedBioCInR);
    }
    if (selectedBioC == null) {
      fRequireConfirm |= REQUIRE_BIOC;
      selectedBioC = PreferencesUtil.getInstancePrefs().getPreferenceValue(LAST_BIOC_PREF);
      if (!fCustomBioC.isEmpty()
          && (selectedBioC == null || !selectedBioC.getId().startsWith(RRepo.CUSTOM_PREFIX))) {
        selectedBioC = fCustomBioC.get(0);
      }
      if (fFirstTime && selectedBioC == null) {
        selectedBioC = Util.getRepoByURL(fAllBioC, "http://www.bioconductor.org"); // $NON-NLS-1$
      }
    }

    selected = new SelectedRepos(selected.getRepos(), selectedCRAN, fBioCVersion, selectedBioC);
    if ((fRequireLoad & (REQUIRE_REPOS)) == 0) {
      for (final RRepo repo : fAllRepos) {
        if (repo instanceof RVarRepo) {
          ((RVarRepo) repo).updateURL(selected);
        }
      }
    }
    fSelectedRepos = selected;

    event.fPkgs = 1;
  }
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();
    }
  }
Exemple #4
0
  private void savePrefs(final SelectedRepos repos) {
    if (fREnv.getConfig() == null) {
      return;
    }
    final IScopeContext prefs = InstanceScope.INSTANCE;

    final IEclipsePreferences node = prefs.getNode(fSelectedReposPref.getQualifier());

    PreferencesUtil.setPrefValue(node, fSelectedReposPref, repos.getRepos());
    PreferencesUtil.setPrefValue(node, fSelectedCRANPref, repos.getCRANMirror());
    PreferencesUtil.setPrefValue(node, fBioCVersionPref, repos.getBioCVersion());
    PreferencesUtil.setPrefValue(node, fSelectedBioCPref, repos.getBioCMirror());

    if (repos.getCRANMirror() != null) {
      PreferencesUtil.setPrefValue(prefs, LAST_CRAN_PREF, repos.getCRANMirror());
    }
    if (repos.getBioCMirror() != null) {
      PreferencesUtil.setPrefValue(prefs, LAST_BIOC_PREF, repos.getBioCMirror());
    }

    try {
      node.flush();
    } catch (final BackingStoreException e) {
      RCorePlugin.log(
          new Status(
              IStatus.ERROR,
              RCore.PLUGIN_ID,
              "An error occurred when saving the R package manager preferences.",
              e));
    }
  }
  public static String getTodoTaskTag(final StatetProject project) {
    final TaskTagsPreferences taskPrefs =
        (project != null)
            ? new TaskTagsPreferences(project)
            : new TaskTagsPreferences(PreferencesUtil.getInstancePrefs());

    final String[] markers = taskPrefs.getTags();

    if (markers == null || markers.length == 0) {
      return null;
    }
    return markers[0];
  }
Exemple #6
0
public class NicoCore {

  /** Plugin-ID Value: @value */
  public static final String PLUGIN_ID = "de.walware.statet.nico.core"; // $NON-NLS-1$

  public static final int STATUS_CATEGORY = (3 << 16);

  /** Status Code for errors when handle Threads/Runnables */
  public static final int STATUSCODE_RUNTIME_ERROR = STATUS_CATEGORY | (2 << 8);

  public static final int EXITVALUE_CORE_EXCEPTION = STATUSCODE_RUNTIME_ERROR | 1;
  public static final int EXITVALUE_RUNTIME_EXCEPTION = STATUSCODE_RUNTIME_ERROR | 2;

  private static IPreferenceAccess CONSOLE_PREFS =
      PreferencesUtil.createAccess(
          new IScopeContext[] {
            new ConsoleInstanceScope(),
            new ConsoleDefaultScope(),
            new InstanceScope(),
            new DefaultScope()
          });

  /**
   * The instance preferences for consoles with the scope search path:
   *
   * <ol>
   *   <li>ConsoleInstance
   *   <li>ConsoleDefault
   *   <li>Instance
   *   <li>Default
   *
   * @return shared preference access to the preferences
   */
  public static IPreferenceAccess getInstanceConsolePreferences() {
    return CONSOLE_PREFS;
  }

  public static void addToolLifeListener(final IToolLifeListener listener) {
    NicoPlugin.getDefault().getToolLifecycle().addToolLifeListener(listener);
  }

  public static void removeToolLifeListener(final IToolLifeListener listener) {
    NicoPlugin.getDefault().getToolLifecycle().removeToolLifeListener(listener);
  }

  private NicoCore() {}
}
Exemple #7
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 #8
0
 public void dispose() {
   PreferencesUtil.getSettingsChangeNotifier().removeManageListener(this);
 }