mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 21:48:22 +02:00
unique validation has to work on the model to have the correct snapshot of the data
This commit is contained in:
@@ -39,7 +39,7 @@ import org.apache.logging.log4j.Logger;
|
||||
* The CSVModel is the client representation for the csv filepath.
|
||||
* It holds the data in rows, stores the header and manages the validator.
|
||||
*/
|
||||
public final class CSVModel {
|
||||
public final class CSVModel implements ColumnValueProvider {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(CSVModel.class);
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class CSVModel {
|
||||
* @param validationConfiguration the validator configuration for this data
|
||||
*/
|
||||
public void setValidationConfiguration(ValidationConfiguration validationConfiguration) {
|
||||
this.validator = new Validator(validationConfiguration);
|
||||
this.validator = new Validator(validationConfiguration, this);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
@@ -145,11 +145,19 @@ public final class CSVModel {
|
||||
public ValidationConfiguration createValidationConfiguration() {
|
||||
ValidationConfiguration newValidationConfiguration = new ValidationConfiguration();
|
||||
newValidationConfiguration.setHeaderNames(this.header);
|
||||
this.validator = new Validator(newValidationConfiguration);
|
||||
this.validator = new Validator(newValidationConfiguration, this);
|
||||
this.revalidate();
|
||||
return newValidationConfiguration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getValue(int row, String column) {
|
||||
return rows.get(row).getColumns().get(column).getValue().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfRows() {
|
||||
return rows.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package ninja.javafx.smartcsv.fx.table.model;
|
||||
|
||||
/**
|
||||
* interface for easier access to values in a column
|
||||
*/
|
||||
public interface ColumnValueProvider {
|
||||
|
||||
String getValue(int row, String column);
|
||||
int getNumberOfRows();
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user