From e87eec2162d1f2ab3baf3b406777d4f2e0232d9c Mon Sep 17 00:00:00 2001 From: Andreas Billmann Date: Thu, 11 Aug 2016 12:55:09 +0200 Subject: [PATCH] no need for 2 checkboxes when it is a boolean rule --- .../ValidationEditorController.java | 62 +++++++------------ .../javafx/smartcsv/fx/smartcsv.properties | 10 +-- .../javafx/smartcsv/fx/smartcsv_de.properties | 8 +-- .../fx/validation/validationEditor.fxml | 19 +++--- 4 files changed, 40 insertions(+), 59 deletions(-) diff --git a/src/main/java/ninja/javafx/smartcsv/fx/validation/ValidationEditorController.java b/src/main/java/ninja/javafx/smartcsv/fx/validation/ValidationEditorController.java index dd20e9a..11dd839 100644 --- a/src/main/java/ninja/javafx/smartcsv/fx/validation/ValidationEditorController.java +++ b/src/main/java/ninja/javafx/smartcsv/fx/validation/ValidationEditorController.java @@ -95,20 +95,20 @@ public class ValidationEditorController extends FXMLController { + "|(?" + COMMENT_PATTERN + ")" ); - @FXML - private CheckBox notEmptyRuleCheckBox; - - @FXML - private CheckBox integerRuleCheckBox; - - @FXML - private CheckBox doublerRuleCheckBox; - - @FXML - private CheckBox alphanumericRuleCheckBox; - - @FXML - private CheckBox uniqueRuleCheckBox; +// @FXML +// private CheckBox notEmptyRuleCheckBox; +// +// @FXML +// private CheckBox integerRuleCheckBox; +// +// @FXML +// private CheckBox doublerRuleCheckBox; +// +// @FXML +// private CheckBox alphanumericRuleCheckBox; +// +// @FXML +// private CheckBox uniqueRuleCheckBox; @FXML private Spinner minLengthSpinner; @@ -174,11 +174,6 @@ public class ValidationEditorController extends FXMLController { minLengthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0)); maxLengthSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, Integer.MAX_VALUE, 0)); - initCheckBox(notEmptyRuleCheckBox, enableNotEmptyRule); - initCheckBox(integerRuleCheckBox, enableIntegerRule); - initCheckBox(doublerRuleCheckBox, enableDoubleRule); - initCheckBox(alphanumericRuleCheckBox, enableAlphanumericRule); - initCheckBox(uniqueRuleCheckBox, enableUniqueRule); initSpinner(minLengthSpinner, enableMinLengthRule); initSpinner(maxLengthSpinner, enableMaxLengthRule); initTextInputControl(dateformatRuleTextField, enableDateRule); @@ -210,31 +205,31 @@ public class ValidationEditorController extends FXMLController { public void updateConfiguration() { if (enableIntegerRule.isSelected()) { - validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), integerRuleCheckBox.isSelected()); + validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), enableIntegerRule.isSelected()); } else { validationConfiguration.setIntegerRuleFor(selectedColumn.getValue(), null); } if (enableNotEmptyRule.isSelected()) { - validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), notEmptyRuleCheckBox.isSelected()); + validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), enableNotEmptyRule.isSelected()); } else { validationConfiguration.setNotEmptyRuleFor(selectedColumn.getValue(), null); } if (enableUniqueRule.isSelected()) { - validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), uniqueRuleCheckBox.isSelected()); + validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), enableUniqueRule.isSelected()); } else { validationConfiguration.setUniqueRuleFor(selectedColumn.getValue(), null); } if (enableDoubleRule.isSelected()) { - validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), doublerRuleCheckBox.isSelected()); + validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), enableDoubleRule.isSelected()); } else { validationConfiguration.setDoubleRuleFor(selectedColumn.getValue(), null); } if (enableAlphanumericRule.isSelected()) { - validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), alphanumericRuleCheckBox.isSelected()); + validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), enableAlphanumericRule.isSelected()); } else { validationConfiguration.setAlphanumericRuleFor(selectedColumn.getValue(), null); } @@ -281,31 +276,26 @@ public class ValidationEditorController extends FXMLController { private void updateForm() { updateCheckBox( - notEmptyRuleCheckBox, validationConfiguration.getNotEmptyRuleFor(getSelectedColumn()), enableNotEmptyRule ); updateCheckBox( - integerRuleCheckBox, validationConfiguration.getIntegerRuleFor(getSelectedColumn()), enableIntegerRule ); updateCheckBox( - doublerRuleCheckBox, validationConfiguration.getDoubleRuleFor(getSelectedColumn()), enableDoubleRule ); updateCheckBox( - alphanumericRuleCheckBox, validationConfiguration.getAlphanumericRuleFor(getSelectedColumn()), enableAlphanumericRule ); updateCheckBox( - uniqueRuleCheckBox, validationConfiguration.getUniqueRuleFor(getSelectedColumn()), enableUniqueRule ); @@ -347,12 +337,11 @@ public class ValidationEditorController extends FXMLController { ); } - private void updateCheckBox(CheckBox rule, Boolean value, CheckBox ruleEnabled) { + private void updateCheckBox(Boolean value, CheckBox ruleEnabled) { if (value == null) { ruleEnabled.setSelected(false); } else { - rule.setSelected(value); - ruleEnabled.setSelected(true); + ruleEnabled.setSelected(value); } } @@ -392,15 +381,6 @@ public class ValidationEditorController extends FXMLController { } } - private void initCheckBox(CheckBox rule, CheckBox ruleEnabled) { - rule.disableProperty().bind(ruleEnabled.selectedProperty().not()); - ruleEnabled.selectedProperty().addListener((observable, oldValue, newValue) -> { - if (!newValue) { - rule.setSelected(false); - } - }); - } - private void initSpinner(Spinner rule, CheckBox ruleEnabled) { rule.disableProperty().bind(ruleEnabled.selectedProperty().not()); ruleEnabled.selectedProperty().addListener((observable, oldValue, newValue) -> { diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties index 3cb4bcc..5cc9ef6 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties +++ b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties @@ -60,20 +60,20 @@ validation.message.header.length = number of headers is not correct! there are { validation.message.header.match = header number {0} does not match "{1}" should be "{2}" validation.message.value.of = Value {0} is not part of this list {1} -validation.rule.label.not_empty = not empty: -validation.rule.label.integer = integer: -validation.rule.label.double = double: +validation.rule.label.not_empty = not empty +validation.rule.label.integer = integer +validation.rule.label.double = double validation.rule.label.minlength = minimum length: validation.rule.label.maxlength = maximum length: validation.rule.label.dateformat = date format: -validation.rule.label.alphanumeric = alphanumeric: +validation.rule.label.alphanumeric = alphanumeric validation.rule.label.regexp = regular expression: validation.rule.label.value_of = value in list: validation.rule.label.groovy = groovy: validation.rules.active = active validation.rules.name = rule validation.rules.value = value -validation.rule.label.unique = Unique in column: +validation.rule.label.unique = Unique in column dialog.validation.rules.title = Validation rules dialog.validation.rules.header = Validation rules of column "{0}" diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties index c966ce6..ce2dcc3 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties +++ b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties @@ -69,9 +69,9 @@ validation.message.header.length = Anzahl der \u00dcberschriften ist nicht korre validation.message.header.match = \u00dcberschrift in Spalte {0} stimmt nicht. "{1}" sollte "{3}" sein validation.message.value.of = Der Wert {0} ist nicht in der Liste {1} enthalten -validation.rule.label.not_empty = Nicht leer: -validation.rule.label.integer = Zahl: -validation.rule.label.double = Gleitkommazahl: +validation.rule.label.not_empty = Nicht leer +validation.rule.label.integer = Zahl +validation.rule.label.double = Gleitkommazahl validation.rule.label.minlength = Minimale L\u00e4nge: validation.rule.label.maxlength = Maximale L\u00e4nge: validation.rule.label.dateformat = Datumsformat: @@ -82,7 +82,7 @@ validation.rule.label.groovy = groovy: validation.rules.active = Aktiv validation.rules.name = Regel validation.rules.value = Wert -validation.rule.label.unique = Einmalig in Spalte: +validation.rule.label.unique = Einmalig in Spalte dialog.validation.rules.title = Pr\u00fcfregeln dialog.validation.rules.header = Pr\u00fcfregeln f\u00fcr die Spalte "{0}" diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/validation/validationEditor.fxml b/src/main/resources/ninja/javafx/smartcsv/fx/validation/validationEditor.fxml index 6d29851..b38c287 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/validation/validationEditor.fxml +++ b/src/main/resources/ninja/javafx/smartcsv/fx/validation/validationEditor.fxml @@ -1,10 +1,16 @@ - - - - + + + + + + + + + + @@ -39,15 +45,10 @@