Class FilmController

java.lang.Object
com.esprit.controllers.films.FilmController

public class FilmController extends Object
JavaFX controller class for the RAKCHA application. Handles UI interactions and manages view logic using FXML.
Since:
1.0.0
Version:
1.0.0
Author:
RAKCHA Team
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • addressCheckBoxes

      private final List<javafx.scene.control.CheckBox> addressCheckBoxes
    • yearsCheckBoxes

      private final List<javafx.scene.control.CheckBox> yearsCheckBoxes
    • validator

      net.synedra.validatorfx.Validator validator
    • ajouterCinema_Button

      private javafx.scene.control.Button ajouterCinema_Button
    • annederalisationFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,Integer> annederalisationFilm_tableColumn
    • annederealisationFilm_textArea

      private javafx.scene.control.TextArea annederealisationFilm_textArea
    • descriptionFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,String> descriptionFilm_tableColumn
    • descriptionFilm_textArea

      private javafx.scene.control.TextArea descriptionFilm_textArea
    • dureeFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,Time> dureeFilm_tableColumn
    • dureeFilm_textArea

      private javafx.scene.control.TextArea dureeFilm_textArea
    • Delete_Column

      private javafx.scene.control.TableColumn<Film,javafx.scene.control.Button> Delete_Column
    • filmCategory_tableView1

      private javafx.scene.control.TableView<Film> filmCategory_tableView1
    • filmCrudInterface

      private javafx.scene.layout.AnchorPane filmCrudInterface
    • idFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,Long> idFilm_tableColumn
    • idacteurFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,org.controlsfx.control.CheckComboBox<String>> idacteurFilm_tableColumn
    • idcategoryFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,org.controlsfx.control.CheckComboBox<String>> idcategoryFilm_tableColumn
    • idcinemaFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,org.controlsfx.control.CheckComboBox<String>> idcinemaFilm_tableColumn
    • idcinemaFilm_comboBox

      private org.controlsfx.control.CheckComboBox<String> idcinemaFilm_comboBox
    • imageFilm_ImageView

      private javafx.scene.image.ImageView imageFilm_ImageView
    • imageFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,javafx.scene.layout.HBox> imageFilm_tableColumn
    • nomFilm_tableColumn

      private javafx.scene.control.TableColumn<Film,String> nomFilm_tableColumn
    • nomFilm_textArea

      private javafx.scene.control.TextArea nomFilm_textArea
    • image_view

      private javafx.scene.layout.AnchorPane image_view
    • AjouterFilm_Button

      private javafx.scene.control.Button AjouterFilm_Button
    • Categorychecj_ComboBox

      private org.controlsfx.control.CheckComboBox<String> Categorychecj_ComboBox
    • Actorcheck_ComboBox1

      private org.controlsfx.control.CheckComboBox<String> Actorcheck_ComboBox1
    • addButton

      private javafx.scene.control.Button addButton
    • addHbox

      private javafx.scene.layout.HBox addHbox
    • filteredActors

      private javafx.collections.transformation.FilteredList<Film> filteredActors
    • recherche_textField

      private javafx.scene.control.TextField recherche_textField
    • Anchore_Pane_filtrage1

      private javafx.scene.layout.AnchorPane Anchore_Pane_filtrage1
    • bouttonAnchor_outfilltrer

      private javafx.scene.control.Button bouttonAnchor_outfilltrer
    • bouttonAnchor_outfilltrer1

      private javafx.scene.control.Button bouttonAnchor_outfilltrer1
    • filteredFilms

      private javafx.collections.transformation.FilteredList<Film> filteredFilms
    • sortedFilms

      private javafx.collections.transformation.SortedList<Film> sortedFilms
  • Constructor Details

    • FilmController

      public FilmController()
  • Method Details

    • initialize

      void initialize()
      Populates a ComboBox with actor names, another with cinema names, and a third with category names. It also sets tooltips for each item and filters the actors based on user input in a text field.
    • searchActor

      private void searchActor(String searchText)
      /** Sets a predicate for the `filteredActors` list to search for an actor based on the given search text. If the search text is empty or null, it returns all actors in the list. Otherwise, it checks if the actor's name contains the lowercase version of the search text, ignoring case.
      Parameters:
      searchText - searched text, which is used to filter the `filteredActors` list by checking if an actor's name contains the search text in lower case.
    • setupAdvancedSearch

      private void setupAdvancedSearch()
    • createSearchPredicate

      private Predicate<Film> createSearchPredicate(String searchText)
    • showAlert

      private void showAlert(String message)
      /** Generates an information alert displaying a provided message.
      Parameters:
      message - information to be displayed as the content of the alert.
    • importFilmImage

      void importFilmImage(javafx.event.ActionEvent event)
      Displays a file chooser dialog to select an image file, reads the selected file, and sets the image as the Image component's source.
      Parameters:
      event - ActionEvent that triggered the execution of the `importFilmImage()` method.
    • deleteFilm

      void deleteFilm(Long id)
      Deletes a film with the specified ID from the database and displays an information alert message.
      Parameters:
      id - unique identifier of the film to be deleted.
    • insertFilm

      void insertFilm(javafx.event.ActionEvent event)
      Takes user inputted film data and validates it against predetermined criteria before inserting the film into a database.
      Parameters:
      event - action event that triggered the method to be executed, and it is not used in this case.
    • switchForm

      public void switchForm(javafx.event.ActionEvent event)
      Determines the source of an event and sets the visibility of a component based on that source.
      Parameters:
      event - event that occurred and triggered the execution of the `switchForm()` function.
    • clear

      void clear()
      Removes text and image contents from four text areas: `nomFilm`, `dureeFilm`, `descriptionFilm`, and `annederealisationFilm`.
    • updateActorlist

      void updateActorlist()
      Monitors changes to a combo box containing a list of actors and updates the actor film table accordingly, by inserting or removing actors based on the changed selection.
    • readFilmTable

      void readFilmTable()
      Populates an ObservableList of Films based on data read from the FilmService API and displays them in a tableView.
    • setupCellFactory

      private void setupCellFactory()
      Sets up cell factories for the table columns in a `TableView`. It creates `TextFieldTableCell` instances with validators for each column to check input validity during editing. Tooltips are also set up for each cell to display validation errors.
    • setupCellValueFactory

      private void setupCellValueFactory()
      Sets up cell value factories for the `id`, `nomFilm`, `idacteurFilm`, `idcinemaFilm` columns of a table. It creates and returns observable values for each column based on their respective data types and uses ListChangeListener to handle changes in the checked items in the `idacteurFilm` and `idcinemaFilm` columns.
    • setupCellOnEditCommit

      private void setupCellOnEditCommit()
      Sets event handlers for cell editing events on columns related to film details, namely "Annenderalisation", "Nom", "Description", and "Duree". These event handlers call the `handle` method when an edit commit occurs, updating the corresponding film detail field with the new value from the event.
    • updateFilm

      void updateFilm(Film film)
      Updates a film in the database using the `FilmService`, and displays an alert message with the title "Film modifiée" and content text "Film modifié !". If an error occurs, it shows an alert with the error message. Finally, it reads the film table again to reflect the update.
      Parameters:
      film - Film object that will be updated.
    • importImage

      void importImage(javafx.event.ActionEvent event)
      Imports an image file selected by the user through a file chooser and saves it to two different directories based on user preference. It then sets the imported image as the image displayable in the `imageFilm_ImageView`.
      Parameters:
      event - event object that triggered the `importImage()` method to be called, providing the source of the action that led to the file selection and import process.
    • switchtoajouterCinema

      public void switchtoajouterCinema(javafx.event.ActionEvent event)
      Loads an FXML file and displays it as a stage with a specific size.
      Parameters:
      event - triggered action event that caused the method to be called, providing the necessary context for the code inside the method to execute properly.