use of org.osgi.service.prefs.Preferences in project webtools.sourceediting by eclipse.
the class ContentBasedPreferenceGateway method getDefaultPreferences.
private static Preferences getDefaultPreferences(IContentType contentType) {
IEclipsePreferences eclipsePreferences = Platform.getPreferencesService().getRootNode();
// TODO: eventaully need extension mechanism to avoid these hard coded
// mechanism.
// The idea is to load/store based on plugin's preferences, where the
// content type was contributed
// Eventually, too, we could do more "dynamic lookup" to get parent
// types for defaults, etc.
// Get default plugin preferences
String pluginPreferenceLocation = DefaultScope.SCOPE + IPath.SEPARATOR + getContributorPluginId(contentType);
Preferences pluginPreferences = eclipsePreferences.node(pluginPreferenceLocation);
return pluginPreferences;
}
use of org.osgi.service.prefs.Preferences in project webtools.sourceediting by eclipse.
the class ContentBasedPreferenceGateway method getPreferences.
public static Preferences getPreferences(IContentType contentType) {
IEclipsePreferences eclipsePreferences = Platform.getPreferencesService().getRootNode();
// TODO: eventaully need extension mechanism to avoid these hard coded
// mechanism.
// The idea is to load/store based on plugin's preferences, where the
// content type was contributed
// Eventually, too, we could do more "dynamic lookup" to get parent
// types for defaults, etc.
// Get instance plugin preferences
String pluginPreferenceLocation = Plugin.PLUGIN_PREFERENCE_SCOPE + IPath.SEPARATOR + getContributorPluginId(contentType);
Preferences pluginPreferences = eclipsePreferences.node(pluginPreferenceLocation);
// return contentPreferences;
return pluginPreferences;
}
use of org.osgi.service.prefs.Preferences in project webtools.sourceediting by eclipse.
the class TestPreferences method printChildren.
/**
* @param preferences
* @throws BackingStoreException
*/
private static void printChildren(Preferences preferences) throws BackingStoreException {
System.out.println("\t" + preferences.absolutePath());
String[] keys = preferences.keys();
printKeys(keys);
String[] children = preferences.childrenNames();
printChildren(children);
for (int i = 0; i < children.length; i++) {
String child = children[i];
Preferences subPreferences = preferences.node(child);
String[] subkeys = subPreferences.keys();
System.out.println();
System.out.println(child);
System.out.println();
printKeys(subkeys);
}
}
use of org.osgi.service.prefs.Preferences in project webtools.sourceediting by eclipse.
the class TestPreferences method testContentBasedPrefHTML.
public void testContentBasedPrefHTML() {
IContentType contentType = Platform.getContentTypeManager().findContentTypeFor("test.html");
Preferences preferences = ContentBasedPreferenceGateway.getPreferences(contentType);
assertNotNull(preferences);
}
use of org.osgi.service.prefs.Preferences in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPreferences method savePreferences.
/**
* Stores application insights resources list
* in preference file in the form of byte array.
*/
private void savePreferences() {
try {
Preferences prefs = PluginUtil.getPrefs(PREF_FILE);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput output = new ObjectOutputStream(buffer);
List<ApplicationInsightsResource> data = ApplicationInsightsResourceRegistry.getAppInsightsResrcList();
ApplicationInsightsResource[] dataArray = data.stream().filter(a -> !a.isImported()).sorted().toArray(ApplicationInsightsResource[]::new);
/*
* Sort list according to application insights resource name.
* Save only manually added resources
*/
try {
output.writeObject(dataArray);
} finally {
output.close();
}
prefs.putByteArray(PREF_KEY, buffer.toByteArray());
prefs.flush();
} catch (BackingStoreException e) {
Activator.getDefault().log(e.getMessage(), e);
} catch (IOException e) {
Activator.getDefault().log(e.getMessage(), e);
}
}
Aggregations