use of org.osgi.service.prefs.Preferences in project jop by jop-devel.
the class JOPPropertyPage method performDefaults.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performDefaults()
*/
@Override
public void performDefaults() {
super.performDefaults();
IProject project = getProject();
IPath projectRoot = project.getLocation();
IScopeContext scopeContext = new ProjectScope(project);
Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
jopDirectoryEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME, projectRoot.toOSString()));
IPath defaultQuartusProjectFile = projectRoot.append("quartus").append("cycmin").append("jop").addFileExtension("qpf");
quartusProjectFileEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_QUARTUS_PROJECT, defaultQuartusProjectFile.toOSString()));
}
use of org.osgi.service.prefs.Preferences in project snow-owl by b2ihealthcare.
the class EclipsePreferencesTest method testFlushDeadlock.
@Test(timeout = 5000L)
public void testFlushDeadlock() {
final IEclipsePreferences parent = InstanceScope.INSTANCE.getNode(RUNTIME_TESTS);
final Preferences child = parent.node("testFlushDeadlock");
class FlushJob extends Job {
private final Preferences node;
FlushJob(final Preferences node) {
super("testFlushDeadlock");
this.node = node;
}
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
node.flush();
} catch (final BackingStoreException e) {
return new Status(IStatus.ERROR, RUNTIME_TESTS, "unexpected flush failure", e);
}
return Status.OK_STATUS;
}
}
// make sure node is dirty
child.putBoolean("testFlushDeadlock", true);
// flush the parent of the load level, and the child
final Job flushParent = new FlushJob(parent);
final Job flushChild = new FlushJob(child);
flushParent.schedule();
flushChild.schedule();
try {
flushParent.join();
flushChild.join();
} catch (final InterruptedException e) {
throw new RuntimeException("Interrupted while updating preferences store.", e);
}
}
use of org.osgi.service.prefs.Preferences in project hale by halestudio.
the class ContentTypeSettings method removeFileSpec.
static void removeFileSpec(IScopeContext context, String contentTypeId, String fileSpec, int type) throws CoreException {
Preferences contentTypeNode = ContentTypeManager.getInstance().getPreferences(context).node(contentTypeId);
String key = ContentType.getPreferenceKey(type);
String existing = contentTypeNode.get(key, null);
if (existing == null)
// content type has no settings - nothing to do
return;
List existingValues = Util.parseItemsIntoList(contentTypeNode.get(key, null));
int index = -1;
int existingCount = existingValues.size();
for (int i = 0; index == -1 && i < existingCount; i++) if (((String) existingValues.get(i)).equalsIgnoreCase(fileSpec))
index = i;
if (index == -1)
// did not find the file spec to be removed - nothing to do
return;
existingValues.remove(index);
// set new preference value
String newValue = Util.toListString(existingValues.toArray());
ContentType.setPreference(contentTypeNode, key, newValue);
try {
contentTypeNode.flush();
} catch (BackingStoreException bse) {
String message = NLS.bind(ContentMessages.content_errorSavingSettings, contentTypeId);
IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
throw new CoreException(status);
}
}
use of org.osgi.service.prefs.Preferences in project hale by halestudio.
the class ContentTypeSettings method addFileSpec.
@SuppressWarnings("unchecked")
static void addFileSpec(IScopeContext context, String contentTypeId, String fileSpec, int type) throws CoreException {
Preferences contentTypeNode = ContentTypeManager.getInstance().getPreferences(context).node(contentTypeId);
String key = ContentType.getPreferenceKey(type);
List existingValues = Util.parseItemsIntoList(contentTypeNode.get(key, null));
for (int i = 0; i < existingValues.size(); i++) if (((String) existingValues.get(i)).equalsIgnoreCase(fileSpec))
// don't do anything if already exists
return;
existingValues.add(fileSpec);
// set new preference value
String newValue = Util.toListString(existingValues.toArray());
ContentType.setPreference(contentTypeNode, key, newValue);
try {
contentTypeNode.flush();
} catch (BackingStoreException bse) {
String message = NLS.bind(ContentMessages.content_errorSavingSettings, contentTypeId);
IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, bse);
throw new CoreException(status);
}
}
use of org.osgi.service.prefs.Preferences in project hale by halestudio.
the class ContentTypeSettings method internalGetDefaultProperty.
public static String internalGetDefaultProperty(ContentType current, final Preferences contentTypePrefs, final QualifiedName key) throws BackingStoreException {
String id = current.getId();
if (contentTypePrefs.nodeExists(id)) {
Preferences contentTypeNode = contentTypePrefs.node(id);
String propertyValue = contentTypeNode.get(key.getLocalName(), null);
if (propertyValue != null)
return propertyValue;
}
// try built-in settings
String propertyValue = current.basicGetDefaultProperty(key);
if (propertyValue != null)
return propertyValue;
// try ancestor
ContentType baseType = (ContentType) current.getBaseType();
return baseType == null ? null : internalGetDefaultProperty(baseType, contentTypePrefs, key);
}
Aggregations