Search in sources :

Example 11 with BackingStoreException

use of java.util.prefs.BackingStoreException in project jdk8u_jdk by JetBrains.

the class InputContext method getInputMethodSelectionKeyStroke.

private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) {
    try {
        if (root.nodeExists(inputMethodSelectionKeyPath)) {
            Preferences node = root.node(inputMethodSelectionKeyPath);
            int keyCode = node.getInt(inputMethodSelectionKeyCodeName, KeyEvent.VK_UNDEFINED);
            if (keyCode != KeyEvent.VK_UNDEFINED) {
                int modifiers = node.getInt(inputMethodSelectionKeyModifiersName, 0);
                return AWTKeyStroke.getAWTKeyStroke(keyCode, modifiers);
            }
        }
    } catch (BackingStoreException bse) {
    }
    return null;
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 12 with BackingStoreException

use of java.util.prefs.BackingStoreException in project intellij-plugins by JetBrains.

the class OptionsButton method addResetPreferencesActionTo.

private void addResetPreferencesActionTo(DefaultActionGroup actionGroup) {
    myResetSettingsAction = new AnAction("Reset to default settings") {

        public void actionPerformed(AnActionEvent e) {
            try {
                Preferences preferences = Preferences.userRoot().node("jetbrains.communicator");
                preferences.removeNode();
                preferences.flush();
            } catch (BackingStoreException e1) {
                LOG.error(e1.getMessage(), e1);
            }
        }
    };
    actionGroup.add(myResetSettingsAction);
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Preferences(java.util.prefs.Preferences) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 13 with BackingStoreException

use of java.util.prefs.BackingStoreException in project processdash by dtuma.

the class TranslationSharer method promptForAuthorInfo.

private void promptForAuthorInfo() {
    JLabel authorLabel = new JLabel(resources.getString("Translation.Sharing.Author.Name_Prompt"));
    JTextField author = new JTextField(20);
    JLabel emailLabel = new JLabel(resources.getString("Translation.Sharing.Author.Email_Prompt"));
    JTextField email = new JTextField(30);
    JRadioButton yesOption = new JRadioButton(resources.getString("Translation.Sharing.Author.Yes_Option"), true);
    JRadioButton noOption = new JRadioButton(resources.getString("Translation.Sharing.Author.No_Option"));
    ButtonGroup group = new ButtonGroup();
    group.add(yesOption);
    group.add(noOption);
    ContactOptionListener l = new ContactOptionListener(yesOption, new JComponent[] { authorLabel, author, emailLabel, email });
    yesOption.addActionListener(l);
    noOption.addActionListener(l);
    Box buttonBox = Box.createHorizontalBox();
    buttonBox.add(yesOption);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(noOption);
    buttonBox.add(Box.createHorizontalGlue());
    Object[] message = new Object[] { resources.getString("Translation.Sharing.Author.Prompt"), buttonBox, inputBox(authorLabel, author), inputBox(emailLabel, email) };
    JOptionPane.showMessageDialog(null, message, resources.getString("Translation.Sharing.Author.Title"), JOptionPane.OK_OPTION);
    if (yesOption.isSelected()) {
        prefs.put(AUTHOR_SETTING, author.getText());
        prefs.put(EMAIL_SETTING, email.getText());
        try {
            prefs.flush();
        } catch (BackingStoreException e) {
            System.out.println(resources.getString("Translation.Errors.Cant_Save_Preferences"));
            e.printStackTrace();
        }
    }
}
Also used : JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) BackingStoreException(java.util.prefs.BackingStoreException) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JTextField(javax.swing.JTextField)

Example 14 with BackingStoreException

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

the class Util method getPreference.

static int[] getPreference(final String name, final int[] defaultValues) {
    Preferences prefs = getPreferences();
    try {
        prefs.sync();
        String value = prefs.get(name, null);
        if (value != null) {
            String[] values = value.split(",");
            int[] result = new int[values.length];
            for (int i = 0; i < values.length; i++) {
                result[i] = Integer.parseInt(values[i]);
            }
            return result;
        }
    } catch (BackingStoreException ioe) {
    // ignore
    } catch (NumberFormatException nfe) {
    // ignore
    }
    return defaultValues;
}
Also used : BackingStoreException(java.util.prefs.BackingStoreException) Preferences(java.util.prefs.Preferences)

Example 15 with BackingStoreException

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

the class JabRefPreferences method getKeyPattern.

/**
     * Fetches key patterns from preferences.
     * The implementation doesn't cache the results
     *
     * @return LabelPattern containing all keys. Returned LabelPattern has no parent
     */
public GlobalBibtexKeyPattern getKeyPattern() {
    keyPattern = GlobalBibtexKeyPattern.fromPattern(get(DEFAULT_BIBTEX_KEY_PATTERN));
    Preferences pre = Preferences.userNodeForPackage(PREFS_BASE_CLASS).node(BIBTEX_KEY_PATTERNS_NODE);
    try {
        String[] keys = pre.keys();
        if (keys.length > 0) {
            for (String key : keys) {
                keyPattern.addBibtexKeyPattern(key, pre.get(key, null));
            }
        }
    } catch (BackingStoreException ex) {
        LOGGER.info("BackingStoreException in JabRefPreferences.getKeyPattern", ex);
    }
    return keyPattern;
}
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)

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