mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
change editor to the new config
The editor should handle the new configuration
This commit is contained in:
@@ -35,6 +35,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
||||||
import ninja.javafx.smartcsv.fx.FXMLController;
|
import ninja.javafx.smartcsv.fx.FXMLController;
|
||||||
|
import ninja.javafx.smartcsv.validation.FieldConfiguration;
|
||||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||||
import org.fxmisc.richtext.CodeArea;
|
import org.fxmisc.richtext.CodeArea;
|
||||||
import org.fxmisc.richtext.LineNumberFactory;
|
import org.fxmisc.richtext.LineNumberFactory;
|
||||||
@@ -100,20 +101,8 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
+ "|(?<COMMENT>" + COMMENT_PATTERN + ")"
|
+ "|(?<COMMENT>" + COMMENT_PATTERN + ")"
|
||||||
);
|
);
|
||||||
|
|
||||||
// @FXML
|
@FXML
|
||||||
// private CheckBox notEmptyRuleCheckBox;
|
private ComboBox<FieldConfiguration.Type> typeComboBox;
|
||||||
//
|
|
||||||
// @FXML
|
|
||||||
// private CheckBox integerRuleCheckBox;
|
|
||||||
//
|
|
||||||
// @FXML
|
|
||||||
// private CheckBox doublerRuleCheckBox;
|
|
||||||
//
|
|
||||||
// @FXML
|
|
||||||
// private CheckBox alphanumericRuleCheckBox;
|
|
||||||
//
|
|
||||||
// @FXML
|
|
||||||
// private CheckBox uniqueRuleCheckBox;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Spinner<Integer> minLengthSpinner;
|
private Spinner<Integer> minLengthSpinner;
|
||||||
@@ -136,15 +125,6 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
@FXML
|
@FXML
|
||||||
private CheckBox enableNotEmptyRule;
|
private CheckBox enableNotEmptyRule;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CheckBox enableIntegerRule;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CheckBox enableDoubleRule;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private CheckBox enableAlphanumericRule;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private CheckBox enableMinLengthRule;
|
private CheckBox enableMinLengthRule;
|
||||||
|
|
||||||
@@ -176,6 +156,13 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize(URL location, ResourceBundle resources) {
|
public void initialize(URL location, ResourceBundle resources) {
|
||||||
|
|
||||||
|
typeComboBox.getItems().addAll(FieldConfiguration.Type.STRING,
|
||||||
|
FieldConfiguration.Type.INTEGER,
|
||||||
|
FieldConfiguration.Type.NUMBER,
|
||||||
|
FieldConfiguration.Type.DATE,
|
||||||
|
FieldConfiguration.Type.DATETIME,
|
||||||
|
FieldConfiguration.Type.TIME);
|
||||||
|
|
||||||
initMinMaxSpinner();
|
initMinMaxSpinner();
|
||||||
|
|
||||||
initSpinner(minLengthSpinner, enableMinLengthRule);
|
initSpinner(minLengthSpinner, enableMinLengthRule);
|
||||||
@@ -185,7 +172,6 @@ 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();
|
||||||
@@ -296,13 +282,6 @@ public class ValidationEditorController extends FXMLController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
private void addDependencyListener(CheckBox rule, CheckBox... dependentRules) {
|
||||||
rule.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
rule.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package ninja.javafx.smartcsv.validation;
|
package ninja.javafx.smartcsv.validation;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -8,9 +10,18 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class FieldConfiguration {
|
public class FieldConfiguration {
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
@SerializedName("string") STRING,
|
||||||
|
@SerializedName("integer") INTEGER,
|
||||||
|
@SerializedName("number") NUMBER,
|
||||||
|
@SerializedName("date") DATE,
|
||||||
|
@SerializedName("datetime") DATETIME,
|
||||||
|
@SerializedName("time") TIME
|
||||||
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String title;
|
private String title;
|
||||||
private String type;
|
private Type type;
|
||||||
private String description;
|
private String description;
|
||||||
private String format;
|
private String format;
|
||||||
private Object missingValue;
|
private Object missingValue;
|
||||||
@@ -32,11 +43,11 @@ public class FieldConfiguration {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public Type getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ package ninja.javafx.smartcsv.validation;
|
|||||||
*/
|
*/
|
||||||
public interface Validation {
|
public interface Validation {
|
||||||
|
|
||||||
enum Type { NOT_EMPTY, UNIQUE, DOUBLE, INTEGER, MIN_LENGTH, MAX_LENGTH, DATE, ALPHANUMERIC, REGEXP, VALUE_OF, GROOVY }
|
enum Type { NOT_EMPTY, UNIQUE, DOUBLE, INTEGER, MIN_LENGTH, MAX_LENGTH, DATE, REGEXP, VALUE_OF, GROOVY }
|
||||||
void check(int row, String value, ValidationError error);
|
void check(int row, String value, ValidationError error);
|
||||||
Type getType();
|
Type getType();
|
||||||
boolean canBeChecked(String value);
|
boolean canBeChecked(String value);
|
||||||
|
|||||||
@@ -157,25 +157,25 @@ public class Validator {
|
|||||||
private void initializeColumnWithRules(FieldConfiguration column) {
|
private void initializeColumnWithRules(FieldConfiguration column) {
|
||||||
|
|
||||||
if (column.getType() != null) {
|
if (column.getType() != null) {
|
||||||
if (column.getType().equals("number")) {
|
if (column.getType() == FieldConfiguration.Type.NUMBER) {
|
||||||
add(column.getName(), new DoubleValidation());
|
add(column.getName(), new DoubleValidation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.getType().equals("integer")) {
|
if (column.getType() == FieldConfiguration.Type.INTEGER) {
|
||||||
add(column.getName(), new IntegerValidation());
|
add(column.getName(), new IntegerValidation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.getType().equals("date")) {
|
if (column.getType() == FieldConfiguration.Type.DATE) {
|
||||||
String format = dateFormat(column.getFormat(), "YYYY-MM-DD");
|
String format = dateFormat(column.getFormat(), "YYYY-MM-DD");
|
||||||
add(column.getName(), new DateValidation(format));
|
add(column.getName(), new DateValidation(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.getType().equals("datetime")) {
|
if (column.getType() == FieldConfiguration.Type.DATETIME) {
|
||||||
String format = dateFormat(column.getFormat(), "YYYY-MM-DDThh:mm:ssZ");
|
String format = dateFormat(column.getFormat(), "YYYY-MM-DDThh:mm:ssZ");
|
||||||
add(column.getName(), new DateValidation(format));
|
add(column.getName(), new DateValidation(format));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.getType().equals("time")) {
|
if (column.getType() == FieldConfiguration.Type.TIME) {
|
||||||
String format = dateFormat(column.getFormat(), "hh:mm:ss");
|
String format = dateFormat(column.getFormat(), "hh:mm:ss");
|
||||||
add(column.getName(), new DateValidation(format));
|
add(column.getName(), new DateValidation(format));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<?import java.net.URL?>
|
<?import java.net.URL?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.CheckBox?>
|
<?import javafx.scene.control.CheckBox?>
|
||||||
|
<?import javafx.scene.control.ComboBox?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.Spinner?>
|
<?import javafx.scene.control.Spinner?>
|
||||||
<?import javafx.scene.control.TextField?>
|
<?import javafx.scene.control.TextField?>
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import org.fxmisc.richtext.CodeArea?>
|
<?import org.fxmisc.richtext.CodeArea?>
|
||||||
|
|
||||||
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.101" xmlns:fx="http://javafx.com/fxml/1">
|
<GridPane hgap="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.76-ea" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="50.0" prefWidth="50.0" />
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="50.0" prefWidth="50.0" />
|
||||||
<ColumnConstraints hgrow="NEVER" />
|
<ColumnConstraints hgrow="NEVER" />
|
||||||
@@ -33,21 +34,15 @@
|
|||||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<children>
|
<children>
|
||||||
<Label text="%validation.rule.label.not_empty" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Label text="%validation.rule.label.not_empty" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||||
<Label text="%validation.rule.label.integer" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
|
||||||
<Label text="%validation.rule.label.double" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
|
||||||
<Label text="%validation.rule.label.minlength" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
<Label text="%validation.rule.label.minlength" GridPane.columnIndex="1" GridPane.rowIndex="6" />
|
||||||
<Label text="%validation.rule.label.maxlength" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
<Label text="%validation.rule.label.maxlength" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
||||||
<Label text="%validation.rule.label.dateformat" GridPane.columnIndex="1" GridPane.rowIndex="8" />
|
<Label text="%validation.rule.label.dateformat" GridPane.columnIndex="1" GridPane.rowIndex="8" />
|
||||||
<Label text="%validation.rule.label.alphanumeric" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
|
||||||
<Label text="%validation.rule.label.regexp" GridPane.columnIndex="1" GridPane.rowIndex="9" />
|
<Label text="%validation.rule.label.regexp" GridPane.columnIndex="1" GridPane.rowIndex="9" />
|
||||||
<Label text="%validation.rule.label.value_of" GridPane.columnIndex="1" GridPane.rowIndex="10" />
|
<Label text="%validation.rule.label.value_of" GridPane.columnIndex="1" GridPane.rowIndex="10" />
|
||||||
<Label text="%validation.rule.label.groovy" GridPane.columnIndex="1" GridPane.rowIndex="11" />
|
<Label text="%validation.rule.label.groovy" GridPane.columnIndex="1" GridPane.rowIndex="11" />
|
||||||
<Label text="%validation.rule.label.unique" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
<Label text="%validation.rule.label.unique" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||||
<CheckBox fx:id="enableNotEmptyRule" mnemonicParsing="false" GridPane.rowIndex="1" />
|
<CheckBox fx:id="enableNotEmptyRule" mnemonicParsing="false" GridPane.rowIndex="4" />
|
||||||
<CheckBox fx:id="enableIntegerRule" mnemonicParsing="false" GridPane.rowIndex="2" />
|
|
||||||
<CheckBox fx:id="enableDoubleRule" mnemonicParsing="false" GridPane.rowIndex="3" />
|
|
||||||
<CheckBox fx:id="enableAlphanumericRule" mnemonicParsing="false" GridPane.rowIndex="4" />
|
|
||||||
<CheckBox fx:id="enableUniqueRule" mnemonicParsing="false" GridPane.rowIndex="5" />
|
<CheckBox fx:id="enableUniqueRule" mnemonicParsing="false" GridPane.rowIndex="5" />
|
||||||
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" GridPane.rowIndex="6" />
|
<CheckBox fx:id="enableMinLengthRule" mnemonicParsing="false" GridPane.rowIndex="6" />
|
||||||
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
<Spinner fx:id="minLengthSpinner" GridPane.columnIndex="2" GridPane.rowIndex="6" />
|
||||||
@@ -61,9 +56,15 @@
|
|||||||
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="10" />
|
<TextField fx:id="valueOfRuleTextField" GridPane.columnIndex="2" GridPane.rowIndex="10" />
|
||||||
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" GridPane.rowIndex="11" />
|
<CheckBox fx:id="enableGroovyRule" mnemonicParsing="false" GridPane.rowIndex="11" />
|
||||||
<CodeArea fx:id="groovyRuleTextArea" prefHeight="300.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="11" GridPane.rowSpan="2" />
|
<CodeArea fx:id="groovyRuleTextArea" prefHeight="300.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="11" GridPane.rowSpan="2" />
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.active" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.active" GridPane.rowIndex="3" />
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.name" GridPane.columnIndex="1" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.name" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
<Label style="-fx-font-weight: bold;" text="%validation.rules.value" GridPane.columnIndex="2" />
|
<Label style="-fx-font-weight: bold;" text="%validation.rules.value" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
|
<Label text="Label" GridPane.columnSpan="2" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" />
|
||||||
|
<Label text="Label" GridPane.columnSpan="2" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" />
|
||||||
|
<ComboBox fx:id="typeComboBox" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" GridPane.vgrow="NEVER">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</GridPane.margin></ComboBox>
|
||||||
|
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
<padding>
|
||||||
|
|||||||
Reference in New Issue
Block a user