Skip to content

Commit

Permalink
Merge pull request #915 from tobiasdiez/resetPreferences
Browse files Browse the repository at this point in the history
Add button in preference dialog to reset preferences
  • Loading branch information
oscargus committed Mar 7, 2016
2 parents 0bb5a5b + d5f3fc4 commit 904111c
Show file tree
Hide file tree
Showing 19 changed files with 85 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 @@ -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!
*
Expand Down
42 changes: 36 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,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(),
Expand All @@ -195,14 +199,40 @@ 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();

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 @@ -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=
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 @@ -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=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=
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 @@ -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=

0 comments on commit 904111c

Please sign in to comment.