Search in sources :

Example 31 with BackingStoreException

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

the class AbstractUiContext method setShowTriggerChanceFailure.

@Override
public void setShowTriggerChanceFailure(final boolean value) {
    final Preferences prefs = Preferences.userNodeForPackage(AbstractUiContext.class);
    prefs.putBoolean(SHOW_TRIGGERED_CHANCE_FAILURE, 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)

Example 32 with BackingStoreException

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

the class AbstractUiContext method setShowTriggeredNotifications.

@Override
public void setShowTriggeredNotifications(final boolean value) {
    final Preferences prefs = Preferences.userNodeForPackage(AbstractUiContext.class);
    prefs.putBoolean(SHOW_TRIGGERED_NOTIFICATIONS, value);
    try {
        prefs.flush();
    } catch (final BackingStoreException ex) {
        ex.printStackTrace();
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 33 with BackingStoreException

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

the class TileImageFactory method setShowMapBlendAlpha.

public static void setShowMapBlendAlpha(final float showMapBlendAlpha) {
    TileImageFactory.showMapBlendAlpha = showMapBlendAlpha;
    final Preferences prefs = Preferences.userNodeForPackage(TileImageFactory.class);
    prefs.putFloat(SHOW_MAP_BLEND_ALPHA, TileImageFactory.showMapBlendAlpha);
    try {
        prefs.flush();
    } catch (final BackingStoreException ex) {
        ClientLogger.logQuietly("faild to save value: " + showMapBlendAlpha, ex);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 34 with BackingStoreException

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

the class TileImageFactory method setShowMapBlendMode.

public static void setShowMapBlendMode(final String showMapBlendMode) {
    TileImageFactory.showMapBlendMode = showMapBlendMode;
    final Preferences prefs = Preferences.userNodeForPackage(TileImageFactory.class);
    prefs.put(SHOW_MAP_BLEND_MODE, TileImageFactory.showMapBlendMode);
    try {
        prefs.flush();
    } catch (final BackingStoreException ex) {
        ClientLogger.logQuietly("faild to save value: " + showMapBlendMode, ex);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 35 with BackingStoreException

use of java.util.prefs.BackingStoreException in project jvarkit by lindenb.

the class FilePeeker method choose.

public void choose() {
    Preferences prefs = Preferences.userNodeForPackage(getClass());
    String dirStr = prefs.get("last.directory." + name, null);
    File lastDir = null;
    if (dirStr != null)
        lastDir = new File(dirStr);
    JFileChooser chooser = new JFileChooser(lastDir);
    if (fileFilter != null)
        chooser.setFileFilter(fileFilter);
    chooser.setMultiSelectionEnabled(this.multiple);
    if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
        return;
    }
    if (multiple) {
        DefaultListModel<File> m = (DefaultListModel<File>) fileList.getModel();
        for (File f : chooser.getSelectedFiles()) {
            if (m.indexOf(f) != -1)
                continue;
            m.addElement(f);
        }
    } else {
        File f = chooser.getSelectedFile();
        setFile(f);
        if (this.file.getParentFile() != null) {
            prefs.put("last.directory." + name, this.file.getParentFile().getPath());
            try {
                prefs.sync();
            } catch (BackingStoreException err) {
            }
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) BackingStoreException(java.util.prefs.BackingStoreException) DefaultListModel(javax.swing.DefaultListModel) Preferences(java.util.prefs.Preferences) File(java.io.File)

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