use of org.osgi.service.prefs.Preferences in project n4js by eclipse.
the class WorkingSetManagerBrokerImpl method saveState.
private IStatus saveState() {
final Preferences node = getPreferences();
// Top level element.
node.putBoolean(IS_WORKINGSET_TOP_LEVEL_KEY, workingSetTopLevel.get());
// Active working set manager.
final WorkingSetManager activeManager = getActiveManager();
final String activeId = activeManager == null ? null : activeManager.getId();
node.put(ACTIVE_MANAGER_KEY, Strings.nullToEmpty(activeId));
try {
node.flush();
return OK_STATUS;
} catch (final BackingStoreException e) {
final String message = "Unexpected error when trying to persist working set broker state.";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
}
use of org.osgi.service.prefs.Preferences in project liferay-ide by liferay.
the class NewPortletClassOperation method execute.
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
String defaultSuperclasses = INewPortletClassDataModelProperties.QUALIFIED_MVC_PORTLET + StringPool.COMMA + INewPortletClassDataModelProperties.QUALIFIED_LIFERAY_PORTLET + StringPool.COMMA + INewPortletClassDataModelProperties.QUALIFIED_GENERIC_PORTLET;
try {
Preferences preferences = PortletCore.getPreferences();
String superclasses = preferences.get(PortletCore.PREF_KEY_PORTLET_SUPERCLASSES_USED, null);
String superclass = getDataModel().getStringProperty(INewJavaClassDataModelProperties.SUPERCLASS);
if (!defaultSuperclasses.contains(superclass)) {
String newSuperclasses = null;
if (superclasses == null) {
newSuperclasses = superclass;
} else if (!superclasses.contains(superclass)) {
newSuperclasses = superclasses + StringPool.COMMA + superclass;
}
if (newSuperclasses != null) {
preferences.put(PortletCore.PREF_KEY_PORTLET_SUPERCLASSES_USED, newSuperclasses);
preferences.flush();
}
}
} catch (BackingStoreException bse) {
PortletCore.logError(bse);
}
return super.execute(monitor, info);
}
use of org.osgi.service.prefs.Preferences in project arduino-eclipse-plugin by Sloeber.
the class Shared method applyKnownWorkArounds.
/*
* For some boards that do not run out of the box we know how to fix it. This
* code fixes these things
*/
public static void applyKnownWorkArounds() {
/*
* for chipkit PONTECH UAV100 board boards.txt contains
* usbono_pic32.compiler.c.extra_flags=-G1024 -Danything=1 and platform.txt
* contains ... {compiler.define} "{compiler.cpp.extra_flags}"
* {build.extra_flags} ... resulting in ... "-G1024 -Danything=1" ... Arduino
* IDE magically makes this ... "-G1024" -Danything=1 ... But I refuse to do
* this type of smart parsing because modifying text files is lots easier
* therefore as a workaround I replace "{compiler.cpp.extra_flags}" in
* platform.txt with {compiler.cpp.extra_flags}
*/
java.nio.file.Path packageRoot = Paths.get(ConfigurationPreferences.getInstallationPathPackages().toOSString());
java.nio.file.Path platform_txt = packageRoot.resolve("chipKIT").resolve("hardware").resolve("pic32").resolve("2.0.1").resolve("platform.txt");
if (platform_txt.toFile().exists()) {
FileModifiers.replaceInFile(platform_txt.toFile(), false, "\"{compiler.cpp.extra_flags}\"", "{compiler.cpp.extra_flags}");
}
/*
* oak on windows does not come with all required libraries and assumes arduino
* IDE has them available So I set sloeber_path_extension to the teensy root
*
*/
if (SystemUtils.IS_OS_WINDOWS) {
java.nio.file.Path arduinoIDERoot = Paths.get(MySystem.getTeensyPlatform());
if (arduinoIDERoot.toFile().exists()) {
try {
// /cater for null pointer
arduinoIDERoot = arduinoIDERoot.getParent().getParent();
IEnvironmentVariable var = new EnvironmentVariable("sloeber_path_extension", arduinoIDERoot.toString());
IEclipsePreferences myScope = InstanceScope.INSTANCE.getNode("org.eclipse.cdt.core");
Preferences t = myScope.node("environment").node("workspace").node(var.getName().toUpperCase());
t.put("delimiter", var.getDelimiter());
t.put("operation", "append");
t.put("value", var.getValue());
myScope.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/*
* oak on linux comes with a esptool2 in a wrong folder.
* As it is only 1 file I move the file
*
*/
if (SystemUtils.IS_OS_LINUX) {
java.nio.file.Path esptool2root = packageRoot.resolve("digistump").resolve("tools").resolve("esptool2").resolve("0.9.1");
java.nio.file.Path esptool2wrong = esptool2root.resolve("0.9.1").resolve("esptool2");
java.nio.file.Path esptool2right = esptool2root.resolve("esptool2");
if (esptool2wrong.toFile().exists()) {
try {
Files.move(esptool2wrong, esptool2right);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/*
* Elector heeft core Platino maar de directory noemt platino.
* In windows geen probleem maar in case sensitive linux dus wel
*/
if (SystemUtils.IS_OS_LINUX) {
java.nio.file.Path cores = packageRoot.resolve("Elektor").resolve("hardware").resolve("avr").resolve("1.0.0").resolve("cores");
java.nio.file.Path coreWrong = cores.resolve("platino");
java.nio.file.Path coreGood = cores.resolve("Platino");
if (coreWrong.toFile().exists()) {
coreWrong.toFile().renameTo(coreGood.toFile());
}
}
}
use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.
the class AccountModel method save.
@Override
public void save() {
clusters.forEach(ICluster::save);
Preferences accountRoot = getAccountsPreferences();
ISecurePreferences accountSecureRoot = getSecureAccountsPreferences();
removed.forEach(id -> {
removeAccount(id, accountRoot, accountSecureRoot);
});
removed.clear();
}
use of org.osgi.service.prefs.Preferences in project jbosstools-openshift by jbosstools.
the class AccountModel method loadModel.
private void loadModel() {
ISecurePreferences secureAccountRoot = getSecureAccountsPreferences();
Preferences accountsRoot = getAccountsPreferences();
try {
String[] ids = accountsRoot.childrenNames();
for (String id : ids) {
Cluster cluster = new Cluster(this, id);
Preferences clusterNode = accountsRoot.node(id);
ISecurePreferences secureClusterNode = secureAccountRoot.node(id);
addCluster(cluster, clusterNode, secureClusterNode);
}
} catch (BackingStoreException e) {
OpenShiftIOCoreActivator.logError(e.getLocalizedMessage(), e);
}
if (clusters.isEmpty()) {
addCluster(createCluster("OpenShift.io"));
}
}
Aggregations