use of java.util.prefs.BackingStoreException in project jabref by JabRef.
the class PreferencesMigrations method upgradePrefsToOrgJabRef.
/**
* Migrate all preferences from net/sf/jabref to org/jabref
*/
public static void upgradePrefsToOrgJabRef() {
JabRefPreferences prefs = Globals.prefs;
Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class);
try {
if (mainPrefsNode.childrenNames().length != 0) {
// skip further processing as prefs already have been migrated
LOGGER.debug("New prefs node already exists with content - skipping migration");
} else {
if (mainPrefsNode.parent().parent().nodeExists("net/sf/jabref")) {
LOGGER.info("Migrating old preferences.");
Preferences oldNode = mainPrefsNode.parent().parent().node("net/sf/jabref");
copyPrefsRecursively(oldNode, mainPrefsNode);
}
}
} catch (BackingStoreException ex) {
LOGGER.error("Migrating old preferences failed.", ex);
}
}
use of java.util.prefs.BackingStoreException in project jabref by JabRef.
the class JabRefPreferences method loadCustomEntryTypes.
public List<CustomEntryType> loadCustomEntryTypes(BibDatabaseMode bibDatabaseMode) {
List<CustomEntryType> storedEntryTypes = new ArrayList<>();
Preferences prefsNode = getPrefsNodeForCustomizedEntryTypes(bibDatabaseMode);
try {
Arrays.stream(prefsNode.keys()).map(key -> prefsNode.get(key, null)).filter(Objects::nonNull).forEach(typeString -> CustomEntryType.parse(typeString).ifPresent(storedEntryTypes::add));
} catch (BackingStoreException e) {
LOGGER.info("Parsing customized entry types failed.", e);
}
return storedEntryTypes;
}
use of java.util.prefs.BackingStoreException in project jabref by JabRef.
the class JabRefPreferences method storeCustomEntryTypes.
public void storeCustomEntryTypes(List<CustomEntryType> customEntryTypes, BibDatabaseMode bibDatabaseMode) {
Preferences prefsNode = getPrefsNodeForCustomizedEntryTypes(bibDatabaseMode);
try {
// clear old custom types
clearCustomEntryTypes(bibDatabaseMode);
// store current custom types
customEntryTypes.forEach(type -> prefsNode.put(type.getName(), type.getAsString()));
prefsNode.flush();
} catch (BackingStoreException e) {
LOGGER.info("Updating stored custom entry types failed.", e);
}
}
use of java.util.prefs.BackingStoreException in project JMRI by JMRI.
the class SystemConsolePreferencesManager method savePreferences.
@Override
public void savePreferences(Profile profile) {
Preferences preferences = ProfileUtils.getPreferences(profile, this.getClass(), true);
preferences.put(FONT_FAMILY, this.getFontFamily());
preferences.putInt(FONT_SIZE, this.getFontSize());
preferences.putInt(FONT_STYLE, this.getFontStyle());
preferences.putInt(SCHEME, this.getScheme());
preferences.putInt(WRAP_STYLE, this.getWrapStyle());
try {
preferences.sync();
} catch (BackingStoreException ex) {
log.error("Unable to save preferences.", ex);
}
}
use of java.util.prefs.BackingStoreException in project JMRI by JMRI.
the class ManagerDefaultSelector method savePreferences.
@Override
public void savePreferences(Profile profile) {
// NOI18N
Preferences settings = ProfileUtils.getPreferences(profile, this.getClass(), true).node("defaults");
try {
this.defaults.keySet().stream().forEach((cls) -> {
settings.put(this.nameForClass(cls), this.defaults.get(cls));
});
settings.sync();
} catch (BackingStoreException ex) {
log.error("Unable to save preferences for Default Selector.", ex);
}
}
Aggregations