Skip to content

Commit

Permalink
Refactor enable/disable logic to its own method
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeitzel committed Nov 3, 2018
1 parent f13fb65 commit 8dd0800
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/jabref/gui/preferences/GeneralTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.time.format.DateTimeFormatter;

import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
Expand Down Expand Up @@ -63,7 +62,7 @@ public GeneralTab(DialogService dialogService, JabRefPreferences prefs) {
if (!useTimeStamp.isSelected()) {
updateTimeStamp.setDisable(true);
}
useTimeStamp.setOnAction(e->updateTimeStamp.setDisable(!useTimeStamp.isSelected()));
useTimeStamp.setOnAction(e->setDisableUpdateTimeStamp());
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 @@ -134,12 +133,16 @@ public Node getBuilder() {
return builder;
}

private void setDisableUpdateTimeStamp() {
updateTimeStamp.setDisable(!useTimeStamp.isSelected());
}

@Override
public void setValues() {
useOwner.setSelected(prefs.getBoolean(JabRefPreferences.USE_OWNER));
overwriteOwner.setSelected(prefs.getBoolean(JabRefPreferences.OVERWRITE_OWNER));
useTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.USE_TIME_STAMP));
useTimeStamp.getOnAction().handle(new ActionEvent()); // pretend we just clicked on the checkbox so it updates the UI
setDisableUpdateTimeStamp();
overwriteTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.OVERWRITE_TIME_STAMP));
updateTimeStamp.setSelected(prefs.getBoolean(JabRefPreferences.UPDATE_TIMESTAMP));
updateTimeStamp.setSelected(useTimeStamp.isSelected());
Expand Down

0 comments on commit 8dd0800

Please sign in to comment.