Package com.esprit.controllers.films
Class CategoryController
java.lang.Object
com.esprit.controllers.films.CategoryController
Is responsible for handling user interactions with the category table. It
provides a setupCellFactory method to set up cell factories for each column
in the table, including id, nom, and description. The setupCellValueFactory
method sets the cell value factory for each column, and the
setupCellOnEditCommit method sets the on edit commit event handler for each
column. These methods work together to handle user input and updates to the
category table.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.control.Button
private javafx.scene.layout.AnchorPane
private javafx.scene.control.TableColumn<Category,
javafx.scene.control.Button> private javafx.scene.control.TextArea
private javafx.scene.control.TableView<Category>
private javafx.scene.control.ComboBox<String>
private static final Logger
private javafx.scene.control.TextArea
private javafx.scene.control.TextField
private javafx.scene.layout.StackPane
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
deleteCategory
(Long id) Deletes a category with the given ID using `CategoryService`.(package private) void
Adds a new column to a table, makes the table editable, sets up cell factories, value factories, and on-edit commit listeners.(package private) void
insertCategory
(javafx.event.ActionEvent event) Allows the user to create a new category by filling in a form with the category name and description, then calls the `create()` method of a `CategoryService` class to insert the category into the database, displays an alert message confirming the operation, and then refreshes the table displaying the categories.(package private) void
Retrieves a list of categories from a service and populates a table with them.private void
Filters and displays a list of categories based on a search query provided as an argument.private void
Sets cell factories for three table columns, `idCategory_tableColumn`, `nomCategory_tableColumn`, and `descrptionCategory_tableColumn`.private void
Sets cell edit events for two columns of a table to update the corresponding fields of a `Category` object when committed.private void
Sets cell values for four table columns in a category list by creating property value factories that return the id, description, nom, and delete buttons for each category respectively.void
switchForm
(javafx.event.ActionEvent event) Sets the visibility of an interface based on the source of the event.(package private) void
updateCategory
(Category category) Updates a specified category using the `CategoryService`, displays an alert to confirm the update, and then calls the `readCategoryTable()` function to refresh the category table.
-
Field Details
-
LOGGER
-
descriptionCategory_textArea
private javafx.scene.control.TextArea descriptionCategory_textArea -
nomCategory_textArea
private javafx.scene.control.TextArea nomCategory_textArea -
filmCategory_tableView
-
nomCategory_tableColumn
-
descrptionCategory_tableColumn
-
idCategory_tableColumn
-
delete_tableColumn
-
categoryCrudInterface
private javafx.scene.layout.AnchorPane categoryCrudInterface -
filterCriteriaComboBox
-
stackPane
private javafx.scene.layout.StackPane stackPane -
AjouterCategory_Button
private javafx.scene.control.Button AjouterCategory_Button -
recherche_textField
private javafx.scene.control.TextField recherche_textField
-
-
Constructor Details
-
CategoryController
public CategoryController()
-
-
Method Details
-
initialize
void initialize()Adds a new column to a table, makes the table editable, sets up cell factories, value factories, and on-edit commit listeners. It also reads data from a category table and provides initial values for a filter criteria combobox. -
search
Filters and displays a list of categories based on a search query provided as an argument.- Parameters:
keyword
- search query used to filter and display only relevant categories in the `filmCategory_tableView`.
-
insertCategory
void insertCategory(javafx.event.ActionEvent event) Allows the user to create a new category by filling in a form with the category name and description, then calls the `create()` method of a `CategoryService` class to insert the category into the database, displays an alert message confirming the operation, and then refreshes the table displaying the categories.- Parameters:
event
- user-generated action that triggered the function execution, allowing the code to respond accordingly.Event type: `ActionEvent` Target object: `nomCategory_textArea` and `descriptionCategory_textArea` Context: Callback function for button press
-
readCategoryTable
void readCategoryTable()Retrieves a list of categories from a service and populates a table with them. -
switchForm
public void switchForm(javafx.event.ActionEvent event) Sets the visibility of an interface based on the source of the event.- Parameters:
event
- ActionEvent object that triggered the method, providing information about the source of the event and its state.
-
deleteCategory
Deletes a category with the given ID using `CategoryService`. If successful, it displays an alert message and updates the category table.- Parameters:
id
- identity of the category to be deleted.
-
updateCategory
Updates a specified category using the `CategoryService`, displays an alert to confirm the update, and then calls the `readCategoryTable()` function to refresh the category table.- Parameters:
category
- category object to be updated.- `Category category`: Represents a single category to be updated. Its main properties include its name and any relevant subcategories.
-
setupCellFactory
private void setupCellFactory()Sets cell factories for three table columns, `idCategory_tableColumn`, `nomCategory_tableColumn`, and `descrptionCategory_tableColumn`. These factories create custom TableCells that display a text field with an error message when the user types invalid input. -
setupCellValueFactory
private void setupCellValueFactory()Sets cell values for four table columns in a category list by creating property value factories that return the id, description, nom, and delete buttons for each category respectively. -
setupCellOnEditCommit
private void setupCellOnEditCommit()Sets cell edit events for two columns of a table to update the corresponding fields of a `Category` object when committed.
-