Skip to content

Commit

Permalink
Set auto-update checkbox enable/disable when reading preferences (#4446)
Browse files Browse the repository at this point in the history
* When initializing the UI from prefs, fire an event to make sure dependent controls get updated.

Drive-by code cleanup -- enums are singletons; don't call enum.equals(), just use ==.

* Update changelog to document fix.

* Refactor enable/disable logic to its own method

* Revert CHANGELOG. Change checkbox disable/enable logic to use FX bind / observable.
  • Loading branch information
sbeitzel authored and Siedlerchr committed Nov 6, 2018
1 parent 185c47a commit 5548f8f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/org/jabref/gui/preferences/GeneralTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.preferences.JabRefPreferences;

import static javafx.beans.binding.Bindings.not;

class GeneralTab extends Pane implements PrefsTab {

private final CheckBox useOwner;
Expand Down Expand Up @@ -59,10 +61,7 @@ public GeneralTab(DialogService dialogService, JabRefPreferences prefs) {
updateTimeStamp = new CheckBox(Localization.lang("Update timestamp on modification"));
useTimeStamp = new CheckBox(Localization.lang("Mark new entries with addition date") + ". "
+ Localization.lang("Date format") + ':');
if (!useTimeStamp.isSelected()) {
updateTimeStamp.setDisable(true);
}
useTimeStamp.setOnAction(e->updateTimeStamp.setDisable(!useTimeStamp.isSelected()));
updateTimeStamp.disableProperty().bind(not(useTimeStamp.selectedProperty()));
overwriteOwner = new CheckBox(Localization.lang("Overwrite"));
overwriteTimeStamp = new CheckBox(Localization.lang("If a pasted or imported entry already has the field set, overwrite."));
enforceLegalKeys = new CheckBox(Localization.lang("Enforce legal characters in BibTeX keys"));
Expand Down Expand Up @@ -182,9 +181,9 @@ public void storeSettings() {
// Update name of the time stamp field based on preferences
InternalBibtexFields.updateTimeStampField(prefs.get(JabRefPreferences.TIME_STAMP_FIELD));
prefs.setDefaultEncoding(encodings.getValue());
prefs.putBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE, biblatexMode.getValue().equals(BibDatabaseMode.BIBLATEX));
prefs.putBoolean(JabRefPreferences.BIBLATEX_DEFAULT_MODE, biblatexMode.getValue() == BibDatabaseMode.BIBLATEX);

if (!languageSelection.getValue().equals(prefs.getLanguage())) {
if (languageSelection.getValue() != prefs.getLanguage()) {
prefs.setLanguage(languageSelection.getValue());
Localization.setLanguage(languageSelection.getValue());

Expand Down

0 comments on commit 5548f8f

Please sign in to comment.