Search in sources :

Example 66 with BackingStoreException

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);
    }
}
Also used : JabRefPreferences(org.jabref.preferences.JabRefPreferences) BackingStoreException(java.util.prefs.BackingStoreException) JabRefPreferences(org.jabref.preferences.JabRefPreferences) Preferences(java.util.prefs.Preferences)

Example 67 with BackingStoreException

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;
}
Also used : ArrayList(java.util.ArrayList) CustomEntryType(org.jabref.model.entry.CustomEntryType) BackingStoreException(java.util.prefs.BackingStoreException) OpenOfficePreferences(org.jabref.logic.openoffice.OpenOfficePreferences) RemotePreferences(org.jabref.logic.remote.RemotePreferences) LatexFieldFormatterPreferences(org.jabref.logic.bibtex.LatexFieldFormatterPreferences) AutoCompletePreferences(org.jabref.logic.autocompleter.AutoCompletePreferences) NameFormatterPreferences(org.jabref.logic.layout.format.NameFormatterPreferences) FieldContentParserPreferences(org.jabref.logic.bibtex.FieldContentParserPreferences) CleanupPreferences(org.jabref.logic.cleanup.CleanupPreferences) JournalAbbreviationPreferences(org.jabref.logic.journals.JournalAbbreviationPreferences) FileLinkPreferences(org.jabref.logic.layout.format.FileLinkPreferences) AutoLinkPreferences(org.jabref.logic.util.io.AutoLinkPreferences) ProtectedTermsPreferences(org.jabref.logic.protectedterms.ProtectedTermsPreferences) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) UpdateFieldPreferences(org.jabref.logic.util.UpdateFieldPreferences) ProxyPreferences(org.jabref.logic.net.ProxyPreferences) XMPPreferences(org.jabref.logic.xmp.XMPPreferences) FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Preferences(java.util.prefs.Preferences) BibtexKeyPatternPreferences(org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)

Example 68 with BackingStoreException

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);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) OpenOfficePreferences(org.jabref.logic.openoffice.OpenOfficePreferences) RemotePreferences(org.jabref.logic.remote.RemotePreferences) LatexFieldFormatterPreferences(org.jabref.logic.bibtex.LatexFieldFormatterPreferences) AutoCompletePreferences(org.jabref.logic.autocompleter.AutoCompletePreferences) NameFormatterPreferences(org.jabref.logic.layout.format.NameFormatterPreferences) FieldContentParserPreferences(org.jabref.logic.bibtex.FieldContentParserPreferences) CleanupPreferences(org.jabref.logic.cleanup.CleanupPreferences) JournalAbbreviationPreferences(org.jabref.logic.journals.JournalAbbreviationPreferences) FileLinkPreferences(org.jabref.logic.layout.format.FileLinkPreferences) AutoLinkPreferences(org.jabref.logic.util.io.AutoLinkPreferences) ProtectedTermsPreferences(org.jabref.logic.protectedterms.ProtectedTermsPreferences) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) UpdateFieldPreferences(org.jabref.logic.util.UpdateFieldPreferences) ProxyPreferences(org.jabref.logic.net.ProxyPreferences) XMPPreferences(org.jabref.logic.xmp.XMPPreferences) FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Preferences(java.util.prefs.Preferences) BibtexKeyPatternPreferences(org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)

Example 69 with BackingStoreException

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);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 70 with BackingStoreException

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);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Aggregations

BackingStoreException (java.util.prefs.BackingStoreException)112 Preferences (java.util.prefs.Preferences)95 NbPreferences (org.openide.util.NbPreferences)14 File (java.io.File)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)4 AutoCompletePreferences (org.jabref.logic.autocompleter.AutoCompletePreferences)4 FieldContentParserPreferences (org.jabref.logic.bibtex.FieldContentParserPreferences)4 LatexFieldFormatterPreferences (org.jabref.logic.bibtex.LatexFieldFormatterPreferences)4 BibtexKeyPatternPreferences (org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)4 CleanupPreferences (org.jabref.logic.cleanup.CleanupPreferences)4 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)4 JournalAbbreviationPreferences (org.jabref.logic.journals.JournalAbbreviationPreferences)4 LayoutFormatterPreferences (org.jabref.logic.layout.LayoutFormatterPreferences)4 FileLinkPreferences (org.jabref.logic.layout.format.FileLinkPreferences)4 NameFormatterPreferences (org.jabref.logic.layout.format.NameFormatterPreferences)4 ProxyPreferences (org.jabref.logic.net.ProxyPreferences)4 OpenOfficePreferences (org.jabref.logic.openoffice.OpenOfficePreferences)4 ProtectedTermsPreferences (org.jabref.logic.protectedterms.ProtectedTermsPreferences)4