Skip to content

Commit

Permalink
Add button in preference dialog to reset preferences
Browse files Browse the repository at this point in the history
Implements JabRef#455 and/or [kopper
47](koppor#47)
  • Loading branch information
tobiasdiez committed Mar 6, 2016
1 parent c4fc0cc commit d1ed189
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!
*
Expand Down
34 changes: 28 additions & 6 deletions src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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(),
Expand All @@ -195,14 +195,36 @@ 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();

pack();

}

private void updateAfterPreferenceChanges() {
setValues();
ExportFormats.initAllExports();
frame.removeCachedEntryEditors();
Globals.prefs.updateEntryEditorTabList();
}

class OkAction extends AbstractAction {

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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=

0 comments on commit d1ed189

Please sign in to comment.