/*
|
* 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.fdxgenerator.controller.search;
|
|
import com.megatimfx.common.annontations.Search;
|
import com.megatimfx.common.customcontrols.AbstractSelectionItem;
|
import com.megatimfx.common.enums.Operateur;
|
import com.megatimfx.components.customdialogs.AlertMessageUtil;
|
import com.megatimfx.components.customdialogs.LoadinIndicatorDialogUtil;
|
import com.megatim.fdxgenerator.controller.table.TypeFichierTable;
|
import com.megatim.fdxgenerator.model.TypeFichier;
|
import com.megatim.fdxgenerator.service.TypeFichierService;
|
import java.net.URL;
|
import java.util.Arrays;
|
import java.util.HashSet;
|
import java.util.ResourceBundle;
|
import java.util.Set;
|
import javafx.concurrent.Task;
|
import javafx.fxml.FXML;
|
import javafx.fxml.Initializable;
|
import javafx.util.Pair;
|
|
/**
|
*
|
* @author STEPHANIE
|
*/
|
public class ValidateurFichierSearchFormController implements Initializable {
|
|
@Search(fieldName = "typeFichier", operateur = Operateur.EQUALS)
|
@FXML
|
private AbstractSelectionItem typeFichierAbstractSelectItem;
|
|
private TypeFichierService typeFichierService = TypeFichierService.getInstance();
|
|
//ELEMENTS DE CHARGEMENT
|
private final Set<TypeFichier> typeFichierSet = new HashSet<>();
|
|
@Override
|
public void initialize(URL location, ResourceBundle resources) {
|
typeFichierAbstractSelectItem.setTitle("Choix du type de fichier");
|
typeFichierAbstractSelectItem.setColumns(Arrays.asList(
|
TypeFichierTable.codeColumn(),
|
TypeFichierTable.libelleColumn()
|
));
|
typeFichierAbstractSelectItem.setSearchFieldPairs(Arrays.asList(
|
new Pair<>("code", "Code"),
|
new Pair<>("libelle", "Libellé")
|
));
|
initElements();
|
}
|
|
private void initElements() {
|
Task<Void> task = new Task() {
|
@Override
|
protected Object call() throws Exception {
|
typeFichierSet.clear();
|
typeFichierSet.addAll(typeFichierService.getAll());
|
//typeFichierSet.addAll(typeFichierService.findAllByCategorieFichierAndTypeExtension(CategorieFichier.STRUCTURE, TypeExtension.TEXTE));
|
return null;
|
}
|
};
|
task.setOnRunning(e -> LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().show());
|
task.setOnSucceeded(e -> {
|
LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().hide();
|
typeFichierAbstractSelectItem.setElements(typeFichierSet);
|
});
|
task.setOnFailed(e -> {
|
LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().hide();
|
AlertMessageUtil.showAlertException(task.getException(),
|
"Une exception s'est produite pendant le traitement", "Erreur");
|
});
|
Thread thread = new Thread(task);
|
thread.setDaemon(true);
|
thread.start();
|
}
|
|
public AbstractSelectionItem<TypeFichier> getTypeFichierAbstractSelectItem() {
|
return typeFichierAbstractSelectItem;
|
}
|
|
public void setTypeFichierAbstractSelectItem(AbstractSelectionItem<TypeFichier> typeFichierAbstractSelectItem) {
|
this.typeFichierAbstractSelectItem = typeFichierAbstractSelectItem;
|
}
|
|
}
|