diff --git a/CHANGELOG.md b/CHANGELOG.md index cecf443a39f..fdf7943f8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by ## [Unreleased] ### Changed +- Implemented [#455](https://github.com/JabRef/jabref/issues/455): Add button in preference dialog to reset preferences - Implemented [#756](https://github.com/JabRef/jabref/issues/756): Add possibility to reformat all entries on save (under Preferences, File) - Comments and preamble are serialized with capitalized first letter, i.e. `@Comment` instead of `@comment` and `@Preamble` instead of `@PREAMBLE`. - Global sorting options and preferences are removed. Databases can still be sorted on save, but this is configured locally and stored in the file diff --git a/src/main/java/net/sf/jabref/JabRefPreferences.java b/src/main/java/net/sf/jabref/JabRefPreferences.java index 5ec4b50390d..86a0094157a 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -1285,16 +1285,6 @@ public void importPreferences(String filename) throws JabRefException { } } - /** - * Determines whether the given field should be written without any sort of wrapping. - * - * @param fieldName The field name. - * @return true if the field should not be wrapped. - */ - public boolean isNonWrappableField(String fieldName) { - return nonWrappableFields.contains(fieldName); - } - /** * ONLY FOR TESTING! * diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java index f25d50ed388..01896c16471 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.prefs.BackingStoreException; import javax.swing.AbstractAction; import javax.swing.BorderFactory; @@ -63,6 +64,7 @@ public class PreferencesDialog extends JDialog { private final JButton importPreferences = new JButton(Localization.lang("Import preferences")); private final JButton exportPreferences = new JButton(Localization.lang("Export preferences")); private final JButton showPreferences = new JButton(Localization.lang("Show preferences")); + private final JButton resetPreferences = new JButton(Localization.lang("Reset preferences")); private static final Log LOGGER = LogFactory.getLog(PreferencesDialog.class); @@ -125,10 +127,11 @@ public PreferencesDialog(JabRefFrame parent, JabRef jabRef) { JPanel buttons = new JPanel(); - buttons.setLayout(new GridLayout(3, 1)); + buttons.setLayout(new GridLayout(4, 1)); buttons.add(importPreferences, 0); buttons.add(exportPreferences, 1); buttons.add(showPreferences, 2); + buttons.add(resetPreferences, 3); JPanel westPanel = new JPanel(); westPanel.setLayout(new BorderLayout()); @@ -183,10 +186,11 @@ public PreferencesDialog(JabRefFrame parent, JabRef jabRef) { if (filename != null) { try { prefs.importPreferences(filename); - setValues(); - ExportFormats.initAllExports(); - frame.removeCachedEntryEditors(); - Globals.prefs.updateEntryEditorTabList(); + updateAfterPreferenceChanges(); + JOptionPane.showMessageDialog(PreferencesDialog.this, + Localization.lang("You must restart JabRef for this to come into effect."), + Localization.lang("Import preferences"), + JOptionPane.WARNING_MESSAGE); } catch (JabRefException ex) { LOGGER.warn(ex.getMessage(), ex); JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), @@ -195,7 +199,27 @@ public PreferencesDialog(JabRefFrame parent, JabRef jabRef) { } }); - showPreferences.addActionListener(e -> new JabRefPreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame).setVisible(true)); + showPreferences.addActionListener( + e -> new JabRefPreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame) + .setVisible(true)); + resetPreferences.addActionListener(e -> { + if (JOptionPane.showConfirmDialog(PreferencesDialog.this, + Localization.lang("Are you sure you want to reset all settings to default values?"), + Localization.lang("Reset preferences"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { + try { + prefs.clear(); + JOptionPane.showMessageDialog(PreferencesDialog.this, + Localization.lang("You must restart JabRef for this to come into effect."), + Localization.lang("Reset preferences"), + JOptionPane.WARNING_MESSAGE); + } catch (BackingStoreException ex) { + LOGGER.warn(ex.getMessage(), ex); + JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), + Localization.lang("Reset preferences"), JOptionPane.ERROR_MESSAGE); + } + updateAfterPreferenceChanges(); + } + }); setValues(); @@ -203,6 +227,12 @@ public PreferencesDialog(JabRefFrame parent, JabRef jabRef) { } + private void updateAfterPreferenceChanges() { + setValues(); + ExportFormats.initAllExports(); + frame.removeCachedEntryEditors(); + Globals.prefs.updateEntryEditorTabList(); + } class OkAction extends AbstractAction { diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index fd7e61477a2..337cf8ef15e 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -1785,3 +1785,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 0df69356cc0..7d5110e028e 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -2496,3 +2496,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index f6d0ebba24f..546b06acfd4 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2469,3 +2469,6 @@ Resolve_duplicate_keys=Resolve_duplicate_keys Unabbreviate_journal_names=Unabbreviate_journal_names Unabbreviating...=Unabbreviating... Usage=Usage + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?=Are_you_sure_you_want_to_reset_all_settings_to_default_values? +Reset_preferences=Reset_preferences \ No newline at end of file diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 1cc57145ac9..456d0853e96 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -1686,3 +1686,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index aa8bd7805ba..9bc2a0a581f 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -2473,3 +2473,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 9252e2e6c99..31c0343ffc0 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1725,3 +1725,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 163b9093e6e..0ea73accacc 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -1708,3 +1708,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 522a505bcf9..efc8c3a4756 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -1805,3 +1805,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index df54a69db69..812f3adde64 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -2480,3 +2480,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index c1e6b0d3862..da9b325c81d 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -2480,3 +2480,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index ae0f58c4be6..8327b74b21a 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -2879,3 +2879,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 5d670ffe623..71adf78fa0f 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -1699,3 +1699,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index eba2d53df55..20496a42f87 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -2480,3 +2480,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index e0db0da3579..fbee42c2446 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -1720,3 +1720,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index 8319d4afc24..a5c0fd30b58 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -2476,3 +2476,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 3f9b72447ae..69547f4b642 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -2473,3 +2473,6 @@ Resolve_duplicate_keys= Unabbreviate_journal_names= Unabbreviating...= Usage= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences=