Search in sources :

Example 96 with BackingStoreException

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

the class RenamedPreferences method childrenCopy.

private static ArrayList<Preferences> childrenCopy(Preferences pref, String oldPath, String newPath) {
    try {
        String[] children = pref.childrenNames();
        ArrayList<Preferences> prefChild = new ArrayList<Preferences>();
        for (int j = 0; j < children.length; j++) {
            String child = children[j];
            // get old preference
            Preferences childNode = pref.node(child);
            if (!equalsPath(oldNode, childNode)) {
                // path to node
                String path = childNode.absolutePath().replace(oldPath, newPath);
                // copy all preferences in this node
                String[] names = childNode.keys();
                Preferences newPref = Preferences.userRoot().node(path);
                for (int i = 0; i < names.length; i++) {
                    newPref.put(names[i], childNode.get(names[i], ""));
                }
                prefChild.add(newPref);
            }
        }
        return prefChild;
    } catch (BackingStoreException e) {
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 97 with BackingStoreException

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

the class RenamedPreferences method removeOldPreferences.

public static void removeOldPreferences() {
    if (oldNode != null) {
        Iterator<Preferences> it = oldNode.iterator();
        while (it.hasNext()) {
            Preferences pref = it.next();
            try {
                pref.removeNode();
            } catch (BackingStoreException e) {
            } catch (IllegalStateException e) {
            // do nothing
            }
        }
        clearPreferences();
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 98 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 99 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 100 with BackingStoreException

use of java.util.prefs.BackingStoreException in project jgnash by ccavanaugh.

the class PortablePreferences method deleteUserPreferences.

public static void deleteUserPreferences() {
    try {
        final Preferences p = Preferences.userRoot();
        if (p.nodeExists("/jgnash")) {
            Preferences jgnash = p.node("/jgnash");
            jgnash.removeNode();
            p.flush();
            System.out.println(ResourceUtils.getString("Message.UninstallGood"));
        } else {
            System.err.println(ResourceUtils.getString("Message.PrefFail"));
        }
    } catch (final BackingStoreException bse) {
        LogUtil.logSevere(PortablePreferences.class, bse);
        System.err.println(ResourceUtils.getString("Message.UninstallBad"));
    }
}
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