use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.
the class PreferenceInitializer method initializeDefaultPreferences.
/* (non-Javadoc)
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
@Override
public void initializeDefaultPreferences() {
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
// auto-refresh default
node.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, PREF_AUTO_REFRESH_DEFAULT);
node.putBoolean(ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, PREF_LIGHTWEIGHT_AUTO_REFRESH_DEFAULT);
// linked resources default
node.putBoolean(ResourcesPlugin.PREF_DISABLE_LINKING, PREF_DISABLE_LINKING_DEFAULT);
// build manager defaults
node.putBoolean(ResourcesPlugin.PREF_AUTO_BUILDING, PREF_AUTO_BUILDING_DEFAULT);
node.put(ResourcesPlugin.PREF_BUILD_ORDER, PREF_BUILD_ORDER_DEFAULT);
node.putInt(ResourcesPlugin.PREF_MAX_BUILD_ITERATIONS, PREF_MAX_BUILD_ITERATIONS_DEFAULT);
node.putBoolean(ResourcesPlugin.PREF_DEFAULT_BUILD_ORDER, PREF_DEFAULT_BUILD_ORDER_DEFAULT);
// history store defaults
node.putBoolean(ResourcesPlugin.PREF_APPLY_FILE_STATE_POLICY, PREF_APPLY_FILE_STATE_POLICY_DEFAULT);
node.putLong(ResourcesPlugin.PREF_FILE_STATE_LONGEVITY, PREF_FILE_STATE_LONGEVITY_DEFAULT);
node.putLong(ResourcesPlugin.PREF_MAX_FILE_STATE_SIZE, PREF_MAX_FILE_STATE_SIZE_DEFAULT);
node.putInt(ResourcesPlugin.PREF_MAX_FILE_STATES, PREF_MAX_FILE_STATES_DEFAULT);
// save manager defaults
node.putLong(ResourcesPlugin.PREF_SNAPSHOT_INTERVAL, PREF_SNAPSHOT_INTERVAL_DEFAULT);
node.putInt(PREF_OPERATIONS_PER_SNAPSHOT, PREF_OPERATIONS_PER_SNAPSHOT_DEFAULT);
node.putLong(PREF_DELTA_EXPIRATION, PREF_DELTA_EXPIRATION_DEFAULT);
// encoding defaults
node.put(ResourcesPlugin.PREF_ENCODING, PREF_ENCODING_DEFAULT);
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.
the class JavaProject method setOptions.
@Override
public void setOptions(Map newOptions) {
IEclipsePreferences projectPreferences = getEclipsePreferences();
if (projectPreferences == null)
return;
try {
if (newOptions == null) {
projectPreferences.clear();
} else {
Iterator entries = newOptions.entrySet().iterator();
JavaModelManager javaModelManager = getJavaModelManager();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
javaModelManager.storePreference(key, value, projectPreferences, newOptions);
}
// reset to default all options not in new map
// @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=26255
// @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49691
String[] pNames = projectPreferences.keys();
int ln = pNames.length;
for (int i = 0; i < ln; i++) {
String key = pNames[i];
if (!newOptions.containsKey(key)) {
// old preferences => remove from preferences table
projectPreferences.remove(key);
}
}
}
// persist options
projectPreferences.flush();
// flush cache immediately
try {
getPerProjectInfo().options = null;
} catch (JavaModelException e) {
// do nothing
}
} catch (BackingStoreException e) {
// problem with pref store - quietly ignore
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class PersistUtils method setGlobalPreferenceValue.
/**
* Save value to global preference of configuration scope
*
* @param pluginId String
* @param key the key
* @param value the value
*/
public static void setGlobalPreferenceValue(String pluginId, String key, String value) {
IEclipsePreferences prefs = getGlobalPreference(pluginId);
prefs.put(key, value);
try {
prefs.flush();
} catch (BackingStoreException e) {
prefs = null;
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class PersistUtils method setPreferenceValue.
/**
* Save value to plugin preference of instance scope
*
* @param pluginId String
* @param key the key
* @param value the value
*/
public static void setPreferenceValue(String pluginId, String key, String value) {
IEclipsePreferences prefs = getPreference(pluginId);
prefs.put(key, value);
try {
prefs.flush();
} catch (BackingStoreException e) {
prefs = null;
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class PersistUtils method getXMLMemento.
/**
* Get the node XML memento from instance scope preference
*
* @param pluginId String
* @param key String
* @return IXMLMemento
*/
public static IXMLMemento getXMLMemento(String pluginId, String key) {
IEclipsePreferences preference = getPreference(pluginId);
String xmlString = preference.get(key, "");
if (xmlString == null || xmlString.length() == 0) {
return null;
}
try {
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
return XMLMemento.loadMemento(in);
} catch (UnsupportedEncodingException e) {
return null;
}
}
Aggregations