Guest User

Untitled

a guest
Apr 19th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 KB | None | 0 0
  1. package controllers;
  2.  
  3. import app.GCUToursApp;
  4. import javafx.collections.FXCollections;
  5. import javafx.collections.ObservableList;
  6. import javafx.fxml.FXML;
  7. import javafx.fxml.FXMLLoader;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.ListView;
  10. import javafx.scene.layout.BorderPane;
  11. import javafx.stage.Stage;
  12. import model.GCUTour;
  13. import repositories.Repository;
  14. import views.RootLayoutController;
  15.  
  16. import java.io.IOException;
  17. import java.util.List;
  18.  
  19.  
  20. public class Controller {
  21.     private Stage primaryStage;
  22.     private BorderPane rootLayout;
  23.     private Repository repository;
  24.  
  25.     @FXML
  26.     ListView<GCUTour> tourListView;
  27.  
  28.     public Controller(Stage primaryStage) {
  29.         this.primaryStage = primaryStage;
  30.         this.repository = new Repository();
  31.     }
  32.  
  33.     public void initRootLayout() {
  34.         try {
  35.             FXMLLoader loader = new FXMLLoader();
  36.             loader.setLocation(GCUToursApp.class.getResource("/views/RootLayout.fxml"));
  37.             rootLayout = loader.load();
  38.  
  39.             Scene scene = new Scene(rootLayout);
  40.             primaryStage.setScene(scene);
  41.  
  42.             RootLayoutController rootLayoutController = loader.getController();
  43.             rootLayoutController.setMainController(this);
  44.             rootLayoutController.setTourListView(tourListView); // Initialize tourListView
  45.  
  46.             primaryStage.show();
  47.         } catch (IOException e) {
  48.             e.printStackTrace();
  49.         }
  50.     }
  51.  
  52.     public void listGCUTours() {
  53.         // Retrieve GCUTours from the database
  54.         List<GCUTour> gcuTours = repository.getGCUTours();
  55.  
  56.         // Update the ListView with the retrieved GCUTours
  57.         ObservableList<GCUTour> observableList = FXCollections.observableList(gcuTours);
  58.         tourListView.setItems(observableList);
  59.     }
  60.  
  61.  
  62.  
  63.     public void addGCUTourForm() {
  64.  
  65.     }
  66.  
  67.     public void addGCUTour(String tourDate, int tourDuration) {
  68.  
  69.     }
  70.  
  71.     public void addPlaceForm(int GCUTourId) {
  72.  
  73.     }
  74.  
  75.     public void addPlace(String placeName, String country, int GCUTourId) {
  76.  
  77.     }
  78.  
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment