From 494d349fb67be74da49caae2794fda702f595fb4 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 16:29:11 +0000
Subject: [PATCH] rename packages

---
 fdx_generator/src/main/java/com/megatim/fdxgenerator/controller/StructureLigneEditDialogController.java |  204 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 204 insertions(+), 0 deletions(-)

diff --git a/fdx_generator/src/main/java/com/megatim/fdxgenerator/controller/StructureLigneEditDialogController.java b/fdx_generator/src/main/java/com/megatim/fdxgenerator/controller/StructureLigneEditDialogController.java
new file mode 100644
index 0000000..2e22aa2
--- /dev/null
+++ b/fdx_generator/src/main/java/com/megatim/fdxgenerator/controller/StructureLigneEditDialogController.java
@@ -0,0 +1,204 @@
+package com.megatim.fdxgenerator.controller;
+
+import com.megatimfx.common.abstracts.AbstractEditDialogController;
+import com.megatimfx.common.customdialogs.LoadinIndicatorDialogUtil;
+import com.megatimfx.common.dialogs.NotificationDialog;
+import com.megatimfx.common.dialogs.NotificationType;
+import com.megatimfx.common.enums.TypeOperation;
+import com.megatimfx.common.utils.ViewLoaderUtil;
+import com.megatim.fdxgenerator.App;
+import com.megatim.fdxgenerator.enums.TypeDonnee;
+import com.megatim.fdxgenerator.forms.StructureLigneEditFormController;
+import com.megatim.fdxgenerator.model.StructureLigne;
+import com.megatim.fdxgenerator.model.TypeFichier;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ResourceBundle;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.scene.Node;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+
+public class StructureLigneEditDialogController extends AbstractEditDialogController<StructureLigne> {
+
+    private StructureLigneEditFormController structureLigneEditFormController;
+
+    private ObservableList<StructureLigne> selectedStructureLignes = FXCollections.observableArrayList();
+
+    private TypeFichier typeFichier;
+
+    @Override
+    public void initialize(URL url, ResourceBundle rb) {
+        super.initialize(url, rb);
+    }
+
+    @Override
+    public String getTitle() {
+        return "Editer une structure de ligne";
+    }
+
+    @Override
+    public Pane getContentFormPane() throws IOException {
+        return ViewLoaderUtil.getPaneFromFxmlFile(
+                structureLigneEditFormController.getClass().getResource("StructureLigneEditForm.fxml"),
+                structureLigneEditFormController
+        );
+    }
+
+    @Override
+    public Object getContentFormController() {
+        return structureLigneEditFormController;
+    }
+
+    @Override
+    protected void beforeBindFormFieldWithCurrentObject(StructureLigne bindObject, Object formController, TypeOperation typeOperation) {
+
+        if (formController instanceof StructureLigneEditFormController) {
+
+            if (typeOperation.equals(TypeOperation.UPDATE) || typeOperation.equals(TypeOperation.VIEW)) {
+                
+                if (bindObject.getTypeDonnee().equals(TypeDonnee.DATE) && App.SEPARATEURS_DATE.containsKey(bindObject.getSeparateurDate())) {
+                   
+                    bindObject.setDelimiteurDate(App.SEPARATEURS_DATE.get(bindObject.getSeparateurDate()));
+                }
+                if (bindObject.getTypeDonnee().equals(TypeDonnee.DECIMAL) && App.SEPARATEURS_DECIMAUX.containsKey(bindObject.getSeparateurDecimal())) {
+                   
+                    bindObject.setDelimiteurDecimal(App.SEPARATEURS_DECIMAUX.get(bindObject.getSeparateurDecimal()));
+                }
+            }
+
+        }
+    }
+
+    @Override
+    public boolean beforeSave(ActionEvent event) {
+        Boolean proceed = super.beforeSave(event);
+        StringBuilder message = new StringBuilder(0);
+
+        if (proceed) {
+
+            if (getCurrentObject().getTypeDonnee().equals(TypeDonnee.DATE)) {
+
+                boolean proceed1 = getCurrentObject().getFormatDate() != null
+                        && getCurrentObject().getTaille() == getCurrentObject().getFormatDate().length();
+
+                proceed = proceed && proceed1;
+
+                if (!proceed1) {
+                    message.append("Le format de la date est obligatoire et sa taille doit être égale à la taille du champ\n");
+                }
+
+                boolean proceedSeparateurDate = getCurrentObject().getDelimiteurDate() != null;
+                proceed = proceed && proceedSeparateurDate;
+
+                if (proceedSeparateurDate) {
+                    getCurrentObject().setSeparateurDate(getCurrentObject().getDelimiteurDate().getCode());
+                } else {
+                    message.append("Le séparateur de date est obligatoire\n");
+                }
+
+            }
+
+            if (getCurrentObject().getTypeDonnee().equals(TypeDonnee.DECIMAL)) {
+
+                boolean proceedSeparateurDecimal = getCurrentObject().getDelimiteurDecimal() != null;
+                proceed = proceed && proceedSeparateurDecimal;
+
+                if (proceedSeparateurDecimal) {
+                    getCurrentObject().setSeparateurDecimal(getCurrentObject().getDelimiteurDecimal().getCode());
+                } else {
+                    message.append("Le séparateur de décimal est obligatoire\n");
+                }
+
+                boolean proceedTailleDecimal = getCurrentObject().getTaillePartieDecimal() > 1;
+                proceed = proceed && proceedTailleDecimal;
+
+                if (!proceedTailleDecimal) {
+                    message.append("La taille de la partie entière doit être supérieure à 0");
+                }
+            }
+        }
+
+        if (!proceed && !message.toString().isEmpty()) {
+
+            LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().hide();
+            Node source = (Node) event.getSource();
+            Stage parentStage = (Stage) source.getScene().getWindow();
+            NotificationDialog notificationDialog = new NotificationDialog(
+                    message.toString(),
+                    NotificationType.ERROR,
+                    parentStage
+            );
+
+            notificationDialog.showNotification();
+        }
+
+        return proceed;
+    }
+
+    @Override
+    protected void afterBindCurrentObjectWithFormField(StructureLigne bindObject, Object formController, TypeOperation typeOperation) {
+        if (formController instanceof StructureLigneEditFormController) {
+            if (typeFichier != null) {
+                bindObject.setId(typeFichier + "" + bindObject.getPosition());
+            }
+        }
+    }
+
+    public StructureLigneEditFormController getStructureLigneEditFormController() {
+        return structureLigneEditFormController;
+    }
+
+    public void setStructureLigneEditFormController(StructureLigneEditFormController structureLigneEditFormController) {
+        this.structureLigneEditFormController = structureLigneEditFormController;
+    }
+
+    public void setTypeFichier(TypeFichier typeFichier) {
+        this.typeFichier = typeFichier;
+    }
+
+    public void setSelectedStructureLignes(ObservableList<StructureLigne> selectedStructureLignes) {
+        this.selectedStructureLignes = selectedStructureLignes;
+    }
+
+    @Override
+    public void afterSave(ActionEvent event, Object formController, TypeOperation typeOperation) {
+
+        StructureLigneEditFormController controller = (StructureLigneEditFormController) formController;
+
+        if (getTypeOperation().equals(TypeOperation.UPDATE)) {
+
+            boolean exists = false;
+
+            ObservableList<Integer> liste = controller.getList();
+
+            for (Integer i : liste) {
+
+                if (i.equals(controller.getInitialUpdateSelection())) {
+
+                    exists = true;
+
+                    break;
+                }
+            }
+
+            if (!exists) {
+
+                liste.add(controller.getInitialUpdateSelection());
+            }
+        }
+    }
+
+    @Override
+    protected void afterBindFormFieldWithCurrentObject(StructureLigne bindObject, Object formController, TypeOperation typeOperation) {
+        StructureLigneEditFormController controller = (StructureLigneEditFormController) formController;
+
+        if (typeOperation.equals(TypeOperation.UPDATE)) {
+            controller.setInitialUpateSelection();
+
+        }
+    }
+
+}

--
Gitblit v1.10.0