Class DashboardResponsableController

java.lang.Object
com.esprit.controllers.cinemas.DashboardResponsableController
All Implemented Interfaces:
javafx.fxml.Initializable

public class DashboardResponsableController extends Object implements javafx.fxml.Initializable
Is responsible for handling user interactions related to the dashboard section of the application. It provides functionality such as displaying the room form, back button, and cinema list pane, as well as handling events related to showing sessions and importing images. The class also includes methods for loading moviesessions and showing session forms.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private javafx.scene.layout.AnchorPane
     
    private de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView
     
    private de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView
     
    private javafx.scene.layout.FlowPane
     
    private javafx.scene.layout.AnchorPane
     
    private Long
     
    private javafx.scene.layout.AnchorPane
     
    (package private) CinemaManager
     
    private javafx.scene.control.TableColumn<MovieSession,Void>
     
    private javafx.scene.control.TableColumn<CinemaHall,Void>
     
    private javafx.scene.control.TableColumn<MovieSession,String>
     
    private javafx.scene.control.TableColumn<MovieSession,Date>
     
    private javafx.scene.control.TableColumn<MovieSession,Time>
     
    private javafx.scene.control.TableColumn<MovieSession,Time>
     
    private javafx.scene.control.TableColumn<MovieSession,String>
     
    private javafx.scene.control.TableColumn<MovieSession,String>
     
    private javafx.scene.control.TableColumn<CinemaHall,String>
     
    private javafx.scene.control.TableColumn<CinemaHall,Integer>
     
    private javafx.scene.control.TableColumn<MovieSession,Double>
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.DatePicker
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.image.ImageView
     
    private static final Logger
     
    private javafx.scene.control.TableView<CinemaHall>
     
    private javafx.scene.control.Button
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.control.TableView<MovieSession>
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextArea
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    addCinema(javafx.event.ActionEvent event)
    Allows users to input cinema details, including name and address.
    (package private) void
    Allows users to input cinema, film and room information, as well as a start and end time, and price.
    (package private) void
    AfficherFilmResponsable(javafx.event.ActionEvent event)
    Loads an FXML file, creates a new stage and replaces the current stage with it, displaying the contents of the FXML file on the screen.
    (package private) void
    AjouterCinemaHall(javafx.event.ActionEvent event)
    Verifies that all fields are filled, and then creates a new room in the cinema's database with the provided number of places and name, displaying an alert message after successful creation.
    (package private) void
    back(javafx.scene.input.MouseEvent event)
    Makes the `addRoomForm`, `backButton`, `RoomTableView`, and `cinemaFormPane` invisible, while making the `sessionButton` visible, when a user clicks the back button.
    (package private) void
    back2(javafx.scene.input.MouseEvent event)
    Sets the visibility of various components in a JavaFX application, including the `cinemaFormPane`, `cinemaListPane`, `sessionFormPane`, and `SessionTableView`.
    private HashSet<Cinema>
    Retrieves a list of cinemas from a service, filters them based on their status, and returns a set of accepted cinemas.
    (package private) void
    closeAnchor(javafx.event.ActionEvent event)
    Makes the `facebookAnchor` component invisible when the `Facebook` button is clicked.
    private javafx.scene.layout.HBox
    Creates a card that displays a cinema's details, including its name, capacity, and delete button.
    (package private) void
    importImage(javafx.scene.input.MouseEvent event)
    Allows the user to select an image file, then copies it to a specified directory and sets the selected image as the `image` field.
    void
    initialize(URL location, ResourceBundle resources)
    Loads accepted cinemas and sets pane visibility, adds cinema names to a combo box, and listens for selection changes to load movies and rooms for the selected cinema.
    private HashSet<Cinema>
    Loads a set of accepted cinemas from a CinemaService and displays them as cards on a flow pane.
    private void
    Reads cinemahall data from a service, filters them based on cinema Id, and displays the available rooms in a list view.
    Retrieves a list of `MovieSession` objects from an external service, converts it to an observable list, and sets it as the items of a view.
    private void
    Clears the list of movies for a specified cinema and then reads the movies from the FilmCinemaService, adding them to the combo movie list.
    private void
    Clears the items of a `JList` called `comboRoom`, then reads the rooms for a given cinema using the `CinemaHallService`, and adds the room names to the list.
    (package private) void
    PublierStatut(javafx.event.ActionEvent event)
    Posts a status update to Facebook using an access token and message from a text area.
    (package private) void
    selectImage(javafx.scene.input.MouseEvent event)
    Allows the user to select an image file, which is then copied to a specified directory and set as the image for a `Image` component.
    void
    Sets the value of the `cinemaManager` field to the input parameter `resp`.
    private void
    showAlert(String message)
    Creates an Alert object and displays a message in it using the `show()` method.
    private void
    Sets the visible state of various panes and tables within a JavaFX application, making the cinema list pane visible and the other components hidden.
    private void
    Is responsible for creating and displaying a form within a table cell to allow users to edit the cinema's information, including its name and address, as well as the names of the cinemahall and film associated with it.
    (package private) void
    showSessions(javafx.event.ActionEvent event)
    Makes the `sessionFormPane`, `SessionTableView`, and `backSession` components visible, while hiding `cinemaFormPane`, `cinemaListPane`, and `sessionButton`.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • cinemaManager

      CinemaManager cinemaManager
    • image

      private javafx.scene.image.ImageView image
    • tfAdresse

      private javafx.scene.control.TextField tfAdresse
    • tfNom

      private javafx.scene.control.TextField tfNom
    • cinemaFlowPane

      private javafx.scene.layout.FlowPane cinemaFlowPane
    • cinemaFormPane

      private javafx.scene.layout.AnchorPane cinemaFormPane
    • sessionFormPane

      private javafx.scene.layout.AnchorPane sessionFormPane
    • cinemaListPane

      private javafx.scene.layout.AnchorPane cinemaListPane
    • comboCinema

      private javafx.scene.control.ComboBox<String> comboCinema
    • comboMovie

      private javafx.scene.control.ComboBox<String> comboMovie
    • comboRoom

      private javafx.scene.control.ComboBox<String> comboRoom
    • dpDate

      private javafx.scene.control.DatePicker dpDate
    • tfDepartureTime

      private javafx.scene.control.TextField tfDepartureTime
    • tfEndTime

      private javafx.scene.control.TextField tfEndTime
    • tfPrice

      private javafx.scene.control.TextField tfPrice
    • SessionTableView

      private javafx.scene.control.TableView<MovieSession> SessionTableView
    • colAction

      private javafx.scene.control.TableColumn<MovieSession,Void> colAction
    • colCinema

      private javafx.scene.control.TableColumn<MovieSession,String> colCinema
    • colDate

      private javafx.scene.control.TableColumn<MovieSession,Date> colDate
    • colDepartTime

      private javafx.scene.control.TableColumn<MovieSession,Time> colDepartTime
    • colEndTime

      private javafx.scene.control.TableColumn<MovieSession,Time> colEndTime
    • colMovie

      private javafx.scene.control.TableColumn<MovieSession,String> colMovie
    • colMovieRoom

      private javafx.scene.control.TableColumn<MovieSession,String> colMovieRoom
    • colPrice

      private javafx.scene.control.TableColumn<MovieSession,Double> colPrice
    • addRoomForm

      private javafx.scene.layout.AnchorPane addRoomForm
    • tfNbrPlaces

      private javafx.scene.control.TextField tfNbrPlaces
    • tfNomCinemaHall

      private javafx.scene.control.TextField tfNomCinemaHall
    • cinemaId

      private Long cinemaId
    • RoomTableView

      private javafx.scene.control.TableView<CinemaHall> RoomTableView
    • colActionRoom

      private javafx.scene.control.TableColumn<CinemaHall,Void> colActionRoom
    • colNameRoom

      private javafx.scene.control.TableColumn<CinemaHall,String> colNameRoom
    • colNbrPlaces

      private javafx.scene.control.TableColumn<CinemaHall,Integer> colNbrPlaces
    • facebookAnchor

      private javafx.scene.layout.AnchorPane facebookAnchor
    • txtareaStatut

      private javafx.scene.control.TextArea txtareaStatut
    • backButton

      private de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView backButton
    • sessionButton

      private javafx.scene.control.Button sessionButton
    • backSession

      private de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView backSession
  • Constructor Details

    • DashboardResponsableController

      public DashboardResponsableController()
  • Method Details

    • setData

      public void setData(CinemaManager resp)
      Sets the value of the `cinemaManager` field to the input parameter `resp`.
      Parameters:
      resp - CinemaManager object that will be associated with the method's caller, thereby transferring ownership of the object to the method caller.
    • showAlert

      private void showAlert(String message)
      Creates an Alert object and displays a message in it using the `show()` method.
      Parameters:
      message - text to be displayed as an alert message when the `showAlert()` method is called.
    • addCinema

      void addCinema(javafx.event.ActionEvent event)
      Allows users to input cinema details, including name and address. If fields are empty, an alert is displayed. Then, a responsible cinema object is created based on ID, and the CinemaService creates a new cinema object using the provided details.
      Parameters:
      event - action event triggered by the user's click on the "Add Cinema" button, which initiates the functionality of the function.

      - `tfNom`: A text field containing the name of the cinema. - `tfAdresse`: A text field containing the address of the cinema.

    • selectImage

      void selectImage(javafx.scene.input.MouseEvent event)
      Allows the user to select an image file, which is then copied to a specified directory and set as the image for a `Image` component.
      Parameters:
      event - mouse event that triggered the function execution, providing the necessary information to determine the appropriate action to take.

      - `event`: A `MouseEvent` object representing the user's action that triggered the function.

    • initialize

      public void initialize(URL location, ResourceBundle resources)
      Loads accepted cinemas and sets pane visibility, adds cinema names to a combo box, and listens for selection changes to load movies and rooms for the selected cinema.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      location - URL of the initial page to load, which in this case is the home page with the list of cinemas.

      - `location`: A `URL` object representing the location of the application. - `resources`: A `ResourceBundle` object containing localized messages and data for the application.

      - `location`: represents the URL of the web page being loaded. - `resources`: contains resource bundles for displaying messages and other information to the user.

    • loadMoviesForCinema

      private void loadMoviesForCinema(Long cinemaId)
      Clears the list of movies for a specified cinema and then reads the movies from the FilmCinemaService, adding them to the combo movie list.
      Parameters:
      cinemaId - unique identifier of the cinema for which the movies are to be loaded.
    • loadRoomsForCinema

      private void loadRoomsForCinema(Long cinemaId)
      Clears the items of a `JList` called `comboRoom`, then reads the rooms for a given cinema using the `CinemaHallService`, and adds the room names to the list.
      Parameters:
      cinemaId - id of the cinema for which the rooms are being loaded.
    • loadAcceptedCinemas

      private HashSet<Cinema> loadAcceptedCinemas()
      Loads a set of accepted cinemas from a CinemaService and displays them as cards on a flow pane.
    • chargerAcceptedCinemas

      private HashSet<Cinema> chargerAcceptedCinemas()
      Retrieves a list of cinemas from a service, filters them based on their status, and returns a set of accepted cinemas.
    • createCinemaCard

      private javafx.scene.layout.HBox createCinemaCard(Cinema cinema)
      Creates a card that displays a cinema's details, including its name, capacity, and delete button. It also includes a Facebook icon and anchor for opening the cinema's Facebook page.
      Parameters:
      cinema - cinema object that will be deleted or updated, and is used to access its properties and methods in the function.

      - `id_cinema`: the unique identifier of the cinema - `nom_cinema`: the name of the cinema - `adresse_cinema`: the address of the cinema - `capacite_cinema`: the capacity of the cinema.

    • showCinemaList

      private void showCinemaList()
      Sets the visible state of various panes and tables within a JavaFX application, making the cinema list pane visible and the other components hidden.
    • showSessionForm

      private void showSessionForm()
      Is responsible for creating and displaying a form within a table cell to allow users to edit the cinema's information, including its name and address, as well as the names of the cinemahall and film associated with it.
    • addMovieSession

      void addMovieSession()
      Allows users to input cinema, film and room information, as well as a start and end time, and price. It then creates a new moviesession in the MovieSessionService with the relevant details.
    • loadMovieSessions

      private List<MovieSession> loadMovieSessions()
      Retrieves a list of `MovieSession` objects from an external service, converts it to an observable list, and sets it as the items of a view.
    • AjouterCinemaHall

      void AjouterCinemaHall(javafx.event.ActionEvent event)
      Verifies that all fields are filled, and then creates a new room in the cinema's database with the provided number of places and name, displaying an alert message after successful creation.
      Parameters:
      event - event of a button click and triggers the execution of the code within the function.

      - `event` is an `ActionEvent`, indicating that the method was called as a result of user action.

    • loadcinemahalls

      private void loadcinemahalls()
      Reads cinemahall data from a service, filters them based on cinema Id, and displays the available rooms in a list view.
    • closeAnchor

      void closeAnchor(javafx.event.ActionEvent event)
      Makes the `facebookAnchor` component invisible when the `Facebook` button is clicked.
      Parameters:
      event - occurrence of a button click event that triggered the function execution.
    • PublierStatut

      void PublierStatut(javafx.event.ActionEvent event)
      Posts a status update to Facebook using an access token and message from a text area.
      Parameters:
      event - action that triggered the function execution, providing the necessary context for the code to perform its intended task.

      - `txtareaStatut`: This is a text area where the status message to be published is entered by the user.

    • AfficherFilmResponsable

      void AfficherFilmResponsable(javafx.event.ActionEvent event) throws IOException
      Loads an FXML file, creates a new stage and replaces the current stage with it, displaying the contents of the FXML file on the screen.
      Parameters:
      event - event that triggered the function, specifically the button click event that initiates the display of the film management interface.

      - `event` represents an ActionEvent object, which carries information about the action that triggered the function.

      Throws:
      IOException
    • back

      void back(javafx.scene.input.MouseEvent event)
      Makes the `addRoomForm`, `backButton`, `RoomTableView`, and `cinemaFormPane` invisible, while making the `sessionButton` visible, when a user clicks the back button.
      Parameters:
      event - mouse event that triggered the execution of the `back` method.

      Event type: `MouseEvent` Target element: `backButton`

    • showSessions

      void showSessions(javafx.event.ActionEvent event)
      Makes the `sessionFormPane`, `SessionTableView`, and `backSession` components visible, while hiding `cinemaFormPane`, `cinemaListPane`, and `sessionButton`. It also calls `loadMovieSessions()` and `showSessionForm()` to display the session form and content.
      Parameters:
      event - occurrence of an action, triggering the execution of the `showSessions()` method.

      - `event` is an `ActionEvent` object representing the user action that triggered the function.

    • back2

      void back2(javafx.scene.input.MouseEvent event)
      Sets the visibility of various components in a JavaFX application, including the `cinemaFormPane`, `cinemaListPane`, `sessionFormPane`, and `SessionTableView`. It makes these components visible or invisible based on a user input event.
      Parameters:
      event - mouse event that triggered the `back2()` method, providing information about the location and type of the event.

      - Type: `MouseEvent` - Target: `cinemaFormPane` or `sessionButton` (depending on the location of the click) - Code: The button that was clicked (either `cinemaFormPane` or `sessionButton`)

    • importImage

      void importImage(javafx.scene.input.MouseEvent event)
      Allows the user to select an image file, then copies it to a specified directory and sets the selected image as the `image` field.
      Parameters:
      event - mouse event that triggered the `importImage()` method and provides the location of the selected file through its `FileChooser` object.

      - `event` is a `MouseEvent` object representing a user's interaction with the application.