use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.
the class AbstractProfileManager method readFromPreferenceStore.
/**
* Only to read project specific settings to find out to what profile it matches.
*
* @param context
* The project context
*/
private Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
final Map profileOptions = new HashMap();
IEclipsePreferences uiPrefs = context.getNode(getNodeId());
int version = uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
if (version != fProfileVersioner.getCurrentVersion()) {
Map allOptions = new HashMap();
for (int i = 0; i < fKeySets.length; i++) {
addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
}
// $NON-NLS-1$
CustomProfile profile = new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind());
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 keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
final String key = (String) keyIter.next();
Object 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;
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.
the class AbstractProfileManager method updateProfilesWithName.
@Override
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(getNodeId());
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(getNodeId());
if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
writeToPreferenceStore(newProfile, instanceScope);
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.
the class AbstractProfileManager method clearAllSettings.
@Override
public void clearAllSettings(IScopeContext context) {
for (int i = 0; i < fKeySets.length; i++) {
updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.EMPTY_MAP);
}
final IEclipsePreferences uiPrefs = context.getNode(getNodeId());
uiPrefs.remove(fProfileKey);
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project xtext-xtend by eclipse.
the class XtendProjectConfigurator method writePreferences.
private void writePreferences(OutputConfiguration configuration, IProject project) {
ProjectScope projectPreferences = new ProjectScope(project);
IEclipsePreferences languagePreferences = projectPreferences.getNode("org.eclipse.xtend.core.Xtend");
languagePreferences.putBoolean(OptionsConfigurationBlock.isProjectSpecificPropertyKey(BuilderConfigurationBlock.PROPERTY_PREFIX), true);
languagePreferences.putBoolean(getKey(configuration, INSTALL_DSL_AS_PRIMARY_SOURCE), configuration.isInstallDslAsPrimarySource());
languagePreferences.putBoolean(getKey(configuration, HIDE_LOCAL_SYNTHETIC_VARIABLES), configuration.isHideSyntheticLocalVariables());
languagePreferences.putBoolean(getKey(configuration, USE_OUTPUT_PER_SOURCE_FOLDER), true);
for (SourceMapping sourceMapping : configuration.getSourceMappings()) {
languagePreferences.put(getOutputForSourceFolderKey(configuration, sourceMapping.getSourceFolder()), Strings.nullToEmpty(sourceMapping.getOutputDirectory()));
}
try {
languagePreferences.flush();
} catch (BackingStoreException e) {
throw new RuntimeIOException(e);
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.
the class MetadataPageTest method isPreferencesCorrect.
/**
* Get the current project preference for the category tag and check if the values
* stored are the same as the values passed in.
*
* @param category The preference category to check.
* @param value The value to check.
* @return True if the value is same as what is stored, false otherwise.
*/
private boolean isPreferencesCorrect(String category, String value) {
IEclipsePreferences pref = project.getEclipsePreferences();
IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
String actual = pref.get(category, prefStore.getDefaultString(category));
return actual.equals(value);
}
Aggregations