mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
found rounding bug in ErrorSideBar when the number of rows is greater than height of application
This commit is contained in:
@@ -38,6 +38,8 @@ import javafx.scene.text.Text;
|
||||
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
||||
import ninja.javafx.smartcsv.fx.util.ColorConstants;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.controlsfx.control.PopOver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -54,6 +56,8 @@ import static ninja.javafx.smartcsv.fx.util.I18nValidationUtil.getI18nValidatioM
|
||||
*/
|
||||
public class ErrorSideBar extends Region {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(ErrorSideBar.class);
|
||||
|
||||
private static final double WIDTH = 20.0;
|
||||
private static final int BORDER = 8;
|
||||
private static final double STATUS_BLOCK_HEIGHT = WIDTH - BORDER;
|
||||
@@ -133,7 +137,7 @@ public class ErrorSideBar extends Region {
|
||||
statusBlock.setStyle("-fx-background-color: " + ERROR_COLOR);
|
||||
|
||||
int rows = model.get().getRows().size();
|
||||
double space = heightWithoutStatusBlock() / rows;
|
||||
double space = (double)heightWithoutStatusBlock() / rows;
|
||||
for (ValidationError error : errorList) {
|
||||
errorMarkerList.add(generateErrorMarker(space, error));
|
||||
}
|
||||
@@ -147,6 +151,8 @@ public class ErrorSideBar extends Region {
|
||||
}
|
||||
|
||||
private Region generateErrorMarker(double space, ValidationError error) {
|
||||
logger.info("generate error marker for {} errors in line {}", error.getMessages().size(), error.getLineNumber());
|
||||
logger.info("layout y is set to {}", (space * error.getLineNumber() + STATUS_BLOCK_OFFSET));
|
||||
Region errorMarker = new Region();
|
||||
errorMarker.setLayoutY(space * error.getLineNumber() + STATUS_BLOCK_OFFSET);
|
||||
errorMarker.setPrefSize(WIDTH, 2);
|
||||
|
||||
@@ -31,6 +31,8 @@ import javafx.collections.ObservableList;
|
||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||
import ninja.javafx.smartcsv.validation.Validator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -41,6 +43,8 @@ import java.util.List;
|
||||
*/
|
||||
public class CSVModel {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(CSVModel.class);
|
||||
|
||||
private Validator validator;
|
||||
private ObservableList<CSVRow> rows = FXCollections.observableArrayList();
|
||||
private String[] header;
|
||||
@@ -103,6 +107,8 @@ public class CSVModel {
|
||||
public void revalidate() {
|
||||
validationError.clear();
|
||||
|
||||
logger.info("revalidate: hasValidator -> {}", hasValidator());
|
||||
|
||||
if (!hasValidator()) return;
|
||||
|
||||
List<ValidationError> errors = new ArrayList<>();
|
||||
@@ -110,6 +116,7 @@ public class CSVModel {
|
||||
if (header != null) {
|
||||
ValidationError headerError = validator.isHeaderValid(header);
|
||||
if (headerError != null) {
|
||||
logger.info("revalidate: header error found");
|
||||
errors.add(headerError);
|
||||
}
|
||||
}
|
||||
@@ -123,6 +130,7 @@ public class CSVModel {
|
||||
if (validator != null) {
|
||||
ValidationError validationError = validator.isValid(column, value.getValue(), lineNumber);
|
||||
if (validationError != null) {
|
||||
logger.info("revalidate: {} errors found in line {}", validationError.getMessages().size(), lineNumber);
|
||||
errors.add(validationError);
|
||||
value.setValidationError(validationError);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user