Examples of IEclipsePreferences


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

  /**
   * @see org.aspectj.org.eclipse.jdt.core.IJavaProject#setOptions(Map)
   */
  public void setOptions(Map newOptions) {

    IEclipsePreferences projectPreferences = getEclipsePreferences();
    try {
      if (newOptions == null){
        projectPreferences.clear();
      } else {
        Iterator entries = newOptions.entrySet().iterator();
        while (entries.hasNext()){
          Map.Entry entry = (Map.Entry) entries.next();
          String key = (String) entry.getKey();
          if (!JavaModelManager.getJavaModelManager().optionNames.contains(key)) continue; // unrecognized option
          // no filtering for encoding (custom encoding for project is allowed)
          projectPreferences.put(key, (String) entry.getValue());
        }
       
        // reset to default all options not in new map
        // @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=26255
        // @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49691
        String[] pNames = projectPreferences.keys();
        int ln = pNames.length;
        for (int i=0; i<ln; i++) {
          String key = pNames[i];
          if (!newOptions.containsKey(key)) {
            projectPreferences.remove(key); // old preferences => remove from preferences table
          }
        }
      }

      // persist options
      projectPreferences.flush();
     
      // flush cache immediately
      try {
        getPerProjectInfo().options = null;
      } catch (JavaModelException e) {
View Full Code Here

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

    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

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

  }
 
  public void setOptions(Hashtable newOptions) {
   
    try {
      IEclipsePreferences defaultPreferences = getDefaultPreferences();
      IEclipsePreferences instancePreferences = getInstancePreferences();

      if (newOptions == null){
        instancePreferences.clear();
      } else {
        Enumeration keys = newOptions.keys();
        while (keys.hasMoreElements()){
          String key = (String)keys.nextElement();
          if (!this.optionNames.contains(key)) continue; // unrecognized option
          if (key.equals(JavaCore.CORE_ENCODING)) continue; // skipped, contributed by resource prefs
          String value = (String)newOptions.get(key);
          String defaultValue = defaultPreferences.get(key, null);
          if (defaultValue != null && defaultValue.equals(value)) {
            instancePreferences.remove(key);
          } else {
            instancePreferences.put(key, value);
          }
        }
      }

      // persist options
      instancePreferences.flush();
     
      // update cache
      this.optionsCache = newOptions==null ? null : new Hashtable(newOptions);
    } catch (BackingStoreException e) {
      // ignore
View Full Code Here

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

          // TODO (eric) - investigate after 3.3 if variables should be saved for a SNAPSHOT
        case ISaveContext.SNAPSHOT :
          // 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

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

    return (String[]) set.toArray(new String[set.size()]);
  }
 
  private void initialize() {
    this.userLibraries = new HashMap();
    IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
    String[] propertyNames;
    try {
      propertyNames = instancePreferences.keys();
    } catch (BackingStoreException e) {
      Util.log(e, "Exception while initializing user libraries"); //$NON-NLS-1$
      return;
    }

    boolean preferencesNeedFlush = false;
    for (int i = 0, length = propertyNames.length; i < length; i++) {
      String propertyName = propertyNames[i];
      if (propertyName.startsWith(CP_USERLIBRARY_PREFERENCES_PREFIX)) {
        String propertyValue = instancePreferences.get(propertyName, null);
        if (propertyValue != null) {
          String libName= propertyName.substring(CP_USERLIBRARY_PREFERENCES_PREFIX.length());
          StringReader reader = new StringReader(propertyValue);
          UserLibrary library;
          try {
            library = UserLibrary.createFromString(reader);
          } catch (IOException e) {
            Util.log(e, "Exception while initializing user library " + libName); //$NON-NLS-1$
            instancePreferences.remove(propertyName);
            preferencesNeedFlush = true;
            continue;
          }
          this.userLibraries.put(libName, library);
        }
      }
    }
    if (preferencesNeedFlush) {
      try {
        instancePreferences.flush();
      } catch (BackingStoreException e) {
        Util.log(e, "Exception while flusing instance preferences"); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

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

      }
    }
  }
 
  public synchronized void removeUserLibrary(String libName)  {
    IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
    String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName;
    instancePreferences.remove(propertyName);
    try {
      instancePreferences.flush();
    } catch (BackingStoreException e) {
      Util.log(e, "Exception while removing user library " + libName); //$NON-NLS-1$
    }
    // this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...))
  }
View Full Code Here

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

    }
    // this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...))
  }
 
  public synchronized void setUserLibrary(String libName, IClasspathEntry[] entries, boolean isSystemLibrary)  {
    IEclipsePreferences instancePreferences = JavaModelManager.getJavaModelManager().getInstancePreferences();
    String propertyName = CP_USERLIBRARY_PREFERENCES_PREFIX+libName;
    try {
      String propertyValue = UserLibrary.serialize(entries, isSystemLibrary);
      instancePreferences.put(propertyName, propertyValue); // sends out a PreferenceChangeEvent (see preferenceChange(...))
    } catch (IOException e) {
      Util.log(e, "Exception while serializing user library " + libName); //$NON-NLS-1$
      return;
    }
    try {
      instancePreferences.flush();
    } catch (BackingStoreException e) {
      Util.log(e, "Exception while saving user library " + libName); //$NON-NLS-1$
    }
    // this.userLibraries was updated during the PreferenceChangeEvent (see preferenceChange(...))
  }
View Full Code Here

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

  };

  @Override
  public void handleCommand(HttpServletRequest req, HttpServletResponse resp,
      IUser user) throws IOException {
    IEclipsePreferences users = new OrionScope().getNode("Users"); //$NON-NLS-1$
    IEclipsePreferences result = (IEclipsePreferences) users.node(user
        .getUserID());
    String workbenchSettings = result.get(
        MaqettaOrionServerConstants.WORKBENCH_PREF, "{}");
    try {
      String c = this.getSiteJson();
      String temp = "{\n" + "\t\"workbenchState\":"
          + workbenchSettings + ",\n" + "\t\"userInfo\":{\"userId\": \""
View Full Code Here

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

public class SetWorkbenchState extends Command {

   
    public void handleCommand(HttpServletRequest req, HttpServletResponse resp, IUser user) throws IOException {
      IEclipsePreferences users = new OrionScope().getNode("Users"); //$NON-NLS-1$
    IEclipsePreferences result = (IEclipsePreferences) users.node(user.getUserID());
          // read it with BufferedReader
      BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream()));
    
      String line;
      String value = "";
      while ((line = br.readLine()) != null) {
        value+=line;
      }
      br.close();

      result.put(MaqettaOrionServerConstants.WORKBENCH_PREF, value);
    try {
      //flush directly at root level to workaround equinox bug 389754.
      result.parent().flush();
    } catch (BackingStoreException e) {
      LogHelper.log(e);
    }
   }
View Full Code Here

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

    /* sets the init flag on the user. returns 'true' if this happened (so that we can setup any user project files */
    private boolean init(String userName){
    assertValidUserId(userName);

    IEclipsePreferences users = new OrionScope().getNode("Users"); //$NON-NLS-1$
    IEclipsePreferences result = (IEclipsePreferences) users.node(userName);
          // read it with BufferedReader
      boolean wasInit = result.getBoolean("maqettaInit", false);
    
      if(!wasInit){
        result.putBoolean("maqettaInit", true);
        try {
          //flush directly at root level to workaround equinox bug 389754.
          result.parent().flush();
        } catch (BackingStoreException e) {
          LogHelper.log(e);
        }
      }
      return !wasInit;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.