add support for i18n validation messages

This commit is contained in:
Andreas Billmann
2015-12-17 20:44:07 +01:00
parent 5d53fff577
commit 9278bfa13a
9 changed files with 155 additions and 71 deletions

View File

@@ -34,7 +34,10 @@ import javafx.scene.input.KeyCode;
import ninja.javafx.smartcsv.fx.table.model.CSVRow;
import ninja.javafx.smartcsv.fx.table.model.CSVValue;
import java.util.ResourceBundle;
import static javafx.application.Platform.runLater;
import static ninja.javafx.smartcsv.fx.util.I18nValidationUtil.getI18nValidatioMessage;
/**
* Created by Andreas on 27.11.2015.
@@ -42,6 +45,11 @@ import static javafx.application.Platform.runLater;
public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
private ValueTextField textField;
private ResourceBundle resourceBundle;
public EditableValidationCell(ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
}
@Override
public void startEdit() {
@@ -69,7 +77,7 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
setTooltip(null);
} else if (item.getValidationError() != null) {
setStyle("-fx-background-color: #ff8888");
setTooltip(new Tooltip(item.getValidationError().getMessage()));
setTooltip(new Tooltip(getI18nValidatioMessage(resourceBundle, item.getValidationError().getMessages())));
}
if (item == null || empty) {

View File

@@ -32,13 +32,21 @@ import javafx.util.Callback;
import ninja.javafx.smartcsv.fx.table.model.CSVRow;
import ninja.javafx.smartcsv.fx.table.model.CSVValue;
import java.util.ResourceBundle;
/**
* Created by Andreas on 18.11.2015.
*/
public class ValidationCellFactory implements Callback<TableColumn<CSVRow, CSVValue>, TableCell<CSVRow, CSVValue>> {
private ResourceBundle resourceBundle;
public ValidationCellFactory(ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
}
@Override
public TableCell<CSVRow, CSVValue> call(TableColumn<CSVRow, CSVValue> param) {
return new EditableValidationCell();
return new EditableValidationCell(resourceBundle);
}
}