Kenmegne
7 days ago b3d0580439b9a00c7eb918085de1694151066004
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * 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.controller;
 
import com.megatimfx.common.abstracts.AbstractEditDialogController;
import com.megatimfx.common.enums.TypeOperation;
import com.megatimfx.common.utils.ViewLoaderUtil;
import com.megatimfx.components.dialogs.NotificationDialog;
import com.megatimfx.components.dialogs.NotificationType;
import com.megatim.fdxconvert.forms.TypeFichierEditFormController;
import com.megatim.fdxconvert.model.TypeFichier;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
 
/**
 *
 * @author STEPHANIE
 */
public class TypeFichierEditDialogController extends AbstractEditDialogController<TypeFichier> {
 
    private TypeFichierEditFormController typeFichierEditFormController;
 
    @Override
    public String getTitle() {
        return "Edition d'un type fichier";
    }
 
    @Override
    public Pane getContentFormPane() throws IOException {
        return ViewLoaderUtil.getPaneFromFxmlFile(typeFichierEditFormController.getClass().getResource("TypeFichierEditForm.fxml"), typeFichierEditFormController);
 
    }
 
    @Override
    public Object getContentFormController() {
        return typeFichierEditFormController;
    }
 
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        typeFichierEditFormController = new TypeFichierEditFormController();
        super.initialize(url, rb);
    }
 
//    @Override
//    public boolean beforeSave(ActionEvent event) {
//        boolean proceed = super.beforeSave(event);
//
//        if (getCurrentObject().getDataType() == null) {
//
//            Node source = (Node) event.getSource();
//            Stage parentStage = (Stage) source.getScene().getWindow();
//            NotificationDialog notificationDialog = new NotificationDialog(
//                    "Le type de données est obligatoire",
//                    NotificationType.ERROR,
//                    parentStage
//            );
//            notificationDialog.showNotification();
//
//            proceed = false;
//        }
//        return proceed;
//    }
 
    @Override
    protected void afterBindFormFieldWithCurrentObject(TypeFichier bindObject, Object formController, TypeOperation typeOperation) {
 
        if (formController instanceof TypeFichierEditFormController) {
            TypeFichierEditFormController controller = (TypeFichierEditFormController) formController;
 
            if (typeOperation.equals(TypeOperation.UPDATE)) {
                controller.getCodeTextField().setDisable(true);
            }
        }
 
    }
 
    @Override
    public String getConfirmationMessage() {
        return "Type Fichier " + getCurrentObject().getCode() + "enregistré avec succès";
    }
 
}