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/forms/ModeleJsonEditFormController.java | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 254 insertions(+), 0 deletions(-)
diff --git a/fdx_convert/src/main/java/com/megatim/fdxconvert/forms/ModeleJsonEditFormController.java b/fdx_convert/src/main/java/com/megatim/fdxconvert/forms/ModeleJsonEditFormController.java
new file mode 100644
index 0000000..ab121f8
--- /dev/null
+++ b/fdx_convert/src/main/java/com/megatim/fdxconvert/forms/ModeleJsonEditFormController.java
@@ -0,0 +1,254 @@
+/*
+ * 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.forms;
+
+import com.megatimfx.common.annontations.Champ;
+import com.megatimfx.common.customcontrols.AbstractNestedEntityTable;
+import com.megatimfx.common.customcontrols.AbstractSelectionItem;
+import com.megatimfx.components.customdialogs.AlertMessageUtil;
+import com.megatimfx.components.customdialogs.LoadinIndicatorDialogUtil;
+import com.megatimfx.common.abstracts.AbstractEditDialogController;
+import com.megatimfx.common.abstracts.context.AbstractViewContext;
+import com.megatimfx.common.enums.TypeOperation;
+import com.megatim.fdxconvert.controller.MainController;
+import com.megatim.fdxconvert.controller.SubObjectEditDialogController;
+import com.megatim.fdxconvert.controller.table.StructureChampJsonTable;
+import com.megatim.fdxconvert.controller.table.TypeFichierTable;
+import com.megatim.fdxconvert.model.ModeleJson;
+import com.megatim.fdxconvert.model.StructureChampJson;
+import com.megatim.fdxconvert.model.SubObject;
+import com.megatim.fdxconvert.model.TypeFichier;
+import com.megatim.fdxconvert.service.TypeFichierService;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.beans.property.Property;
+import javafx.beans.property.SimpleObjectProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.concurrent.Task;
+import javafx.event.Event;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.fxml.Initializable;
+import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableRow;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextField;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.stage.Modality;
+import javafx.stage.Stage;
+import javafx.stage.StageStyle;
+import javafx.util.Pair;
+
+/**
+ *
+ * @author ASUS
+ */
+public class ModeleJsonEditFormController implements Initializable {
+
+ @FXML
+ @Champ(mappedBy = "typeFichier", type = TypeFichier.class, update = false)
+ private AbstractSelectionItem<TypeFichier> typeFichierAbstractSelectItem;
+
+ @FXML
+ @Champ(mappedBy = "objectName", type = String.class, update = false)
+ private TextField objectNameTextField;
+
+ @FXML
+ @Champ(mappedBy = "listeStructureJson", type = StructureChampJson.class, update = true)
+ private AbstractNestedEntityTable<StructureChampJson, ModeleJson> structureChampAbstractTable;
+
+ @FXML
+ private Button subTypeAddButton;
+
+ @FXML
+ private Button subTypeUpdateButton;
+
+ @FXML
+ private Button subTypeDeleteButton;
+
+ @FXML
+ private TableView subObjetsTableView;
+
+ @FXML
+ private TableColumn subObjectTableColumn;
+
+ private final Set<TypeFichier> typeFichierSet = new HashSet<>();
+
+ private ObservableList<SubObject> subObjectListe = FXCollections.observableArrayList();
+ private Property<ObservableList<SubObject>> subModeleJsonListeProperty = new SimpleObjectProperty<>(subObjectListe);
+
+ @Override
+ public void initialize(URL url, ResourceBundle rb) {
+
+ initSubObjetsTableView();
+
+ objectNameTextField.setText("");
+
+ 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é")
+ ));
+
+ structureChampAbstractTable.setClazz(StructureChampJson.class);
+ structureChampAbstractTable.setParentFieldName("modeleJson");
+ structureChampAbstractTable.setColums(Arrays.asList(
+ StructureChampJsonTable.codeColumn(),
+ StructureChampJsonTable.typeDonneeColumn(),
+ StructureChampJsonTable.simpleOrListeColumn()
+ ));
+
+ subTypeAddButton.setOnAction(event -> {
+ openSubObjectDialog(event, new SubObject(), TypeOperation.ADD);
+ });
+
+ subTypeUpdateButton.setOnMouseClicked(event -> {
+ updateSubObject(event);
+ });
+
+ subObjetsTableView.setRowFactory(rf -> {
+
+ TableRow<SubObject> row = new TableRow<>();
+ row.setOnMouseClicked(event -> {
+ if (event.getClickCount() == 2 && (!row.isEmpty())) {
+ SubObject rowData = row.getItem();
+ openSubObjectDialog(event, rowData, TypeOperation.VIEW);
+ }
+ });
+
+ return row;
+ });
+
+ initElements();
+ }
+
+ public AbstractSelectionItem<TypeFichier> getTypeFichierAbstractSelectItem() {
+ return typeFichierAbstractSelectItem;
+ }
+
+ public TextField getObjectNameTextField() {
+ return objectNameTextField;
+ }
+
+ public AbstractNestedEntityTable<StructureChampJson, ModeleJson> getStructureChampAbstractTable() {
+ return structureChampAbstractTable;
+ }
+
+ public ObservableList<SubObject> getSubObjectListe() {
+ return subObjectListe;
+ }
+
+ public Button getSubTypeAddButton() {
+ return subTypeAddButton;
+ }
+
+ public Button getSubTypeUpdateButton() {
+ return subTypeUpdateButton;
+ }
+
+ public Button getSubTypeDeleteButton() {
+ return subTypeDeleteButton;
+ }
+
+ public TableView getSubObjetsTableView() {
+ return subObjetsTableView;
+ }
+
+ private void initElements() {
+ Task<Void> task = new Task() {
+ @Override
+ protected Object call() throws Exception {
+ typeFichierSet.clear();
+ typeFichierSet.addAll(TypeFichierService.getInstance().getAll());
+
+ return null;
+ }
+ };
+ task.setOnRunning(e -> LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().show());
+ task.setOnSucceeded(e -> {
+ typeFichierAbstractSelectItem.setElements(typeFichierSet);
+ LoadinIndicatorDialogUtil.getLoadingIndicatorDialog().hide();
+
+ });
+ 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();
+ }
+
+ private void initSubObjetsTableView() {
+
+ subObjetsTableView.itemsProperty().bind(subModeleJsonListeProperty);
+ subObjectTableColumn.setCellValueFactory(new PropertyValueFactory<SubObject, String>("subObjectName"));
+ }
+
+ private void openSubObjectDialog(Event event, SubObject subObject, TypeOperation typeOperation) {
+ try {
+
+ FXMLLoader loader = new FXMLLoader(
+ (AbstractViewContext.getInstance().getAbstractEditDialogControllerURL() == null)
+ ? AbstractEditDialogController.class.getResource("AbstractEditDialog.fxml")
+ : AbstractViewContext.getInstance().getAbstractEditDialogControllerURL()
+ );
+ SubObjectEditDialogController controller = new SubObjectEditDialogController();
+ controller.setModeleJsonEditFormController(this);
+ controller.setSubObjectsList(subObjectListe);
+
+ loader.setControllerFactory(param -> controller);
+
+ Parent root = loader.load();
+ Node source = (Node) event.getSource();
+
+ Stage parentStage = (Stage) source.getScene().getWindow();
+
+ controller.initData(parentStage, typeOperation, subObject, null,
+ subObjectListe, true);
+
+ setStage(root);
+ } catch (IOException ex) {
+ Logger.getLogger(MainController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
+ }
+ }
+
+ private void updateSubObject(Event event) {
+ Object selectedItem = subObjetsTableView.getSelectionModel().getSelectedItem();
+
+ if (selectedItem != null) {
+
+ SubObject subObjectToBeUpdated = (SubObject) selectedItem;
+
+ openSubObjectDialog(event, subObjectToBeUpdated, TypeOperation.UPDATE);
+ }
+ }
+
+ private void setStage(Parent root) {
+ Scene scene = new Scene(root);
+ Stage stage = new Stage();
+
+ stage.setScene(scene);
+ stage.initStyle(StageStyle.UNDECORATED);
+ stage.initModality(Modality.APPLICATION_MODAL);
+ stage.show();
+ }
+}
--
Gitblit v1.10.0