mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
add support for i18n validation messages
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user