Class ActorController

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

public class ActorController extends Object
Is responsible for handling user interactions related to actors in a movie database application. It provides functions to read and update actor data, as well as delete actors from the database. Additionally, it provides an event handler for switching to a new stage with a different FXML layout when the "Ajouter Cinéma" button is clicked.
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • bioAcotr_textArea

      private javafx.scene.control.TextArea bioAcotr_textArea
    • DeleteActor_Column1

      private javafx.scene.control.TableColumn<Actor,javafx.scene.control.Button> DeleteActor_Column1
    • errorBio

      private javafx.scene.control.Label errorBio
    • errorNameActor

      private javafx.scene.control.Label errorNameActor
    • AjouterFilm_Button

      private javafx.scene.control.Button AjouterFilm_Button
    • filmActor_tableView11

      private javafx.scene.control.TableView<Actor> filmActor_tableView11
    • idActor_tableColumn1

      private javafx.scene.control.TableColumn<Actor,Integer> idActor_tableColumn1
    • bioActor_tableColumn1

      private javafx.scene.control.TableColumn<Actor,String> bioActor_tableColumn1
    • imageAcotr_ImageView1

      private javafx.scene.image.ImageView imageAcotr_ImageView1
    • imageAcotr_tableColumn1

      private javafx.scene.control.TableColumn<Actor,javafx.scene.layout.HBox> imageAcotr_tableColumn1
    • nomAcotr_tableColumn1

      private javafx.scene.control.TableColumn<Actor,String> nomAcotr_tableColumn1
    • nomAcotr_textArea1

      private javafx.scene.control.TextArea nomAcotr_textArea1
    • filteredActors

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

      private javafx.scene.control.TextField recherche_textField
    • imageCache

      private final ConcurrentHashMap<String,javafx.scene.image.Image> imageCache
    • imageLoaderService

      private final ExecutorService imageLoaderService
    • undoStack

      private final Stack<ActorController.UndoableAction> undoStack
    • redoStack

      private final Stack<ActorController.UndoableAction> redoStack
  • Constructor Details

    • ActorController

      public ActorController()
  • Method Details

    • initialize

      void initialize()
      Sets up a filtered list of actors based on a searchable text field and updates a tableView with the filtered list.
    • searchActor

      private void searchActor(String searchText)
      Filters an `Actors` list based on a provided search text, returning only actors whose name contains the searched text (ignoring case).
      Parameters:
      searchText - search query that filters the actors in the `filteredActors` list.
    • importAcotrImage

      void importAcotrImage(javafx.event.ActionEvent event)
      Allows the user to select an image file, which is then copied to a specified directory and set as the image for a widget named `imageAcoter_ImageView1`.
      Parameters:
      event - open file selection event that triggered the function to execute.

      - Type: `ActionEvent` (represents an action event triggered by a user) - Target: null (indicates that the event is not associated with any specific component)

    • showAlert

      private void showAlert(String message)
      Creates an `Alert` object and displays a message to the user.
      Parameters:
      message - content to be displayed in an alert window when the `showAlert()` method is called.
    • insertActor

      void insertActor(javafx.event.ActionEvent event)
      Takes an image URL, extracts the actor's path from it, creates a new actor object with the actor's name, URI, and bio, and adds it to the ActorService using the create method. It then displays an information alert with the title "Actor ajoutée" and content text "Actor ajouté!" before refreshing the actor table.
      Parameters:
      event - user's action of clicking on the "Insert Actor" button, which triggers the function to execute and perform the actor insertion logic.

      - `event`: An `ActionEvent` object representing the user's action that triggered the function.

    • setupCellOnEditCommit

      private void setupCellOnEditCommit()
      Sets up event handlers for two table columns in a `TableView`. When an edit is committed, it updates the corresponding actor's property with the new value from the column edit.
    • importImage

      void importImage(javafx.event.ActionEvent event)
      Allows the user to select an image file from a file chooser, then saves it to two different locations and displays the image in an `ImageView`.
      Parameters:
      event - event of opening a file chooser, which triggers the code inside the function to execute when a file is selected.

      - `event`: an ActionEvent object representing the user's action of opening a file from the FileChooser.

    • updateActor

      void updateActor(Actor actor)
      Updates an actor's data in a database by first getting a connection, then calling the `update` method of the `ActorService` class and displaying an alert with the updated actor's information.
      Parameters:
      actor - Actor object to be updated.

      - `Actor actor`: The actor to be updated.

    • readActorTable

      void readActorTable()
      Reads data from an Actor database, creates a table with columns for actor name, nom, bio, and image, and displays the data in the table.
    • deleteFilm

      void deleteFilm(Long id)
      Deletes an actor from a table using the `delete()` method provided by the `ActorService`. It displays an informational alert and updates the `readActorTable()` function to reflect the change.
      Parameters:
      id - identifier of the actor to be deleted.
    • switchtoajouterCinema

      public void switchtoajouterCinema(javafx.event.ActionEvent event)
      Loads an FXML file using the `FXMLLoader` class, creates a new `AnchorPane` object, and sets it as the scene of a `Stage`.
      Parameters:
      event - action event that triggered the function execution, providing the necessary context for the code to perform its intended task.

      - `event`: An instance of `ActionEvent`, representing a user action that triggered the function to execute.

    • validateImage

      private boolean validateImage(File file)
    • loadImageWithCache

      private void loadImageWithCache(String url, javafx.scene.image.ImageView imageView)
    • exportActors

      public void exportActors(String filePath)
      Performs exportActors operation.
    • importActors

      public void importActors(String filePath)
      Performs importActors operation.
    • undo

      public void undo()
      Performs undo operation.
    • redo

      public void redo()
      Performs redo operation.
    • executeAction

      private void executeAction(ActorController.UndoableAction action)
    • close

      public void close()