diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/controller/BatchModeDialog.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/BatchModeDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..1a8e28c714ed16c234116acce46944ba01495db9 --- /dev/null +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/BatchModeDialog.java @@ -0,0 +1,76 @@ +package fr.pasteur.ida.zellige.gui.controller; + +import fr.pasteur.ida.zellige.Main; +import fr.pasteur.ida.zellige.ReferenceSurfaceExtraction; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +public class BatchModeDialog extends VBox +{ + + public BatchModeDialog() + { + + FXMLLoader fxmlLoader = new FXMLLoader( BatchModeDialog.class.getClassLoader(). + getResource( "fr.pasteur.ida.zellige.gui.view/BatchModeDialog.fxml" ) ); + fxmlLoader.setRoot(this); + fxmlLoader.setController( this ); + try + { + fxmlLoader.load(); + } + catch ( IOException e ) + { + e.printStackTrace(); + } + } + + @FXML + private TextField filePathField; // TextField to display selected file path + + private File selectedFile; // Store the selected file + + // Handle Browse Button Click + @FXML + private void handleBrowse() { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Select File"); + + // Set file filter (optional) + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Text Files", "*.csv")); + + // Open FileChooser + Stage stage = (Stage) filePathField.getScene().getWindow(); + File file = fileChooser.showOpenDialog(stage); + + if (file != null) { + selectedFile = file; + filePathField.setText(file.getAbsolutePath()); + } + } + + // Handle Run Button Click + @FXML + private void handleRun() throws Exception + { + if (selectedFile != null) { + System.out.println("Running with file: " + selectedFile.getAbsolutePath()); + ReferenceSurfaceExtraction.run(selectedFile.getAbsolutePath()); + // Add logic to process the file + } else { + System.out.println("No file selected!"); + } + } + + +} diff --git a/src/main/resources/fr.pasteur.ida.zellige.gui.view/BatchModeDialog.fxml b/src/main/resources/fr.pasteur.ida.zellige.gui.view/BatchModeDialog.fxml new file mode 100644 index 0000000000000000000000000000000000000000..31743e9ebb7cda9acdc78173b29930a51df3c241 --- /dev/null +++ b/src/main/resources/fr.pasteur.ida.zellige.gui.view/BatchModeDialog.fxml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> + +<fx:root alignment="CENTER" prefHeight="151.0" prefWidth="439.0" spacing="10" type="VBox" xmlns="http://javafx.com/javafx/23.0.1" xmlns:fx="http://javafx.com/fxml/1" > + + <Label text="Select a File" /> + + <HBox prefHeight="26.0" prefWidth="399.0" spacing="10"> + <TextField fx:id="filePathField" editable="false" prefWidth="300" /> + <Button onAction="#handleBrowse" text="Browse" /> + <padding> + <Insets left="10.0" right="10.0" /> + </padding> + </HBox> + + <Button onAction="#handleRun" text="Run" /> + +</fx:root>