use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.
the class JavaProject method setOption.
@Override
public void setOption(String optionName, String optionValue) {
// Store option value
IEclipsePreferences projectPreferences = getEclipsePreferences();
boolean modified = getJavaModelManager().storePreference(optionName, optionValue, projectPreferences, null);
// Write changes
if (modified) {
try {
projectPreferences.flush();
} catch (BackingStoreException e) {
// problem with pref store - quietly ignore
}
}
getJavaModelManager().resetProjectOptions(JavaProject.this);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568
JavaProject.this.resetCaches();
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project che by eclipse.
the class JavaProject method getOptions.
public Map getOptions(boolean inheritJavaCoreOptions) {
// initialize to the defaults from JavaCore options pool
Map options = inheritJavaCoreOptions ? JavaCore.getOptions() : new Hashtable(5);
// Get project specific options
PerProjectInfo perProjectInfo = null;
Hashtable projectOptions = null;
JavaModelManager javaModelManager = getJavaModelManager();
HashSet optionNames = javaModelManager.optionNames;
try {
perProjectInfo = getPerProjectInfo();
projectOptions = perProjectInfo.options;
if (projectOptions == null) {
// get eclipse preferences
IEclipsePreferences projectPreferences = getEclipsePreferences();
// cannot do better (non-Java project)
if (projectPreferences == null)
return options;
// create project options
String[] propertyNames = projectPreferences.keys();
projectOptions = new Hashtable(propertyNames.length);
for (int i = 0; i < propertyNames.length; i++) {
String propertyName = propertyNames[i];
String value = projectPreferences.get(propertyName, null);
if (value != null) {
value = value.trim();
// Keep the option value, even if it's deprecated
// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=324987
projectOptions.put(propertyName, value);
if (!optionNames.contains(propertyName)) {
// try to migrate deprecated options
String[] compatibleOptions = (String[]) javaModelManager.deprecatedOptions.get(propertyName);
if (compatibleOptions != null) {
for (int co = 0, length = compatibleOptions.length; co < length; co++) {
String compatibleOption = compatibleOptions[co];
if (!projectOptions.containsKey(compatibleOption))
projectOptions.put(compatibleOption, value);
}
}
}
}
}
// cache project options
perProjectInfo.options = projectOptions;
}
} catch (JavaModelException jme) {
projectOptions = new Hashtable();
} catch (BackingStoreException e) {
projectOptions = new Hashtable();
}
// Inherit from JavaCore options if specified
if (inheritJavaCoreOptions) {
Iterator propertyNames = projectOptions.entrySet().iterator();
while (propertyNames.hasNext()) {
Map.Entry entry = (Map.Entry) propertyNames.next();
String propertyName = (String) entry.getKey();
String propertyValue = (String) entry.getValue();
if (propertyValue != null && javaModelManager.knowsOption(propertyName)) {
options.put(propertyName, propertyValue.trim());
}
}
Util.fixTaskTags(options);
return options;
}
Util.fixTaskTags(projectOptions);
return projectOptions;
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class PersistUtils method saveXMLMemento.
/**
*
* Save the xml content to instance scope preference
*
* @param pluginId String
* @param key String
* @param memento XMLMemento
*/
public static void saveXMLMemento(String pluginId, String key, XMLMemento memento) {
String xmlString = null;
try {
xmlString = memento.saveToString();
} catch (IOException e1) {
e1.printStackTrace();
}
IEclipsePreferences preference = PersistUtils.getPreference(pluginId);
try {
preference.put(key, xmlString);
preference.flush();
} catch (BackingStoreException e) {
preference = null;
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class NodeFilterManager method loadFilterSetting.
@SuppressWarnings("deprecation")
private void loadFilterSetting() {
synchronized (this) {
IEclipsePreferences preference = new InstanceScope().getNode(CommonUIPlugin.PLUGIN_ID);
String xmlString = preference.get(FILTER_XML_CONTENT, "");
if (StringUtil.isEmpty(xmlString)) {
LOGGER.warn("The preference.get(FILTER_XML_CONTENT) has a empty string.");
return;
}
try {
ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
IXMLMemento memento = XMLMemento.loadMemento(in);
if (memento == null) {
LOGGER.error("XMLMemento.loadMemento(in) is a null.");
return;
}
IXMLMemento[] children = memento.getChildren("idFilter");
for (int i = 0; i < children.length; i++) {
String id = children[i].getString("id");
idFilterList.add(id);
}
children = memento.getChildren("idGrayFilter");
for (int i = 0; i < children.length; i++) {
String id = children[i].getString("id");
idGrayFilterList.add(id);
}
children = memento.getChildren("nameFilter");
for (int i = 0; i < children.length; i++) {
String pattern = children[i].getString("pattern");
nameFilterList.add(pattern);
}
} catch (UnsupportedEncodingException e) {
LOGGER.error("loadFilterSetting()", e);
}
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class CubridStatusMonitorInstance method removeSetting.
/**
* Remove the info of StatusMonInstanceData relevant to key from preference
*
* @param key the key relevant to saving instance of StatusMonInstanceData
*/
public void removeSetting(String key) {
synchronized (this) {
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
preference.remove(key);
try {
preference.flush();
} catch (BackingStoreException ex) {
LOGGER.error(ex.getMessage());
}
}
}
Aggregations