diff --git a/CHANGELOG.md b/CHANGELOG.md index cecf443a39fc..fdf7943f8e66 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 b3ec02e26e93..29ede0ef4743 100644 --- a/src/main/java/net/sf/jabref/JabRefPreferences.java +++ b/src/main/java/net/sf/jabref/JabRefPreferences.java @@ -1283,16 +1283,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 f25d50ed3881..39ad6e27d15f 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,7 @@ public PreferencesDialog(JabRefFrame parent, JabRef jabRef) { if (filename != null) { try { prefs.importPreferences(filename); - setValues(); - ExportFormats.initAllExports(); - frame.removeCachedEntryEditors(); - Globals.prefs.updateEntryEditorTabList(); + updateAfterPreferenceChanges(); } catch (JabRefException ex) { LOGGER.warn(ex.getMessage(), ex); JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(), @@ -195,7 +195,23 @@ 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(); + } 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 +219,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 d33760eb6a05..5c43a7d0ef10 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -1771,3 +1771,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 c8cafff9b6f0..af20c5cbf12d 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -2482,3 +2482,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 e47cbfa5dd35..67f2bf34a378 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2457,3 +2457,5 @@ abbreviation_detected=abbreviation_detected wrong_entry_type_as_proceedings_has_page_numbers=wrong_entry_type_as_proceedings_has_page_numbers Copy_special=Copy_special +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 aaed3c0daece..2d6bdb94e1c0 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -1673,3 +1673,6 @@ abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 9127d75e9256..e41070f0eaee 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -2460,3 +2460,6 @@ abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 30b7754b6fb5..b09682e38ea1 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1712,3 +1712,6 @@ abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 7652ea892605..afa78fad3b3b 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -1695,3 +1695,6 @@ abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 95983c4dbd6c..128cf7098a56 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -1791,3 +1791,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 022da4c3f5c5..c748372f079f 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -2467,3 +2467,6 @@ abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 2c59ca97584e..6f1b59416b4f 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -2466,3 +2466,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 86a44360e0a7..d0c4b051a5c7 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -2865,3 +2865,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 b43bf370f392..289c3639f7bf 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -1685,3 +1685,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 cb21b0183dd4..73d86c302191 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -2466,3 +2466,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 5c60176bcb55..5b5fb67af56e 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -1706,3 +1706,6 @@ link_should_refer_to_a_correct_file_path=bağlantı_doğru_bir_dosya_yolunu_işa abbreviation_detected=kısaltma_saptandı wrong_entry_type_as_proceedings_has_page_numbers=yanlış_girdi_türü_zira_tutanaklarda_sayfa_numarası_olur Copy_special=Özel_kopayala + +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 ce1f868a862b..fd5a5291ec28 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -2462,3 +2462,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +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 686c6402b424..8e471f401a7f 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -2459,3 +2459,6 @@ link_should_refer_to_a_correct_file_path= abbreviation_detected= wrong_entry_type_as_proceedings_has_page_numbers= Copy_special= + +Are_you_sure_you_want_to_reset_all_settings_to_default_values?= +Reset_preferences=