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:
@@ -25,4 +25,6 @@ dependencies {
|
|||||||
compile group: 'de.jensd', name: 'fontawesomefx', version: '8.9'
|
compile group: 'de.jensd', name: 'fontawesomefx', version: '8.9'
|
||||||
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.11'
|
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.11'
|
||||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
|
||||||
|
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.6.2'
|
||||||
|
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import javafx.scene.text.Text;
|
|||||||
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
||||||
import ninja.javafx.smartcsv.fx.util.ColorConstants;
|
import ninja.javafx.smartcsv.fx.util.ColorConstants;
|
||||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.controlsfx.control.PopOver;
|
import org.controlsfx.control.PopOver;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -54,6 +56,8 @@ import static ninja.javafx.smartcsv.fx.util.I18nValidationUtil.getI18nValidatioM
|
|||||||
*/
|
*/
|
||||||
public class ErrorSideBar extends Region {
|
public class ErrorSideBar extends Region {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(ErrorSideBar.class);
|
||||||
|
|
||||||
private static final double WIDTH = 20.0;
|
private static final double WIDTH = 20.0;
|
||||||
private static final int BORDER = 8;
|
private static final int BORDER = 8;
|
||||||
private static final double STATUS_BLOCK_HEIGHT = WIDTH - BORDER;
|
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);
|
statusBlock.setStyle("-fx-background-color: " + ERROR_COLOR);
|
||||||
|
|
||||||
int rows = model.get().getRows().size();
|
int rows = model.get().getRows().size();
|
||||||
double space = heightWithoutStatusBlock() / rows;
|
double space = (double)heightWithoutStatusBlock() / rows;
|
||||||
for (ValidationError error : errorList) {
|
for (ValidationError error : errorList) {
|
||||||
errorMarkerList.add(generateErrorMarker(space, error));
|
errorMarkerList.add(generateErrorMarker(space, error));
|
||||||
}
|
}
|
||||||
@@ -147,6 +151,8 @@ public class ErrorSideBar extends Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Region generateErrorMarker(double space, ValidationError error) {
|
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();
|
Region errorMarker = new Region();
|
||||||
errorMarker.setLayoutY(space * error.getLineNumber() + STATUS_BLOCK_OFFSET);
|
errorMarker.setLayoutY(space * error.getLineNumber() + STATUS_BLOCK_OFFSET);
|
||||||
errorMarker.setPrefSize(WIDTH, 2);
|
errorMarker.setPrefSize(WIDTH, 2);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import javafx.collections.ObservableList;
|
|||||||
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
import ninja.javafx.smartcsv.validation.ValidationConfiguration;
|
||||||
import ninja.javafx.smartcsv.validation.ValidationError;
|
import ninja.javafx.smartcsv.validation.ValidationError;
|
||||||
import ninja.javafx.smartcsv.validation.Validator;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -41,6 +43,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class CSVModel {
|
public class CSVModel {
|
||||||
|
|
||||||
|
private static final Logger logger = LogManager.getLogger(CSVModel.class);
|
||||||
|
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
private ObservableList<CSVRow> rows = FXCollections.observableArrayList();
|
private ObservableList<CSVRow> rows = FXCollections.observableArrayList();
|
||||||
private String[] header;
|
private String[] header;
|
||||||
@@ -103,6 +107,8 @@ public class CSVModel {
|
|||||||
public void revalidate() {
|
public void revalidate() {
|
||||||
validationError.clear();
|
validationError.clear();
|
||||||
|
|
||||||
|
logger.info("revalidate: hasValidator -> {}", hasValidator());
|
||||||
|
|
||||||
if (!hasValidator()) return;
|
if (!hasValidator()) return;
|
||||||
|
|
||||||
List<ValidationError> errors = new ArrayList<>();
|
List<ValidationError> errors = new ArrayList<>();
|
||||||
@@ -110,6 +116,7 @@ public class CSVModel {
|
|||||||
if (header != null) {
|
if (header != null) {
|
||||||
ValidationError headerError = validator.isHeaderValid(header);
|
ValidationError headerError = validator.isHeaderValid(header);
|
||||||
if (headerError != null) {
|
if (headerError != null) {
|
||||||
|
logger.info("revalidate: header error found");
|
||||||
errors.add(headerError);
|
errors.add(headerError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,6 +130,7 @@ public class CSVModel {
|
|||||||
if (validator != null) {
|
if (validator != null) {
|
||||||
ValidationError validationError = validator.isValid(column, value.getValue(), lineNumber);
|
ValidationError validationError = validator.isValid(column, value.getValue(), lineNumber);
|
||||||
if (validationError != null) {
|
if (validationError != null) {
|
||||||
|
logger.info("revalidate: {} errors found in line {}", validationError.getMessages().size(), lineNumber);
|
||||||
errors.add(validationError);
|
errors.add(validationError);
|
||||||
value.setValidationError(validationError);
|
value.setValidationError(validationError);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
26
src/main/resources/log4j2.xml
Normal file
26
src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="error">
|
||||||
|
|
||||||
|
<Properties>
|
||||||
|
<Property name="filename">smartcsv.log</Property>
|
||||||
|
</Properties>
|
||||||
|
<ThresholdFilter level="trace"/>
|
||||||
|
|
||||||
|
<Appenders>
|
||||||
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
<File name="File" fileName="${filename}" bufferedIO="true">
|
||||||
|
<PatternLayout>
|
||||||
|
<pattern>%d %p %C{1.} [%t] %m%n</pattern>
|
||||||
|
</PatternLayout>
|
||||||
|
</File>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="error">
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
|
<AppenderRef ref="Console"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
Reference in New Issue
Block a user