Search in sources :

Example 16 with BackingStoreException

use of java.util.prefs.BackingStoreException in project jabref by JabRef.

the class JabRefPreferences method putKeyPattern.

/**
     * Adds the given key pattern to the preferences
     *
     * @param pattern the pattern to store
     */
public void putKeyPattern(GlobalBibtexKeyPattern pattern) {
    keyPattern = pattern;
    // Store overridden definitions to Preferences.
    Preferences pre = Preferences.userNodeForPackage(PREFS_BASE_CLASS).node(BIBTEX_KEY_PATTERNS_NODE);
    try {
        // We remove all old entries.
        pre.clear();
    } catch (BackingStoreException ex) {
        LOGGER.info("BackingStoreException in JabRefPreferences.putKeyPattern", ex);
    }
    Set<String> allKeys = pattern.getAllKeys();
    for (String key : allKeys) {
        if (!pattern.isDefaultValue(key)) {
            // no default value
            // the first entry in the array is the full pattern
            // see org.jabref.logic.labelPattern.BibtexKeyPatternUtil.split(String)
            pre.put(key, pattern.getValue(key).get(0));
        }
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) OpenOfficePreferences(org.jabref.logic.openoffice.OpenOfficePreferences) RemotePreferences(org.jabref.logic.remote.RemotePreferences) LatexFieldFormatterPreferences(org.jabref.logic.bibtex.LatexFieldFormatterPreferences) AutoCompletePreferences(org.jabref.logic.autocompleter.AutoCompletePreferences) NameFormatterPreferences(org.jabref.logic.layout.format.NameFormatterPreferences) FieldContentParserPreferences(org.jabref.logic.bibtex.FieldContentParserPreferences) CleanupPreferences(org.jabref.logic.cleanup.CleanupPreferences) JournalAbbreviationPreferences(org.jabref.logic.journals.JournalAbbreviationPreferences) FileLinkPreferences(org.jabref.logic.layout.format.FileLinkPreferences) AutoLinkPreferences(org.jabref.logic.util.io.AutoLinkPreferences) ProtectedTermsPreferences(org.jabref.logic.protectedterms.ProtectedTermsPreferences) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) UpdateFieldPreferences(org.jabref.logic.util.UpdateFieldPreferences) ProxyPreferences(org.jabref.logic.net.ProxyPreferences) XMPPreferences(org.jabref.logic.xmp.XMPPreferences) FileDirectoryPreferences(org.jabref.model.metadata.FileDirectoryPreferences) LayoutFormatterPreferences(org.jabref.logic.layout.LayoutFormatterPreferences) Preferences(java.util.prefs.Preferences) BibtexKeyPatternPreferences(org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences)

Example 17 with BackingStoreException

use of java.util.prefs.BackingStoreException in project JMRI by JMRI.

the class ProgrammerConfigManager method savePreferences.

@Override
public void savePreferences(Profile profile) {
    Preferences preferences = ProfileUtils.getPreferences(profile, this.getClass(), true);
    if (this.defaultFile != null) {
        preferences.put(DEFAULT_FILE, this.defaultFile);
    } else {
        preferences.remove(DEFAULT_FILE);
    }
    preferences.putBoolean(SHOW_EMPTY_PANES, this.showEmptyPanes);
    preferences.putBoolean(SHOW_CV_NUMBERS, this.showCvNumbers);
    preferences.putBoolean(CAN_CACHE_DEFAULT, this.canCacheDefault);
    preferences.putBoolean(DO_CONFIRM_READ, this.doConfirmRead);
    try {
        preferences.sync();
    } catch (BackingStoreException ex) {
        log.error("Unable to save preferences.", ex);
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) FileLocationsPreferences(jmri.implementation.FileLocationsPreferences) Preferences(java.util.prefs.Preferences)

Example 18 with BackingStoreException

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

the class CayenneModelerController method changePathInLastProjListAction.

public void changePathInLastProjListAction(File oldFile, File newFile) {
    Preferences frefLastProjFiles = ModelerPreferences.getLastProjFilesPref();
    List<File> arr = ModelerPreferences.getLastProjFiles();
    // Add proj path to the preferences
    arr.remove(oldFile);
    arr.remove(newFile);
    arr.add(0, newFile);
    while (arr.size() > ModelerPreferences.LAST_PROJ_FILES_SIZE) {
        arr.remove(arr.size() - 1);
    }
    try {
        frefLastProjFiles.clear();
    } catch (BackingStoreException e) {
    // ignore exception
    }
    int size = arr.size();
    for (int i = 0; i < size; i++) {
        frefLastProjFiles.put(String.valueOf(i), arr.get(i).getAbsolutePath());
    }
    getLastDirectory().setDirectory(newFile);
    frame.fireRecentFileListChanged();
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences) File(java.io.File)

Example 19 with BackingStoreException

use of java.util.prefs.BackingStoreException in project BoofCV by lessthanoptimal.

the class OpenWebcamDialog method savePreferences.

public void savePreferences() {
    if (selectedCamera == null)
        return;
    Preferences prefs = Preferences.userRoot().node(getClass().getSimpleName());
    prefs.put("camera", selectedCamera.getName());
    prefs.putInt("width", width);
    prefs.putInt("height", height);
    try {
        prefs.flush();
    } catch (BackingStoreException ignore) {
    }
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 20 with BackingStoreException

use of java.util.prefs.BackingStoreException in project blue by kunstmusik.

the class InfoDialog method showInformationDialog.

public static final synchronized void showInformationDialog(Component parent, String information, String title) {
    if (infoText == null) {
        try {
            if (SwingUtilities.isEventDispatchThread()) {
                infoText = new MimeTypeEditorComponent("text/plain");
            } else {
                SwingUtilities.invokeAndWait(() -> infoText = new MimeTypeEditorComponent("text/plain"));
            }
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        } catch (InvocationTargetException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    infoText.setText(information);
    infoText.getJEditorPane().getCaret().setDot(0);
    final JDialog dlg = new JDialog(SwingUtilities.getWindowAncestor(parent));
    dlg.getContentPane().add(infoText);
    dlg.setModal(true);
    dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dlg.setTitle(title);
    final Preferences prefs = NbPreferences.forModule(InfoDialog.class);
    int w = prefs.getInt("infoDialogWidth", 760);
    int h = prefs.getInt("infoDialogHeight", 400);
    dlg.setSize(new Dimension(w, h));
    dlg.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            final Preferences prefs = NbPreferences.forModule(InfoDialog.class);
            prefs.putInt("infoDialogWidth", dlg.getWidth());
            prefs.putInt("infoDialogHeight", dlg.getHeight());
            prefs.putInt("infoDialogX", dlg.getX());
            prefs.putInt("infoDialogY", dlg.getY());
            try {
                prefs.sync();
            } catch (BackingStoreException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
    int x = prefs.getInt("infoDialogX", -1);
    int y = prefs.getInt("infoDialogY", -1);
    if (x > 0 && y > 0) {
        dlg.setLocation(x, y);
    } else {
        GUI.centerOnScreen(dlg);
    }
    dlg.setVisible(true);
    infoText.setText("");
}
Also used : WindowEvent(java.awt.event.WindowEvent) MimeTypeEditorComponent(blue.ui.nbutilities.MimeTypeEditorComponent) BackingStoreException(java.util.prefs.BackingStoreException) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) Preferences(java.util.prefs.Preferences) NbPreferences(org.openide.util.NbPreferences) InvocationTargetException(java.lang.reflect.InvocationTargetException) JDialog(javax.swing.JDialog)

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