Search in sources :

Example 91 with BackingStoreException

use of java.util.prefs.BackingStoreException in project hale by halestudio.

the class CustomTileMapServerConfiguration method load.

/**
 * Load configuration with the given name
 *
 * @param name the configuration name
 *
 * @return if loading the configuration succeeded
 */
public boolean load(String name) {
    Preferences preferences = getPreferences();
    try {
        if (preferences.nodeExists(name)) {
            Preferences node = preferences.node(name);
            setName(name);
            loadProperties(node);
            return true;
        } else {
            // $NON-NLS-1$ //$NON-NLS-2$
            log.warn("No configuration named " + name + " found");
            return false;
        }
    } catch (BackingStoreException e) {
        // $NON-NLS-1$
        log.error("Error loading CustomTile configuration");
        return false;
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 92 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 93 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 94 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)

Example 95 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)

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