Search in sources :

Example 56 with BackingStoreException

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

the class ChildrenMapPreference method save.

public void save() {
    if (removeObject.size() > 0) {
        for (String aRemoveObject : removeObject) {
            try {
                delegate.getCurrentPreference().node(aRemoveObject).removeNode();
            } catch (BackingStoreException e) {
                throw new CayenneRuntimeException("Error saving preference");
            }
        }
    }
    for (Map.Entry<String, Object> pairs : children.entrySet()) {
        delegate.getCurrentPreference().node(pairs.getKey());
        ((CayennePreference) pairs.getValue()).saveObjectPreference();
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) CayenneRuntimeException(org.apache.cayenne.CayenneRuntimeException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 57 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 58 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)

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