use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class BrokerIntervalSettingManager method saveBrokerIntervals.
/**
*
* Save broker interval to plugin preference
*
*/
public void saveBrokerIntervals() {
synchronized (this) {
if (!initialized) {
init();
}
try {
XMLMemento memento = XMLMemento.createWriteRoot("BrokerIntervalSettings");
Iterator<BrokerIntervalSetting> iterator = brokerIntervalSettingList.iterator();
while (iterator.hasNext()) {
BrokerIntervalSetting brokerInterval = (BrokerIntervalSetting) iterator.next();
IXMLMemento child = memento.createChild("BrokerIntervalSetting");
child.putString("serverName", brokerInterval.getServerName());
child.putString("brokerName", brokerInterval.getBrokerName());
child.putString("isOn", brokerInterval.isOn() ? "true" : "false");
child.putString("interval", brokerInterval.getInterval());
}
String xmlString = memento.saveToString();
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
preference.put(CUBRID_BROKER_INTERVAL_XML_CONTENT, xmlString);
preference.flush();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project cubrid-manager by CUBRID.
the class CubridStatusMonitorInstance method saveSetting.
/**
* Save the info of StatusMonInstanceData relevant to key into preference
*
* @param key the key relevant to saving instance of StatusMonInstanceData
*/
public void saveSetting(String key) {
synchronized (this) {
StatusMonInstanceData data = map.get(key);
ObjectOutputStream objectOutputStream;
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
try {
objectOutputStream = new ObjectOutputStream(byteStream);
objectOutputStream.writeObject(data);
objectOutputStream.close();
byte[] bytes = byteStream.toByteArray();
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
preference.putByteArray(key, bytes);
preference.flush();
} catch (Exception ex) {
LOGGER.error(ex.getMessage());
}
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project sling by apache.
the class ProjectUtil method getSyncDirectoryValue.
/**
* Returns the value of the sync directory configured for a project.
*
* <p>
* The value is returned as a relative path to the project's location. If the property value is not set, it defaults
* to {@value #PROPERTY_SYNC_ROOT_DEFAULT_VALUE}.
* </p>
*
* @param project the project, must not be null
* @return the value of the sync directory
*/
public static IPath getSyncDirectoryValue(IProject project) {
// for compatibility reasons, read the old value first
String oldValue = null;
try {
oldValue = project.getPersistentProperty(PROPERTY_SYNC_ROOT_OLD);
} catch (CoreException e) {
Activator.getDefault().getPluginLogger().trace("Failed retrieving old values for content sync root for project " + project.getName(), e);
}
// read a value from the new store, returning a default if none is found
IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
if (projectNode == null) {
String value;
// try to read from old values
if (oldValue != null) {
value = oldValue;
} else {
value = PROPERTY_SYNC_ROOT_DEFAULT_VALUE;
}
return Path.fromOSString(value);
}
// if no new value if found and an old value exists, use the old value and save it in the new store
String value = projectNode.get(PROPERTY_SYNC_ROOT, null);
if (value == null && oldValue != null) {
value = oldValue;
setSyncDirectoryPath(project, Path.fromPortableString(value));
}
// it is now safe to delete the value from the old store
if (oldValue != null) {
try {
project.setPersistentProperty(PROPERTY_SYNC_ROOT_OLD, null);
} catch (CoreException e) {
Activator.getDefault().getPluginLogger().error(e.getMessage(), e);
}
}
// TODO central place for defaults
if (value == null) {
return Path.fromOSString(PROPERTY_SYNC_ROOT_DEFAULT_VALUE);
} else {
return Path.fromPortableString(value);
}
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project sling by apache.
the class ProjectUtil method getProvisioningModelPath.
public static IPath getProvisioningModelPath(IProject project) {
if (project == null || !project.isOpen() || !ProjectHelper.isLaunchpadProject(project)) {
return null;
}
IScopeContext projectScope = new ProjectScope(project);
IEclipsePreferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
if (projectNode == null) {
return null;
}
String propertyValue = projectNode.get(PROPERTY_PROVISIONING_MODEL_DIR, null);
if (propertyValue == null) {
return null;
}
return Path.fromPortableString(propertyValue);
}
use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project eclipse.platform.text by eclipse.
the class DefaultEncodingSupport method initialize.
/**
* Associates this encoding support to the given text editor and initializes this encoding.
*
* @param textEditor the editor
*/
public void initialize(StatusTextEditor textEditor) {
fTextEditor = textEditor;
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
fPreferenceChangeListener = new IPreferenceChangeListener() {
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (ResourcesPlugin.PREF_ENCODING.equals(event.getKey())) {
Runnable runnable = new Runnable() {
@Override
public void run() {
// null means: use default
setEncoding(null, false);
}
};
if (Display.getCurrent() != null)
runnable.run();
else {
// Post runnable into UI thread
Shell shell;
if (fTextEditor != null)
shell = fTextEditor.getSite().getShell();
else
shell = getActiveWorkbenchShell();
Display display;
if (shell != null)
display = shell.getDisplay();
else
display = Display.getDefault();
display.asyncExec(runnable);
}
}
}
};
prefs.addPreferenceChangeListener(fPreferenceChangeListener);
}
Aggregations