wordsArea.textProperty().addListener(o -> {
if (origDate.equals(datePicker.getValue()))
datePicker.setValue(null);
});
BooleanBinding datePickerIsInvalid = or(
datePicker.valueProperty().isNull(),
createBooleanBinding(() ->
datePicker.getValue().isAfter(LocalDate.now())
, /* depends on */ datePicker.valueProperty())
);
// Don't let the user click restore if the words area contains the current wallet words, or are an invalid set,
// or if the date field isn't set, or if it's in the future.
restoreButton.disableProperty().bind(
or(
or(
not(validator.valid),
equal(origWords, wordsArea.textProperty())
),
datePickerIsInvalid
)
);
// Highlight the date picker in red if it's empty or in the future, so the user knows why restore is disabled.
datePickerIsInvalid.addListener((dp, old, cur) -> {
if (cur) {
datePicker.getStyleClass().add("validation_error");
} else {
datePicker.getStyleClass().remove("validation_error");
}