Example #1
0
  /**
   * Set all the processor options in one call. This will delete any options that are not passed in,
   * so callers who do not wish to destroy pre-existing options should use addProcessorOption()
   * instead.
   *
   * @param options a map of keys to values. The keys should not include any automatic options (@see
   *     #isAutomaticProcessorOption(String)), and the "-A" should not be included. That is, to
   *     perform the equivalent of the apt command line "-Afoo=bar", use the key "foo" and the value
   *     "bar". Keys cannot contain spaces; values can contain anything at all. Keys cannot be null,
   *     but values can be.
   */
  public static void setProcessorOptions(Map<String, String> options, IJavaProject jproj) {
    IScopeContext context =
        (null != jproj) ? new ProjectScope(jproj.getProject()) : InstanceScope.INSTANCE;

    // TODO: this call is needed only for backwards compatibility with
    // settings files previous to 2005.11.13.  At some point it should be
    // removed.
    removeOldStyleSettings(context);

    IEclipsePreferences node =
        context.getNode(
            AptPlugin.PLUGIN_ID
                + "/"
                + //$NON-NLS-1$
                AptPreferenceConstants.APT_PROCESSOROPTIONS);
    try {
      node.clear();
      for (Entry<String, String> option : options.entrySet()) {
        String nonNullVal =
            option.getValue() == null ? AptPreferenceConstants.APT_NULLVALUE : option.getValue();
        node.put(option.getKey(), nonNullVal);
      }
      node.flush();
    } catch (BackingStoreException e) {
      AptPlugin.log(e, "Unable to save annotation processor options"); // $NON-NLS-1$
    }
  }
Example #2
0
  @Override
  protected void initialSetup() throws Exception {
    // disable auto build
    WorkspaceUtil.setAutobuilding(false);

    TestingUtilities.importTestingProjectIntoWorkspace("RTOMoveTests");

    IProject testProject = getProjectHandle("RTOMoveTests");
    m_sys = getSystemModel(testProject.getName());
    m_sys.setUseglobals(true);
    m_sys.getPersistableComponent().loadComponentAndChildren(new NullProgressMonitor());

    IScopeContext projectScope = new ProjectScope(testProject);
    Preferences projectNode =
        projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
    projectNode.putBoolean(BridgePointProjectReferencesPreferences.BP_PROJECT_REFERENCES_ID, true);

    IProject inscope = TestingUtilities.createProject("InScope Other");
    inscopeOtherProject = getSystemModel(inscope.getName());
    inscopeOtherProject.setUseglobals(true);
    projectScope = new ProjectScope(inscope);
    projectNode = projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
    projectNode.putBoolean(BridgePointProjectReferencesPreferences.BP_PROJECT_REFERENCES_ID, true);
    inscopeOtherProject.Newpackage();
    IProject outOfScope = TestingUtilities.createProject("OutOfScope Other");
    outOfScopeOtherProject = getSystemModel(outOfScope.getName());
    outOfScopeOtherProject.Newpackage();
  }
  protected void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
      IScopeContext projectScope = fPreferencesAccess.getProjectScope(projects[i]);
      IEclipsePreferences node = projectScope.getNode(JavaUI.ID_PLUGIN);
      String profileId = node.get(fProfileKey, null);
      if (oldName.equals(profileId)) {
        if (newProfile == null) {
          node.remove(fProfileKey);
        } else {
          if (applySettings) {
            writeToPreferenceStore(newProfile, projectScope);
          } else {
            node.put(fProfileKey, newProfile.getID());
          }
        }
      }
    }

    IScopeContext instanceScope = fPreferencesAccess.getInstanceScope();
    final IEclipsePreferences uiPrefs = instanceScope.getNode(JavaUI.ID_PLUGIN);
    if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
      writeToPreferenceStore(newProfile, instanceScope);
    }
  }
 private static void savePreferences(final IScopeContext context) throws BackingStoreException {
   try {
     context.getNode(JavaUI.ID_PLUGIN).flush();
   } finally {
     context.getNode(JavaCore.PLUGIN_ID).flush();
   }
 }
  private void setProjectProperties(final IProject project, final GridProjectProperties props)
      throws CoreException {

    IVirtualOrganization projectVo = props.getProjectVo();
    String voName = projectVo.getName();
    Hashtable<String, String> folders = props.getProjectFolders();

    IScopeContext projectScope = new ProjectScope(project);

    try {

      Preferences projectNode = projectScope.getNode("eu.geclipse.core"); // $NON-NLS-1$
      projectNode.put("vo", voName); // $NON-NLS-1$
      projectNode.flush();

      Preferences folderNode = projectScope.getNode("eu.geclipse.core.folders"); // $NON-NLS-1$
      for (String id : folders.keySet()) {
        String label = folders.get(id);
        folderNode.put(id, label);
      }
      folderNode.flush();

    } catch (BackingStoreException bsExc) {
      IStatus status =
          new Status(
              IStatus.ERROR,
              Activator.PLUGIN_ID,
              IStatus.CANCEL,
              Messages.getString(
                  "GridProjectCreationOperation.set_preferences_failed"), //$NON-NLS-1$
              bsExc);
      throw new CoreException(status);
    }
  }
  public void testGetNode() {
    IScopeContext context = new InstanceScope();

    // null
    try {
      context.getNode(null);
      fail("1.0");
    } catch (IllegalArgumentException e) {
      // expected
    }

    // valid single segment
    String qualifier = Long.toString(System.currentTimeMillis());
    Preferences node = context.getNode(qualifier);
    assertNotNull("2.0", node);
    String expected = "/instance/" + qualifier;
    String actual = node.absolutePath();
    assertEquals("2.1", expected, actual);

    // path
    qualifier = new Path(Long.toString(System.currentTimeMillis())).append("a").toString();
    node = context.getNode(qualifier);
    assertNotNull("3.0", node);
    expected = "/instance/" + qualifier;
    actual = node.absolutePath();
    assertEquals("3.1", expected, actual);
  }
  public static void checkCurrentOptionsVersion() {
    PreferencesAccess access = PreferencesAccess.getOriginalPreferences();
    ProfileVersioner profileVersioner = new ProfileVersioner();

    IScopeContext instanceScope = access.getInstanceScope();
    IEclipsePreferences uiPreferences = instanceScope.getNode(JavaUI.ID_PLUGIN);
    int version = uiPreferences.getInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, 0);
    if (version >= profileVersioner.getCurrentVersion()) {
      return; // is up to date
    }
    try {
      List<Profile> profiles =
          (new FormatterProfileStore(profileVersioner)).readProfiles(instanceScope);
      if (profiles == null) {
        profiles = new ArrayList<Profile>();
      }
      ProfileManager manager =
          new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
      if (manager.getSelected() instanceof CustomProfile) {
        manager.commitChanges(instanceScope); // updates JavaCore options
      }
      uiPreferences.putInt(
          PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, profileVersioner.getCurrentVersion());
      savePreferences(instanceScope);
    } catch (CoreException e) {
      JavaPlugin.log(e);
    } catch (BackingStoreException e) {
      JavaPlugin.log(e);
    }
  }
Example #8
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));
    }
  }
Example #9
0
  private IEclipsePreferences getProjectScope(IProject project) {
    if (project == null) {
      return null;
    }

    IScopeContext projectScope = new ProjectScope(project);
    return projectScope.getNode(PLUGIN_ID);
  }
 private void setProjectPreference(String key, boolean value) throws BackingStoreException {
   BaseTest.dispatchEvents(0);
   IScopeContext projectScope = new ProjectScope(project);
   Preferences projectNode =
       projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
   projectNode.putBoolean(key, value);
   BaseTest.dispatchEvents(0);
 }
  public void clearAllSettings(IScopeContext context) {
    for (int i = 0; i < fKeySets.length; i++) {
      updatePreferences(
          context.getNode(fKeySets[i].getNodeName()),
          fKeySets[i].getKeys(),
          Collections.<String, String>emptyMap());
    }

    final IEclipsePreferences uiPrefs = context.getNode(JavaUI.ID_PLUGIN);
    uiPrefs.remove(fProfileKey);
  }
 public void testBadContext() {
   IScopeContext context = new BadTestScope();
   IPreferencesService service = Platform.getPreferencesService();
   try {
     context.getNode("qualifier");
     fail("0.5"); // should throw an exception
   } catch (RuntimeException e) {
     // expected
   }
   assertNull("1.0", service.getString("qualifier", "foo", null, new IScopeContext[] {context}));
 }
  /*
   * @see TestCase#setUp()
   */
  protected void setUp() throws Exception {
    super.setUp();
    project = createPredefinedProject("Simple AJ Project"); // $NON-NLS-1$
    jp = JavaCore.create(project);

    prefStore = AspectJUIPlugin.getDefault().getPreferenceStore();
    AJCompilerPreferencePage.initDefaults(prefStore);

    IScopeContext projectScope = new ProjectScope(project);
    projectNode = projectScope.getNode(AspectJPlugin.PLUGIN_ID);
  }
Example #14
0
 private static void setBoolean(IJavaProject jproject, String optionName, boolean value) {
   IScopeContext context =
       (null != jproject) ? new ProjectScope(jproject.getProject()) : InstanceScope.INSTANCE;
   IEclipsePreferences node = context.getNode(AptPlugin.PLUGIN_ID);
   // get old val as a String, so it can be null if setting doesn't exist yet
   String oldValue = node.get(optionName, null);
   node.putBoolean(optionName, value);
   if (jproject != null && oldValue == null || (value != Boolean.parseBoolean(oldValue))) {
     AptProject aproj = AptPlugin.getAptProject(jproject);
     aproj.preferenceChanged(optionName);
   }
   flushPreference(optionName, node);
 }
 /**
  * Set the org.eclipse.jdt.core.compiler.processAnnotations setting. In Eclipse 3.3, this value
  * replaces org.eclipse.jdt.apt.aptEnabled, but we continue to set both values in order to ensure
  * backward compatibility with prior versions. the aptEnabled setting.
  *
  * @param enable
  */
 private void setJDTProcessAnnotationsSetting(boolean enable) {
   IScopeContext context =
       (null != fJProj) ? new ProjectScope(fJProj.getProject()) : InstanceScope.INSTANCE;
   IEclipsePreferences node = context.getNode(JavaCore.PLUGIN_ID);
   final String value = enable ? AptPreferenceConstants.ENABLED : AptPreferenceConstants.DISABLED;
   node.put(AptPreferenceConstants.APT_PROCESSANNOTATIONS, value);
   try {
     node.flush();
   } catch (BackingStoreException e) {
     AptPlugin.log(
         e,
         "Failed to save preference: "
             + AptPreferenceConstants.APT_PROCESSANNOTATIONS); // $NON-NLS-1$
   }
 }
 public static boolean getProjectBoolean(final String key, final String projectName) {
   IProject selectedProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
   if (selectedProject != null) {
     IScopeContext projectScope = new ProjectScope(selectedProject);
     Preferences projectNode =
         projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
     boolean rVal = false;
     if (key.equals(BP_PROJECT_EMITRTODATA_ID)) {
       rVal = projectNode.getBoolean(key, getEmitRTODataWorkspaceSetting());
     } else {
       rVal = projectNode.getBoolean(key, false);
     }
     return rVal;
   }
   return false;
 }
Example #17
0
 private static void setString(IJavaProject jproject, String optionName, String value) {
   IScopeContext context =
       (null != jproject) ? new ProjectScope(jproject.getProject()) : InstanceScope.INSTANCE;
   IEclipsePreferences node;
   if (AptPreferenceConstants.APT_PROCESSANNOTATIONS.equals(optionName)) {
     node = context.getNode(JavaCore.PLUGIN_ID);
   } else {
     node = context.getNode(AptPlugin.PLUGIN_ID);
   }
   String oldValue = node.get(optionName, null);
   node.put(optionName, value);
   if (jproject != null && !value.equals(oldValue)) {
     AptProject aproj = AptPlugin.getAptProject(jproject);
     aproj.preferenceChanged(optionName);
   }
   flushPreference(optionName, node);
 }
 protected String getSelectedProfileId(IScopeContext instanceScope) {
   String profileId = instanceScope.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null);
   if (profileId == null) {
     // request from bug 129427
     profileId = DefaultScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null);
   }
   return profileId;
 }
Example #19
0
  /**
   * Get the options that are presented to annotation processors by the
   * AnnotationProcessorEnvironment. The -A and = are stripped out, so (key, value) is the
   * equivalent of -Akey=value.
   *
   * <p>This method differs from getProcessorOptions in that the options returned by this method do
   * NOT include any programmatically set options. This method returns only the options that are
   * persisted to the preference store and that are displayed in the configuration GUI.
   *
   * @param jproj a project, or null to query the workspace-wide setting. If jproj is not null, but
   *     the project has no per-project settings, this method will fall back to the workspace-wide
   *     settings.
   * @return a mutable, possibly empty, map of (key, value) pairs. The value part of a pair may be
   *     null (equivalent to "-Akey"). The value part can contain spaces, if it is quoted:
   *     -Afoo="bar baz".
   */
  public static Map<String, String> getRawProcessorOptions(IJavaProject jproj) {
    Map<String, String> options = new HashMap<String, String>();

    // TODO: this code is needed only for backwards compatibility with
    // settings files previous to 2005.11.13.  At some point it should be
    // removed.
    // If an old-style setting exists, add it into the mix for backward
    // compatibility.
    options.putAll(getOldStyleRawProcessorOptions(jproj));

    // Fall back from project to workspace scope on an all-or-nothing basis,
    // not value by value.  (Never fall back to default scope; there are no
    // default processor options.)  We can't use IPreferencesService for this
    // as we would normally do, because we don't know the names of the keys.
    IScopeContext[] contexts;
    if (jproj != null) {
      contexts = new IScopeContext[] {new ProjectScope(jproj.getProject()), InstanceScope.INSTANCE};
    } else {
      contexts = new IScopeContext[] {InstanceScope.INSTANCE};
    }
    for (IScopeContext context : contexts) {
      IEclipsePreferences prefs = context.getNode(AptPlugin.PLUGIN_ID);
      try {
        if (prefs.childrenNames().length > 0) {
          IEclipsePreferences procOptionsNode =
              context.getNode(
                  AptPlugin.PLUGIN_ID
                      + "/"
                      + AptPreferenceConstants.APT_PROCESSOROPTIONS); // $NON-NLS-1$
          if (procOptionsNode != null) {
            for (String key : procOptionsNode.keys()) {
              String nonNullVal = procOptionsNode.get(key, null);
              String val =
                  AptPreferenceConstants.APT_NULLVALUE.equals(nonNullVal) ? null : nonNullVal;
              options.put(key, val);
            }
            break;
          }
        }
      } catch (BackingStoreException e) {
        AptPlugin.log(e, "Unable to load annotation processor options"); // $NON-NLS-1$
      }
    }
    return options;
  }
Example #20
0
 /**
  * Remove an option from the list of processor options.
  *
  * @param jproj a project, or null to remove the option workspace-wide.
  * @param key must be a nonempty string. It should only include the key; that is, it should not
  *     start with "-A".
  */
 public static void removeProcessorOption(IJavaProject jproj, String key) {
   if (key == null || key.length() < 1) {
     throw new IllegalArgumentException();
   }
   IScopeContext context =
       (null != jproj) ? new ProjectScope(jproj.getProject()) : InstanceScope.INSTANCE;
   IEclipsePreferences node =
       context.getNode(
           AptPlugin.PLUGIN_ID
               + "/"
               + //$NON-NLS-1$
               AptPreferenceConstants.APT_PROCESSOROPTIONS);
   node.remove(key);
   try {
     node.flush();
   } catch (BackingStoreException e) {
     AptPlugin.log(e, "Unable to save annotation processor option" + key); // $NON-NLS-1$
   }
 }
  /**
   * Update all formatter settings with the settings of the specified profile.
   *
   * @param profile The profile to write to the preference store
   */
  private void writeToPreferenceStore(Profile profile, IScopeContext context) {
    final Map<String, String> profileOptions = profile.getSettings();

    for (int i = 0; i < fKeySets.length; i++) {
      updatePreferences(
          context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
    }

    final IEclipsePreferences uiPrefs = context.getNode(JavaUI.ID_PLUGIN);
    if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
      uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
    }

    if (context.getName() == InstanceScope.SCOPE) {
      uiPrefs.put(fProfileKey, profile.getID());
    } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
      uiPrefs.put(fProfileKey, profile.getID());
    }
  }
  /**
   * Only to read project specific settings to find out to what profile it matches.
   *
   * @param context The project context
   */
  private Map<String, String> readFromPreferenceStore(
      IScopeContext context, Profile workspaceProfile) {
    final Map<String, String> profileOptions = new HashMap<String, String>();
    IEclipsePreferences uiPrefs = context.getNode(JavaUI.ID_PLUGIN);

    int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
    if (version != fProfileVersioner.getCurrentVersion()) {
      Map<String, String> allOptions = new HashMap<String, String>();
      for (int i = 0; i < fKeySets.length; i++) {
        addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
      }
      CustomProfile profile =
          new CustomProfile(
              "tmp", allOptions, version, fProfileVersioner.getProfileKind()); // $NON-NLS-1$
      fProfileVersioner.update(profile);
      return profile.getSettings();
    }

    boolean hasValues = false;
    for (int i = 0; i < fKeySets.length; i++) {
      KeySet keySet = fKeySets[i];
      IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
      for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
        final String key = keyIter.next();
        String val = preferences.get(key, null);
        if (val != null) {
          hasValues = true;
        } else {
          val = workspaceProfile.getSettings().get(key);
        }
        profileOptions.put(key, val);
      }
    }

    if (!hasValues) {
      return null;
    }

    setLatestCompliance(profileOptions);
    return profileOptions;
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  private void setupOptions() {

    options = new HashMap(PHPCorePlugin.getOptions());

    IScopeContext[] contents =
        new IScopeContext[] {
          new ProjectScope(type.getScriptProject().getProject()),
          InstanceScope.INSTANCE,
          DefaultScope.INSTANCE
        };

    for (int i = 0; i < contents.length; i++) {

      IScopeContext scopeContext = contents[i];
      IEclipsePreferences inode = scopeContext.getNode(PHPCorePlugin.ID);

      if (inode != null) {

        if (!options.containsKey(PHPCoreConstants.FORMATTER_USE_TABS)) {

          String useTabs = inode.get(PHPCoreConstants.FORMATTER_USE_TABS, null);
          if (useTabs != null) {
            options.put(PHPCoreConstants.FORMATTER_USE_TABS, useTabs);
          }
        }

        if (!options.containsKey(PHPCoreConstants.FORMATTER_INDENTATION_SIZE)) {

          String size = inode.get(PHPCoreConstants.FORMATTER_INDENTATION_SIZE, null);

          if (size != null) {
            options.put(PHPCoreConstants.FORMATTER_INDENTATION_SIZE, size);
          }
        }
      }
    }
  }
 public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
   for (int i = 0; i < keySets.length; i++) {
     KeySet keySet = keySets[i];
     IEclipsePreferences preferences = context.getNode(keySet.getNodeName());
     for (final Iterator<String> keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
       final String key = keyIter.next();
       Object val = preferences.get(key, null);
       if (val != null) {
         return true;
       }
     }
   }
   return false;
 }
Example #25
0
  public static Preferences getPreferences() {
    @SuppressWarnings("deprecation")
    final IScopeContext scope = new InstanceScope();

    return scope.getNode(PLUGIN_ID);
  }
Example #26
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang
  * .String)
  */
 public IEclipsePreferences getNode(String qualifier) {
   return fWorkingCopyManager.getWorkingCopy(fOriginal.getNode(qualifier));
 }
Example #27
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
  */
 public IPath getLocation() {
   return fOriginal.getLocation();
 }
  /**
   * Create and initialize a new profile manager.
   *
   * @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
   * @param profileVersioner
   */
  public ProfileManager(
      List<Profile> profiles,
      IScopeContext context,
      PreferencesAccess preferencesAccess,
      IProfileVersioner profileVersioner,
      KeySet[] keySets,
      String profileKey,
      String profileVersionKey) {

    fPreferencesAccess = preferencesAccess;
    fProfileVersioner = profileVersioner;
    fKeySets = keySets;
    fProfileKey = profileKey;
    fProfileVersionKey = profileVersionKey;

    fProfiles = new HashMap<String, Profile>();
    fProfilesByName = new ArrayList<Profile>();

    for (final Iterator<Profile> iter = profiles.iterator(); iter.hasNext(); ) {
      final Profile profile = iter.next();
      if (profile instanceof CustomProfile) {
        ((CustomProfile) profile).setManager(this);
      }
      fProfiles.put(profile.getID(), profile);
      fProfilesByName.add(profile);
    }

    Collections.sort(fProfilesByName);

    String profileId = getSelectedProfileId(fPreferencesAccess.getInstanceScope());

    Profile profile = fProfiles.get(profileId);
    if (profile == null) {
      profile = getDefaultProfile();
    }
    fSelected = profile;

    if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
      Map<String, String> map = readFromPreferenceStore(context, profile);
      if (map != null) {

        List<String> allKeys = new ArrayList<String>();
        for (int i = 0; i < fKeySets.length; i++) {
          allKeys.addAll(fKeySets[i].getKeys());
        }
        Collections.sort(allKeys);

        Profile matching = null;

        String projProfileId = context.getNode(JavaUI.ID_PLUGIN).get(fProfileKey, null);
        if (projProfileId != null) {
          Profile curr = fProfiles.get(projProfileId);
          if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
            matching = curr;
          }
        } else {
          // old version: look for similar
          for (final Iterator<Profile> iter = fProfilesByName.iterator(); iter.hasNext(); ) {
            Profile curr = iter.next();
            if (curr.hasEqualSettings(map, allKeys)) {
              matching = curr;
              break;
            }
          }
        }
        if (matching == null) {
          String name;
          if (projProfileId != null && !fProfiles.containsKey(projProfileId)) {
            name =
                Messages.format(
                    FormatterMessages.ProfileManager_unmanaged_profile_with_name,
                    projProfileId.substring(ID_PREFIX.length()));
          } else {
            name = FormatterMessages.ProfileManager_unmanaged_profile;
          }
          // current settings do not correspond to any profile -> create a 'team' profile
          SharedProfile shared =
              new SharedProfile(
                  name,
                  map,
                  fProfileVersioner.getCurrentVersion(),
                  fProfileVersioner.getProfileKind());
          shared.setManager(this);
          fProfiles.put(shared.getID(), shared);
          fProfilesByName.add(shared); // add last
          matching = shared;
        }
        fSelected = matching;
      }
    }
  }
Example #29
0
 public static IEclipsePreferences getNode() {
   final IScopeContext context = InstanceScope.INSTANCE;
   final IEclipsePreferences eclipsePreferences = context.getNode(QUALIFIER);
   return eclipsePreferences;
 }
Example #30
0
 public static IEclipsePreferences getPrefsNode() {
   final String qualifier = ErlideUIPlugin.PLUGIN_ID;
   final IScopeContext context = new InstanceScope();
   final IEclipsePreferences eclipsePreferences = context.getNode(qualifier);
   return eclipsePreferences;
 }