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);
}
}
}
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);
}
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations