use of org.osgi.service.prefs.Preferences in project eclipse.platform.runtime by eclipse.
the class EclipsePreferencesTest method testName.
public void testName() {
Preferences node = Platform.getPreferencesService().getRootNode();
assertEquals("1.0", "", node.name());
node = node.node(TestScope.SCOPE);
assertEquals("2.0", TestScope.SCOPE, node.name());
node = node.node("foo");
assertEquals("3.0", "foo", node.name());
}
use of org.osgi.service.prefs.Preferences in project eclipse.platform.runtime by eclipse.
the class EclipsePreferencesTest method tearDown.
@Override
protected void tearDown() throws Exception {
Preferences node = getScopeRoot();
node.removeNode();
}
use of org.osgi.service.prefs.Preferences in project eclipse.platform.runtime by eclipse.
the class ContentType method addFileSpec.
@Override
public void addFileSpec(String fileSpec, int type) throws CoreException {
Assert.isLegal(type == FILE_EXTENSION_SPEC || type == FILE_NAME_SPEC || type == FILE_PATTERN_SPEC, // $NON-NLS-1$
"Unknown type: " + type);
String[] userSet;
synchronized (this) {
if (!internalAddFileSpec(fileSpec, type | SPEC_USER_DEFINED))
return;
userSet = getFileSpecs(type | IGNORE_PRE_DEFINED);
}
// persist using preferences
Preferences contentTypeNode = manager.getPreferences().node(id);
String newValue = Util.toListString(userSet);
// we are adding stuff, newValue must be non-null
Assert.isNotNull(newValue);
setPreference(contentTypeNode, getPreferenceKey(type), newValue);
try {
contentTypeNode.flush();
} catch (BackingStoreException bse) {
String message = NLS.bind(ContentMessages.content_errorSavingSettings, id);
IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
throw new CoreException(status);
}
// notify listeners
manager.fireContentTypeChangeEvent(this);
}
use of org.osgi.service.prefs.Preferences in project eclipse.platform.runtime by eclipse.
the class ContentType method setDefaultCharset.
@Override
public void setDefaultCharset(String newCharset) throws CoreException {
synchronized (this) {
// don't do anything if there is no actual change
if (userCharset == null) {
if (newCharset == null)
return;
} else if (userCharset.equals(newCharset))
return;
// apply change in memory
userCharset = newCharset;
}
// persist the change
Preferences contentTypeNode = manager.getPreferences().node(id);
setPreference(contentTypeNode, PREF_DEFAULT_CHARSET, userCharset);
try {
contentTypeNode.flush();
} catch (BackingStoreException bse) {
String message = NLS.bind(ContentMessages.content_errorSavingSettings, id);
IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
throw new CoreException(status);
}
// notify listeners
manager.fireContentTypeChangeEvent(this);
}
use of org.osgi.service.prefs.Preferences in project eclipse.platform.runtime by eclipse.
the class ContentType method removeFileSpec.
@Override
public void removeFileSpec(String fileSpec, int type) throws CoreException {
Assert.isLegal(type == FILE_EXTENSION_SPEC || type == FILE_NAME_SPEC || type == FILE_PATTERN_SPEC, // $NON-NLS-1$
"Unknown type: " + type);
synchronized (this) {
if (!internalRemoveFileSpec(fileSpec, type | SPEC_USER_DEFINED))
return;
}
// persist the change
Preferences contentTypeNode = manager.getPreferences().node(id);
final String[] userSet = getFileSpecs(type | IGNORE_PRE_DEFINED);
String preferenceKey = getPreferenceKey(type);
String newValue = Util.toListString(userSet);
setPreference(contentTypeNode, preferenceKey, newValue);
try {
contentTypeNode.flush();
} catch (BackingStoreException bse) {
String message = NLS.bind(ContentMessages.content_errorSavingSettings, id);
IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
throw new CoreException(status);
}
// notify listeners
manager.fireContentTypeChangeEvent(this);
}
Aggregations