/*
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
*/
|
package com.megatim.fdxconvert.forms;
|
|
import com.megatimfx.common.annontations.Champ;
|
import com.megatim.fdxconvert.enums.JournalStatut;
|
import java.net.URL;
|
import java.time.LocalDateTime;
|
import java.time.format.DateTimeFormatter;
|
import java.util.ResourceBundle;
|
import java.util.function.UnaryOperator;
|
import javafx.fxml.FXML;
|
import javafx.fxml.Initializable;
|
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextFormatter;
|
|
/**
|
*
|
* @author ASUS
|
*/
|
public class JournalEditFormController implements Initializable {
|
|
@FXML
|
@Champ(mappedBy = "dateAction", type = java.time.LocalDateTime.class)
|
private TextField dateActionTextfield;
|
|
@FXML
|
@Champ(mappedBy = "statut", type = JournalStatut.class)
|
private TextField statutActionTextfield;
|
|
@FXML
|
@Champ(mappedBy = "codeTypefichier", type = String.class)
|
private TextField typefichierfichierTextfield;
|
|
@FXML
|
@Champ(mappedBy = "sourceDirectory")
|
private TextField sourceDirectoryTextfield;
|
|
@FXML
|
@Champ(mappedBy = "sourceFileName")
|
private TextField sourceFileNameTextfield;
|
|
@FXML
|
private TextField nombreLignesTextfield;
|
|
@FXML
|
@Champ(mappedBy = "destinationDirectory")
|
private TextField destinationDirectoryTextfield;
|
|
@FXML
|
@Champ(mappedBy = "destinationFileName")
|
private TextField destinationFileNameTextfield;
|
|
@Override
|
public void initialize(URL location, ResourceBundle resources) {
|
UnaryOperator<TextFormatter.Change> filterDate = change -> {
|
|
if (change.getControlNewText() != null && !change.getControlNewText().isEmpty()) {
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
LocalDateTime dateTime = LocalDateTime.parse(change.getControlNewText());
|
change.setText(dateTime.format(formatter));
|
|
return change;
|
} else {
|
return null;
|
}
|
};
|
TextFormatter<String> dateFormatter = new TextFormatter<>(filterDate);
|
dateActionTextfield.setTextFormatter(dateFormatter);
|
|
}
|
|
public TextField getNombreLignesTextfield() {
|
return nombreLignesTextfield;
|
}
|
|
}
|