Package com.esprit.controllers.films
Class ActorController
java.lang.Object
com.esprit.controllers.films.ActorController
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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.control.Button
private javafx.scene.control.TextArea
private javafx.scene.control.TableColumn<Actor,
javafx.scene.control.Button> private javafx.scene.control.Label
private javafx.scene.control.Label
private javafx.scene.control.TableView<Actor>
private javafx.collections.transformation.FilteredList<Actor>
private javafx.scene.image.ImageView
private javafx.scene.control.TableColumn<Actor,
javafx.scene.layout.HBox> private final ConcurrentHashMap<String,
javafx.scene.image.Image> private final ExecutorService
private static final Logger
private javafx.scene.control.TextArea
private javafx.scene.control.TextField
private final Stack<ActorController.UndoableAction>
private final Stack<ActorController.UndoableAction>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
(package private) void
deleteFilm
(Long id) Deletes an actor from a table using the `delete()` method provided by the `ActorService`.private void
void
exportActors
(String filePath) Performs exportActors operation.(package private) 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`.void
importActors
(String filePath) Performs importActors operation.(package private) 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`.(package private) void
Sets up a filtered list of actors based on a searchable text field and updates a tableView with the filtered list.(package private) 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.private void
loadImageWithCache
(String url, javafx.scene.image.ImageView imageView) (package private) void
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.void
redo()
Performs redo operation.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).private void
Sets up event handlers for two table columns in a `TableView`.private void
Creates an `Alert` object and displays a message to the user.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`.void
undo()
Performs undo operation.(package private) 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.private boolean
validateImage
(File file)
-
Field Details
-
LOGGER
-
bioAcotr_textArea
private javafx.scene.control.TextArea bioAcotr_textArea -
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
-
idActor_tableColumn1
-
bioActor_tableColumn1
-
imageAcotr_ImageView1
private javafx.scene.image.ImageView imageAcotr_ImageView1 -
imageAcotr_tableColumn1
-
nomAcotr_tableColumn1
-
nomAcotr_textArea1
private javafx.scene.control.TextArea nomAcotr_textArea1 -
filteredActors
-
recherche_textField
private javafx.scene.control.TextField recherche_textField -
imageCache
-
imageLoaderService
-
undoStack
-
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
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
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
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
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
-
loadImageWithCache
-
exportActors
Performs exportActors operation. -
importActors
Performs importActors operation. -
undo
public void undo()Performs undo operation. -
redo
public void redo()Performs redo operation. -
executeAction
-
close
public void close()
-