Package org.eclipse.core.runtime.preferences

Examples of org.eclipse.core.runtime.preferences.IEclipsePreferences


        /*
         * @see EclipsePreferences#getChild(String, Plugin)
         */
        protected synchronized IEclipsePreferences getChild(String key, Plugin context) {
            Object value = null;
            IEclipsePreferences child = null;
            if (children != null)
                value = children.get(key);
            if (value != null) {
                if (value instanceof IEclipsePreferences)
                    return (IEclipsePreferences) value;
View Full Code Here


            if (path.length() == 0 || (path.length() == 1 && path.charAt(0) == IPath.SEPARATOR))
                return this;
            int startIndex = path.charAt(0) == IPath.SEPARATOR ? 1 : 0;
            int endIndex = path.indexOf(IPath.SEPARATOR, startIndex + 1);
            String scope = path.substring(startIndex, endIndex == -1 ? path.length() : endIndex);
            IEclipsePreferences child = getChild(scope, null);
            if (child == null) {
                child = new SLDPreferences(this, scope);
                addChild(scope, child);
            }
            return child.node(endIndex == -1 ? "" : path.substring(endIndex + 1)); //$NON-NLS-1$
        }
View Full Code Here

    Hashtable defaultOptions = new Hashtable(10);

    // see JavaCorePreferenceInitializer#initializeDefaultPluginPreferences() for changing default settings
    // If modified, also modify the method getDefaultOptionsNoInitialization()
    IEclipsePreferences defaultPreferences = getDefaultPreferences();

    // initialize preferences to their default
    Iterator iterator = this.optionNames.iterator();
    while (iterator.hasNext()) {
        String propertyName = (String) iterator.next();
        String value = defaultPreferences.get(propertyName, null);
        if (value != null) defaultOptions.put(propertyName, value);
    }
    // get encoding through resource plugin
    defaultOptions.put(JavaCore.CORE_ENCODING, JavaCore.getEncoding());
    // backward compatibility
View Full Code Here

        System.out.println("    + "+elements[i]); //$NON-NLS-1$
      }
    }

      Hashtable cachedValue = newOptions == null ? null : new Hashtable(newOptions);
      IEclipsePreferences defaultPreferences = getDefaultPreferences();
      IEclipsePreferences instancePreferences = getInstancePreferences();

      if (newOptions == null){
        try {
          instancePreferences.clear();
        } catch(BackingStoreException e) {
          // ignore
        }
      } else {
        Enumeration keys = newOptions.keys();
        while (keys.hasMoreElements()){
          String key = (String)keys.nextElement();
          int optionLevel = getOptionLevel(key);
          if (optionLevel == UNKNOWN_OPTION) continue; // unrecognized option
          if (key.equals(JavaCore.CORE_ENCODING)) {
            if (cachedValue != null) {
              cachedValue.put(key, JavaCore.getEncoding());
            }
            continue; // skipped, contributed by resource prefs
          }
          String value = (String) newOptions.get(key);
          String defaultValue = defaultPreferences.get(key, null);
          // Store value in preferences
          if (defaultValue != null && defaultValue.equals(value)) {
            value = null;
          }
          storePreference(key, value, instancePreferences);
        }
        try {
          // persist options
          instancePreferences.flush();
        } catch(BackingStoreException e) {
          // ignore
        }
      }
      // update cache
View Full Code Here

  private void startIndexing() {
    if (this.indexManager != null) this.indexManager.reset();
  }

  public void shutdown () {
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID);
    try {
      preferences.flush();
    } catch (BackingStoreException e) {
      Util.log(e, "Could not save JavaCore preferences"); //$NON-NLS-1$
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    workspace.removeResourceChangeListener(this.deltaState);
    workspace.removeSaveParticipant(JavaCore.PLUGIN_ID);

    // Stop listening to content-type changes
    Platform.getContentTypeManager().removeContentTypeChangeListener(this);

    // Stop indexing
    if (this.indexManager != null) {
      this.indexManager.shutdown();
    }

    // Stop listening to preferences changes
    preferences.removePreferenceChangeListener(this.propertyListener);
    ((IEclipsePreferences) this.preferencesLookup[PREF_DEFAULT].parent()).removeNodeChangeListener(this.defaultNodeListener);
    this.preferencesLookup[PREF_DEFAULT] = null;
    ((IEclipsePreferences) this.preferencesLookup[PREF_INSTANCE].parent()).removeNodeChangeListener(this.instanceNodeListener);
    this.preferencesLookup[PREF_INSTANCE].removePreferenceChangeListener(this.instancePreferencesListener);
    this.preferencesLookup[PREF_INSTANCE] = null;
View Full Code Here

    void save(ISaveContext context) throws IOException, JavaModelException {
      saveProjects(getJavaModel().getJavaProjects());
      // remove variables that should not be saved
      HashMap varsToSave = null;
      Iterator iterator = JavaModelManager.this.variables.entrySet().iterator();
      IEclipsePreferences defaultPreferences = getDefaultPreferences();
      while (iterator.hasNext()) {
        Map.Entry entry = (Map.Entry) iterator.next();
        String varName = (String) entry.getKey();
        if (defaultPreferences.get(CP_VARIABLE_PREFERENCES_PREFIX + varName, null) != null // don't save classpath variables from the default preferences as there is no delta if they are removed
            || CP_ENTRY_IGNORE_PATH.equals(entry.getValue())) {

          if (varsToSave == null)
            varsToSave = new HashMap(JavaModelManager.this.variables);
          varsToSave.remove(varName);
View Full Code Here

  public void close() throws JavaModelException {
    if (JavaProject.hasJavaNature(this.project)) {
      // Get cached preferences if exist
      JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, false);
      if (perProjectInfo != null && perProjectInfo.preferences != null) {
        IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) perProjectInfo.preferences.parent();
        if (this.preferencesNodeListener != null) {
          eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener);
          this.preferencesNodeListener = null;
        }
        if (this.preferencesChangeListener != null) {
          perProjectInfo.preferences.removePreferenceChangeListener(this.preferencesChangeListener);
          this.preferencesChangeListener = null;
View Full Code Here

    // Get cached preferences if exist
    JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfo(this.project, true);
    if (perProjectInfo.preferences != null) return perProjectInfo.preferences;
    // Init project preferences
    IScopeContext context = new ProjectScope(getProject());
    final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID);
    updatePreferences(eclipsePreferences);
    perProjectInfo.preferences = eclipsePreferences;

    // Listen to new preferences node
    final IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) eclipsePreferences.parent();
    if (eclipseParentPreferences != null) {
      if (this.preferencesNodeListener != null) {
        eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener);
      }
      this.preferencesNodeListener = new IEclipsePreferences.INodeChangeListener() {
        public void added(IEclipsePreferences.NodeChangeEvent event) {
          // do nothing
        }
        public void removed(IEclipsePreferences.NodeChangeEvent event) {
          if (event.getChild() == eclipsePreferences) {
            JavaModelManager.getJavaModelManager().resetProjectPreferences(JavaProject.this);
          }
        }
      };
      eclipseParentPreferences.addNodeChangeListener(this.preferencesNodeListener);
    }

    // Listen to preferences changes
    if (this.preferencesChangeListener != null) {
      eclipsePreferences.removePreferenceChangeListener(this.preferencesChangeListener);
View Full Code Here

    try {
      perProjectInfo = getPerProjectInfo();
      projectOptions = perProjectInfo.options;
      if (projectOptions == null) {
        // get eclipse preferences
        IEclipsePreferences projectPreferences= getEclipsePreferences();
        if (projectPreferences == null) return options; // cannot do better (non-Java project)
        // create project options
        String[] propertyNames = projectPreferences.keys();
        projectOptions = new Hashtable(propertyNames.length);
        for (int i = 0; i < propertyNames.length; i++){
          String propertyName = propertyNames[i];
          String value = projectPreferences.get(propertyName, null);
          if (value != null) {
            value = value.trim();
            // Keep the option value, even if it's deprecated
            // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987
            projectOptions.put(propertyName, value);
View Full Code Here

  /**
   * load preferences from a shareable format (VCM-wise)
   */
   private IEclipsePreferences loadPreferences() {

     IEclipsePreferences preferences = null;
     IPath projectMetaLocation = getPluginWorkingLocation();
    if (projectMetaLocation != null) {
      File prefFile = projectMetaLocation.append(PREF_FILENAME).toFile();
      if (prefFile.exists()) { // load preferences from file
        InputStream in = null;
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.preferences.IEclipsePreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.