the most senseless combination of rules are not possible any more

This commit is contained in:
2016-08-11 13:11:23 +02:00
parent e87eec2162
commit 3664a4e8a7

View File

@@ -28,6 +28,8 @@ package ninja.javafx.smartcsv.fx.validation;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import ninja.javafx.smartcsv.fx.FXMLController; import ninja.javafx.smartcsv.fx.FXMLController;
@@ -181,11 +183,30 @@ public class ValidationEditorController extends FXMLController {
initTextInputControl(valueOfRuleTextField, enableValueOfRule); initTextInputControl(valueOfRuleTextField, enableValueOfRule);
initCodeAreaControl(groovyRuleTextArea, enableGroovyRule); initCodeAreaControl(groovyRuleTextArea, enableGroovyRule);
listenToExcludingRuleCombinations();
selectedColumn.addListener(observable -> { selectedColumn.addListener(observable -> {
updateForm(); updateForm();
}); });
} }
private void listenToExcludingRuleCombinations() {
addDependencyListener(enableIntegerRule, enableDoubleRule, enableAlphanumericRule, enableDateRule);
addDependencyListener(enableDoubleRule, enableIntegerRule, enableAlphanumericRule, enableDateRule);
addDependencyListener(enableAlphanumericRule, enableIntegerRule, enableDoubleRule, enableDateRule);
addDependencyListener(enableDateRule, enableIntegerRule, enableDoubleRule, enableAlphanumericRule);
}
private void addDependencyListener(CheckBox rule, CheckBox... dependentRules) {
rule.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
for (CheckBox dependentRule: dependentRules) {
dependentRule.selectedProperty().setValue(false);
}
}
});
}
public String getSelectedColumn() { public String getSelectedColumn() {
return selectedColumn.get(); return selectedColumn.get();
} }