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

---
 fdx_convert/src/main/java/com/megatim/fdxconvert/views/JsonStructureFormController.java |  133 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 133 insertions(+), 0 deletions(-)

diff --git a/fdx_convert/src/main/java/com/megatim/fdxconvert/views/JsonStructureFormController.java b/fdx_convert/src/main/java/com/megatim/fdxconvert/views/JsonStructureFormController.java
new file mode 100644
index 0000000..5620da6
--- /dev/null
+++ b/fdx_convert/src/main/java/com/megatim/fdxconvert/views/JsonStructureFormController.java
@@ -0,0 +1,133 @@
+package com.megatim.fdxconvert.views;
+
+import com.megatimfx.common.customcontrols.AbstractSelectionItem;
+import com.megatim.fdxconvert.controller.table.TypeFichierTable;
+import com.megatim.fdxconvert.model.TypeFichier;
+import com.megatim.fdxconvert.model.TypeFichierJson;
+import com.megatim.fdxconvert.viewmodel.JsonStructureFormViewModel;
+import com.megatim.fdxconvert.viewmodel.JsonStructureViewModel;
+import com.megatim.fdxconvert.views.jsonstructure.JsonStructureController;
+import com.megatim.fdxconvert.views.jsonstructure.NestedJsonStructure;
+import com.megatim.fdxconvert.views.jsonstructure.NestedJsonStructureFromJsonStructure;
+import javafx.application.Platform;
+import javafx.beans.property.ObjectProperty;
+import javafx.collections.ListChangeListener;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.fxml.Initializable;
+import javafx.scene.Parent;
+import javafx.scene.control.Button;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
+import javafx.util.Pair;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.ResourceBundle;
+import java.util.stream.Collectors;
+
+public class JsonStructureFormController implements Initializable {
+
+    @FXML
+    private VBox mainContainer;
+
+    @FXML
+    private AbstractSelectionItem<TypeFichier> typeFichierField;
+
+    @FXML
+    private HBox bottomContainer;
+
+    @FXML
+    private Button cancelButton;
+
+    @FXML
+    private Button editButton;
+
+    private final JsonStructureFormViewModel viewModel;
+
+    private final JsonStructureController jsonStructureController;
+
+    public JsonStructureFormController(TypeFichierJson typeFichierJson) {
+        NestedJsonStructure nestedJsonStructure = (typeFichierJson != null) ? new NestedJsonStructureFromJsonStructure(typeFichierJson.getJsonStructure()) : null;
+        jsonStructureController = new JsonStructureController(new JsonStructureViewModel(true, 1, nestedJsonStructure));
+        viewModel = new JsonStructureFormViewModel(typeFichierJson);
+    }
+
+    @Override
+    public void initialize(URL location, ResourceBundle resources) {
+
+        viewModel.init();
+
+        //On ferme la fenêtre si un résultat vient d'être évalué
+        viewModel.resultProperty().addListener((observable, oldValue, newValue) -> {
+            if(newValue != null) {
+                close();
+            }
+        });
+
+        initTypeFichierField();
+        loadRootJsonStructureView();
+
+        editButton.disableProperty().bind(jsonStructureController.validProperty().not());
+        editButton.setOnAction(event -> { viewModel.createTypeFichierJSON(jsonStructureController.nestedJsonStructure()); });
+
+    }
+
+    public ObjectProperty<TypeFichierJson> resultProperty() {
+        return viewModel.resultProperty();
+    }
+
+    public void close() {
+        ((Stage) mainContainer.getScene().getWindow()).close();
+    }
+
+    public void mouseDraggedTitleBar(MouseEvent mouseEvent) {
+    }
+
+    public void mousePressedTitleBar(MouseEvent mouseEvent) {
+    }
+
+    public void minimize(ActionEvent actionEvent) {
+    }
+
+    public void maximize(ActionEvent actionEvent) {
+    }
+
+    private void initTypeFichierField() {
+
+        typeFichierField.setTitle("Choix du type de fichier de la tâche");
+        typeFichierField.setColumns(Arrays.asList(TypeFichierTable.codeColumn(), TypeFichierTable.libelleColumn(), TypeFichierTable.participantColumn()));
+        typeFichierField.setSearchFieldPairs(Arrays.asList(new Pair<>("code", "Code"), new Pair<>("libelle", "Libellé")));
+
+        typeFichierField.setOldElement(viewModel.selectedTypeFichierProperty().get());
+        typeFichierField.selectedElementProperty().bindBidirectional(viewModel.selectedTypeFichierProperty());
+
+        typeFichierField.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
+            jsonStructureController.setRootStructureName((newValue != null) ? newValue.getCode() : "");
+        });
+
+        typeFichierField.setElements(viewModel.getTypeFichiers().stream().collect(Collectors.toSet()));
+        viewModel.getTypeFichiers().addListener((ListChangeListener<TypeFichier>) c -> {
+            while (c.next()) {
+                Platform.runLater(() -> typeFichierField.setElements(viewModel.getTypeFichiers().stream().collect(Collectors.toSet())));
+            }
+        });
+
+    }
+
+    private void loadRootJsonStructureView() {
+        try {
+            FXMLLoader loader = new FXMLLoader(jsonStructureController.getClass().getResource("JsonStructureView.fxml"));
+            loader.setController(jsonStructureController);
+            Parent root = loader.load();
+            mainContainer.getChildren().add(root);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

--
Gitblit v1.10.0