Search in sources :

Example 26 with BackingStoreException

use of java.util.prefs.BackingStoreException in project triplea by triplea-game.

the class ClipPlayer method setBeSilentInPreferencesWithoutAffectingCurrent.

public static void setBeSilentInPreferencesWithoutAffectingCurrent(final boolean silentBool) {
    final Preferences prefs = Preferences.userNodeForPackage(ClipPlayer.class);
    final boolean current = prefs.getBoolean(SOUND_PREFERENCE_GLOBAL_SWITCH, DEFAULT_SOUND_SILENCED_SWITCH_SETTING);
    boolean setPref = silentBool != current;
    if (!setPref) {
        try {
            setPref = !Arrays.asList(prefs.keys()).contains(SOUND_PREFERENCE_GLOBAL_SWITCH);
        } catch (final BackingStoreException e) {
            ClientLogger.logQuietly("Failed to get keys for preferences: " + prefs.absolutePath(), e);
        }
    }
    if (setPref) {
        prefs.putBoolean(SOUND_PREFERENCE_GLOBAL_SWITCH, silentBool);
        try {
            prefs.flush();
        } catch (final BackingStoreException e) {
            ClientLogger.logQuietly("Failed to flush preferences: " + prefs.absolutePath(), e);
        }
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 27 with BackingStoreException

use of java.util.prefs.BackingStoreException in project triplea by triplea-game.

the class ChatIgnoreList method remove.

void remove(final String name) {
    synchronized (lock) {
        ignore.remove(name);
        final Preferences prefs = getPrefNode();
        prefs.remove(name);
        try {
            prefs.flush();
        } catch (final BackingStoreException e) {
            logger.log(Level.FINE, e.getMessage(), e);
        }
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 28 with BackingStoreException

use of java.util.prefs.BackingStoreException in project triplea by triplea-game.

the class HeadedUiContext method setUnitScaleFactor.

@Override
public void setUnitScaleFactor(final double scaleFactor) {
    unitImageFactory.setScaleFactor(scaleFactor);
    final Preferences prefs = getPreferencesMapOrSkin(getMapDir());
    prefs.putDouble(UNIT_SCALE_PREF, scaleFactor);
    try {
        prefs.flush();
    } catch (final BackingStoreException e) {
        ClientLogger.logQuietly("Failed to flush preferences: " + prefs.absolutePath(), e);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 29 with BackingStoreException

use of java.util.prefs.BackingStoreException in project triplea by triplea-game.

the class AbstractUiContext method setMapDir.

@Override
public void setMapDir(final GameData data, final String mapDir) {
    internalSetMapDir(mapDir, data);
    this.getMapData().verify(data);
    // set the default after internal succeeds, if an error is thrown
    // we don't want to persist it
    final String mapName = (String) data.getProperties().get(Constants.MAP_NAME);
    final Preferences prefs = getPreferencesForMap(mapName);
    prefs.put(MAP_SKIN_PREF, mapDir);
    try {
        prefs.flush();
    } catch (final BackingStoreException e) {
        ClientLogger.logQuietly("Failed to flush preferences: " + prefs.absolutePath(), e);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 30 with BackingStoreException

use of java.util.prefs.BackingStoreException in project triplea by triplea-game.

the class AbstractUiContext method setShowTriggerChanceSuccessful.

@Override
public void setShowTriggerChanceSuccessful(final boolean value) {
    final Preferences prefs = Preferences.userNodeForPackage(AbstractUiContext.class);
    prefs.putBoolean(SHOW_TRIGGERED_CHANCE_SUCCESSFUL, value);
    try {
        prefs.flush();
    } catch (final BackingStoreException ex) {
        ClientLogger.logQuietly("Failed to flush preferences: " + prefs.absolutePath(), 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