Search in sources :

Example 51 with BackingStoreException

use of java.util.prefs.BackingStoreException in project tigervnc by TigerVNC.

the class UserPreferences method load.

public static void load(String nName) {
    // Sets the value of any corresponding Configuration parameters
    try {
        Preferences node = root.node(nName);
        String[] keys = node.keys();
        for (int i = 0; i < keys.length; i++) {
            String key = keys[i];
            VoidParameter p = Configuration.getParam(key);
            if (p == null)
                continue;
            String valueStr = node.get(key, null);
            if (valueStr == null)
                valueStr = p.getDefaultStr();
            Configuration.setParam(key, valueStr);
        }
    } catch (BackingStoreException e) {
        vlog.error(e.getMessage());
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 52 with BackingStoreException

use of java.util.prefs.BackingStoreException in project tigervnc by TigerVNC.

the class UserPreferences method save.

public static void save(String nName) {
    try {
        Preferences node = root.node(nName);
        node.sync();
        String[] keys = root.keys();
        for (int i = 0; i < keys.length; i++) vlog.debug(keys[i] + " = " + node.get(keys[i], null));
    } catch (BackingStoreException e) {
        vlog.error(e.getMessage());
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 53 with BackingStoreException

use of java.util.prefs.BackingStoreException in project cayenne by apache.

the class CodeTemplateManager method updateCustomTemplates.

/**
 * Updates custom templates from preferences.
 */
public void updateCustomTemplates(Preferences preference) {
    String[] keys = {};
    try {
        keys = preference.childrenNames();
    } catch (BackingStoreException e) {
        logger.warn("Error reading preferences");
    }
    this.customTemplates = new HashMap<>(keys.length, 1);
    for (String key : keys) {
        FSPath path = new FSPath(preference.node(key));
        customTemplates.put(key, path.getPath());
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) FSPath(org.apache.cayenne.modeler.pref.FSPath)

Example 54 with BackingStoreException

use of java.util.prefs.BackingStoreException in project cayenne by apache.

the class CayennePreferenceEditor method revert.

public void revert() {
    // remove added preferences node
    for (Preferences pref : addedNode) {
        try {
            pref.removeNode();
        } catch (BackingStoreException ignored) {
        }
    }
    cayenneProjectPreferences.getDetailObject(DBConnectionInfo.class).cancel();
    restartRequired = false;
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences) DBConnectionInfo(org.apache.cayenne.modeler.pref.DBConnectionInfo)

Example 55 with BackingStoreException

use of java.util.prefs.BackingStoreException in project cayenne by apache.

the class ChildrenMapPreference method initChildrenPreferences.

public void initChildrenPreferences() {
    Map<String, Object> children = new HashMap<>();
    try {
        String[] names = getCurrentPreference().childrenNames();
        for (String name : names) {
            try {
                Object newInstance = delegate.getClass().getConstructor(String.class, boolean.class).newInstance(name, true);
                children.put(name, newInstance);
            } catch (Throwable e) {
                throw new CayenneRuntimeException("Error initializing preference", e);
            }
        }
        this.children.putAll(children);
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
Also used : HashMap(java.util.HashMap) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) BackingStoreException(java.util.prefs.BackingStoreException)

Aggregations

BackingStoreException (java.util.prefs.BackingStoreException)58 Preferences (java.util.prefs.Preferences)47 File (java.io.File)8 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)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