Kenmegne
7 days ago 494d349fb67be74da49caae2794fda702f595fb4
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package com.megatim.fdxgenerator.forms;
 
import com.megatimfx.common.annontations.Champ;
import com.megatim.fdxgenerator.App;
import static com.megatim.fdxgenerator.App.FORMATS_DATE;
import com.megatim.fdxgenerator.enums.TypeDonnee;
import com.megatim.fdxgenerator.pojo.Delimiteur;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
 
public class StructureLigneEditFormController implements Initializable {
 
    private ObservableList<Integer> list = FXCollections.observableArrayList();
 
//    @FXML
//    private VBox formFieldContainer;
//
//    @FXML
//    private HBox dateFormatContainer;
 
    @FXML
    @Champ(mappedBy = "position", type = Integer.class)
    private ComboBox<Integer> positionComboBox;
 
    @FXML
    @Champ(mappedBy = "typeDonnee", type = TypeDonnee.class)
    private ComboBox<TypeDonnee> typeDonneeComboBox;
 
    @FXML
    @Champ(mappedBy = "code", type = String.class)
    private TextField codeTextField;
 
    @FXML
    @Champ(mappedBy = "designation", type = String.class)
    private TextField designationTextField;
 
    @FXML
    @Champ(mappedBy = "taille", type = Integer.class)
    private TextField tailleTextField;
 
    @FXML
    @Champ(mappedBy = "taillePartieDecimal", type = Integer.class)
    private TextField taillePartieDecimalTextField;
 
    @FXML
    @Champ(mappedBy = "formatDate", type = String.class)
    private ComboBox<String> formatDateComboBox;
 
    @FXML
    @Champ(mappedBy = "delimiteurDate",type = Delimiteur.class)
    private ComboBox<Delimiteur> delimiteurDateComboBox;
 
    @FXML
    @Champ(mappedBy = "delimiteurDecimal",type = Delimiteur.class)
    private ComboBox<Delimiteur> delimiteurDecimalComboBox;
 
    private Integer initialUpdateSelection;
 
    @Override
    public void initialize(URL url, ResourceBundle rb) {
 
        formatDateComboBox.setDisable(true);
        formatDateComboBox.setPromptText("Sélectionnez un élément dans la liste");
        formatDateComboBox.setItems(FXCollections.observableArrayList(
                FORMATS_DATE
        ));
 
        delimiteurDateComboBox.setDisable(true);
        delimiteurDateComboBox.setPromptText("Sélectionnez un élément dans la liste");
        delimiteurDateComboBox.setItems(FXCollections.observableArrayList(
                App.SEPARATEURS_DATE.values()
        ));
        
        taillePartieDecimalTextField.setDisable(true);
 
        delimiteurDecimalComboBox.setDisable(true);
        delimiteurDecimalComboBox.setPromptText("Sélectionnez un élément dans la liste");
        delimiteurDecimalComboBox.setItems(FXCollections.observableArrayList(
                App.SEPARATEURS_DECIMAUX.values()
        ));
 
        positionComboBox.setItems(list);
        typeDonneeComboBox.setItems(FXCollections.observableArrayList(TypeDonnee.values()));
        typeDonneeComboBox.getSelectionModel().selectFirst();
 
        tailleTextField.textProperty().addListener((observable, oldValue, newValue) -> {
            if (!newValue.matches("\\d*")) {
                tailleTextField.setText(oldValue);
            }
        });
 
        typeDonneeComboBox.setOnAction(event -> {
 
            if (typeDonneeComboBox.getValue().equals(TypeDonnee.DATE)) {
                formatDateComboBox.setDisable(false);
                delimiteurDateComboBox.setDisable(false);
            } else {
                formatDateComboBox.setDisable(true);
                delimiteurDateComboBox.setDisable(true);
            }
            
             if (typeDonneeComboBox.getValue().equals(TypeDonnee.DECIMAL)) {
                 taillePartieDecimalTextField.setDisable(false);
                 delimiteurDecimalComboBox.setDisable(false);
             } else {
                  taillePartieDecimalTextField.setDisable(true);
                 delimiteurDecimalComboBox.setDisable(true);
             }
 
        });
        
    }
 
    public void populatePositionComboBox(int positionNumber) {
        list.clear();
        for (int i = 1; i <= positionNumber; i++) {
            list.add(i);
        }
 
    }
 
    public ComboBox getFormatDateComboBox() {
        return formatDateComboBox;
    }
 
    public ComboBox<TypeDonnee> getTypeDonneeComboBox() {
        return typeDonneeComboBox;
    }
 
    public ObservableList<Integer> getList() {
        return list;
    }
 
    public ComboBox<Integer> getPositionComboBox() {
        return positionComboBox;
    }
 
    public void setInitialUpateSelection() {
 
        initialUpdateSelection = positionComboBox.getSelectionModel().getSelectedItem();
 
    }
 
    public Integer getInitialUpdateSelection() {
        return initialUpdateSelection;
    }
 
    public ComboBox<Delimiteur> getDelimiteurDateComboBox() {
        return delimiteurDateComboBox;
    }
 
    public ComboBox<Delimiteur> getDelimiteurDecimalComboBox() {
        return delimiteurDecimalComboBox;
    }
 
}