Package com.esprit.controllers.films
Class FilmController
java.lang.Object
com.esprit.controllers.films.FilmController
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 Summary
FieldsModifier and TypeFieldDescriptionprivate org.controlsfx.control.CheckComboBox<String>
private javafx.scene.control.Button
private javafx.scene.layout.HBox
private final List<javafx.scene.control.CheckBox>
private javafx.scene.control.Button
private javafx.scene.control.Button
private javafx.scene.layout.AnchorPane
private javafx.scene.control.TextArea
private javafx.scene.control.Button
private javafx.scene.control.Button
private org.controlsfx.control.CheckComboBox<String>
private javafx.scene.control.TableColumn<Film,
javafx.scene.control.Button> private javafx.scene.control.TextArea
private javafx.scene.control.TextArea
private javafx.scene.control.TableView<Film>
private javafx.scene.layout.AnchorPane
private javafx.collections.transformation.FilteredList<Film>
private javafx.collections.transformation.FilteredList<Film>
private org.controlsfx.control.CheckComboBox<String>
private javafx.scene.layout.AnchorPane
private javafx.scene.image.ImageView
private javafx.scene.control.TableColumn<Film,
javafx.scene.layout.HBox> private static final Logger
private javafx.scene.control.TextArea
private javafx.scene.control.TextField
private javafx.collections.transformation.SortedList<Film>
(package private) net.synedra.validatorfx.Validator
private final List<javafx.scene.control.CheckBox>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
clear()
Removes text and image contents from four text areas: `nomFilm`, `dureeFilm`, `descriptionFilm`, and `annederealisationFilm`.createSearchPredicate
(String searchText) (package private) void
deleteFilm
(Long id) Deletes a film with the specified ID from the database and displays an information alert message.(package private) 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.(package private) 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.(package private) void
Populates a ComboBox with actor names, another with cinema names, and a third with category names.(package private) void
insertFilm
(javafx.event.ActionEvent event) Takes user inputted film data and validates it against predetermined criteria before inserting the film into a database.(package private) void
Populates an ObservableList of Films based on data read from the FilmService API and displays them in a tableView.private void
searchActor
(String searchText) /** Sets a predicate for the `filteredActors` list to search for an actor based on the given search text.private void
private void
Sets up cell factories for the table columns in a `TableView`.private void
Sets event handlers for cell editing events on columns related to film details, namely "Annenderalisation", "Nom", "Description", and "Duree".private void
Sets up cell value factories for the `id`, `nomFilm`, `idacteurFilm`, `idcinemaFilm` columns of a table.private void
/** Generates an information alert displaying a provided message.void
switchForm
(javafx.event.ActionEvent event) Determines the source of an event and sets the visibility of a component based on that source.void
switchtoajouterCinema
(javafx.event.ActionEvent event) Loads an FXML file and displays it as a stage with a specific size.(package private) void
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.(package private) 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é !".
-
Field Details
-
LOGGER
-
addressCheckBoxes
-
yearsCheckBoxes
-
validator
net.synedra.validatorfx.Validator validator -
ajouterCinema_Button
private javafx.scene.control.Button ajouterCinema_Button -
annederalisationFilm_tableColumn
-
annederealisationFilm_textArea
private javafx.scene.control.TextArea annederealisationFilm_textArea -
descriptionFilm_tableColumn
-
descriptionFilm_textArea
private javafx.scene.control.TextArea descriptionFilm_textArea -
dureeFilm_tableColumn
-
dureeFilm_textArea
private javafx.scene.control.TextArea dureeFilm_textArea -
Delete_Column
-
filmCategory_tableView1
-
filmCrudInterface
private javafx.scene.layout.AnchorPane filmCrudInterface -
idFilm_tableColumn
-
idacteurFilm_tableColumn
-
idcategoryFilm_tableColumn
-
idcinemaFilm_tableColumn
-
idcinemaFilm_comboBox
-
imageFilm_ImageView
private javafx.scene.image.ImageView imageFilm_ImageView -
imageFilm_tableColumn
-
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
-
Actorcheck_ComboBox1
-
addButton
private javafx.scene.control.Button addButton -
addHbox
private javafx.scene.layout.HBox addHbox -
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
-
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
/** 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
-
showAlert
/** 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
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
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.
-