Class DesignProductAdminContoller

java.lang.Object
com.esprit.controllers.products.DesignProductAdminContoller

public class DesignProductAdminContoller extends Object
Is responsible for handling user interactions related to the "Products" section of the Rakcha web application. It contains several methods that handle different types of user actions, such as importing images, creating a new product, and viewing a product details page. The controller also uses FXML to load user interface elements from a file named "/ui/produits/DesignProductAdmin.fxml".
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<javafx.scene.control.CheckBox>
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.control.TableColumn<Product,Void>
     
    private javafx.scene.control.TableColumn<Product,String>
     
    private javafx.scene.control.TextArea
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.layout.AnchorPane
     
    private javafx.scene.image.ImageView
     
    private javafx.scene.control.TableColumn<Product,javafx.scene.image.ImageView>
     
    private final List<Product>
     
    private static final Logger
     
    private javafx.scene.control.ComboBox<String>
     
    private javafx.scene.control.TableColumn<Product,String>
     
    private javafx.scene.control.TableColumn<Product,String>
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TableColumn<Product,Integer>
     
    private javafx.scene.control.TableView<Product>
     
    private javafx.scene.control.TableColumn<Product,Integer>
     
    private javafx.scene.control.TextField
     
    private javafx.scene.control.TextField
     
    private File
     
    private final List<javafx.scene.control.CheckBox>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add_produit(javafx.event.ActionEvent actionEvent)
    Allows users to add a new product to a list.
    (package private) void
    1) sets the style class for the cell containing the Product object, 2) updates the graphic and text of the cell based on the Product object, and 3) makes the cell editable.
    private void
    Allows the user to select an image, then sets the selected image as the product's image using a database connection.
    (package private) void
    cinemaclient(javafx.event.ActionEvent event)
    Charges a new FXML file (`CommentaireProduct.fxml`), creates a new scene with it, and attaches the scene to a new stage.
    (package private) void
    eventClient(javafx.event.ActionEvent event)
    Loads a new FXML file "/ui//ui/DesignEvenementAdmin.fxml" and creates a new scene with it, replacing the current stage with the new scene.
    private void
    Filters a list of products based on a search query, by adding only the products that have the searched category name in their name.
    void
    filtercinema(javafx.event.ActionEvent event)
    Filters a list of cinemas based on selected categories and statuses, updates the TableView with the filtered results.
    (package private) void
    filtrer(javafx.scene.input.MouseEvent event)
    Updates the opacity and visibility of an ancestor element, sets a `CheckBox` list as visible, clears existing check boxes, retrieves unique addresses from a database, creates a `VBox` for each address, adds the `VBox` to a parent element, and makes the parent element visible.
    (package private) void
    GestionCategorie(javafx.event.ActionEvent event)
    Loads a new user interface (`DesignCategorieAdmin.fxml`) into a scene, creates a new stage with the new interface, and replaces the current stage with it, while closing the original stage.
    private List<Product>
    Retrieves a list of product categories from the service layer using the `ProductService`.
    Retrieves a list of category names from a database and returns it as a list of strings.
    private List<String>
    Streams, filters, and collects the selected addresses from the `addressCheckBoxes` array, returning a list of strings representing the selected categories.
    (package private) void
    importImage(javafx.scene.input.MouseEvent event)
    Allows the user to select an image file from a list of accepted formats, saves it to a specified directory, and sets the selected image as the `image` field's new image.
    private void
    Sets up a delete button for each item in a table, with the button's on-action triggering the deletion of the corresponding item from the data source and updating the table view accordingly.
    (package private) void
    Sets up event listeners for the `SearchBar` text property and triggers actions when the text changes.
    (package private) void
    Modifies the values of a `Product` object, such as its category, name, price, description, image, quantity, and ID, before saving the modified data to the database using a `ProductService`.
    (package private) void
    MovieClient(javafx.event.ActionEvent event)
    Loads a new user interface, creates a new stage with it, and replaces the current stage with the new one.
    (package private) void
    produitClient(javafx.event.ActionEvent event)
    Loads a new FXML interface, creates a new scene, and attaches it to a new stage, replacing the current stage.
    (package private) void
    profilclient(javafx.event.ActionEvent event)
    Appears to be a handler for an action event, likely related to the execution of client-side code.
    private void
    search(String keyword)
    Searches for products based on a given keyword, filtering an observable list of products from the `ProductService`.
    (package private) void
    selectImage(javafx.scene.input.MouseEvent event)
    Allows the user to select an image file using a FileChooser dialog.
    (package private) void
    SerieClient(javafx.event.ActionEvent event)
    Loads a new FXML view, creates a new scene and stage, and replaces the current stage with the new one.
    private void
    showAlert(String message)
    Creates an `Alert` object and displays it with a title, header text, and content text provided as arguments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • addressCheckBoxes

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

      private final List<javafx.scene.control.CheckBox> statusCheckBoxes
    • l1

      private final List<Product> l1
    • selectedFile

      private File selectedFile
    • PrixP_tableC

      private javafx.scene.control.TableColumn<Product,Integer> PrixP_tableC
    • Product_tableview

      private javafx.scene.control.TableView<Product> Product_tableview
    • descriptionP_tableC

      private javafx.scene.control.TableColumn<Product,String> descriptionP_tableC
    • descriptionP_textArea

      private javafx.scene.control.TextArea descriptionP_textArea
    • image_tableC

      private javafx.scene.control.TableColumn<Product,javafx.scene.image.ImageView> image_tableC
    • nomC_comboBox

      private javafx.scene.control.ComboBox<String> nomC_comboBox
    • nomCP_tableC

      private javafx.scene.control.TableColumn<Product,String> nomCP_tableC
    • nomP_tableC

      private javafx.scene.control.TableColumn<Product,String> nomP_tableC
    • nomP_textFiled

      private javafx.scene.control.TextField nomP_textFiled
    • prix_textFiled

      private javafx.scene.control.TextField prix_textFiled
    • quantiteP_tableC

      private javafx.scene.control.TableColumn<Product,Integer> quantiteP_tableC
    • quantiteP_textFiled

      private javafx.scene.control.TextField quantiteP_textFiled
    • image

      private javafx.scene.image.ImageView image
    • categorieList

      private javafx.scene.layout.AnchorPane categorieList
    • filterAnchor

      private javafx.scene.layout.AnchorPane filterAnchor
    • formulaire

      private javafx.scene.layout.AnchorPane formulaire
    • deleteColumn

      private javafx.scene.control.TableColumn<Product,Void> deleteColumn
  • Constructor Details

    • DesignProductAdminContoller

      public DesignProductAdminContoller()
  • Method Details

    • initialize

      void initialize()
      Sets up event listeners for the `SearchBar` text property and triggers actions when the text changes. It also reads category names from a service and adds them to a combobox, and displays the first product in the list.
    • showAlert

      private void showAlert(String message)
      Creates an `Alert` object and displays it with a title, header text, and content text provided as arguments.
      Parameters:
      message - text to be displayed as an information alert when the `showAlert()` method is called.
    • selectImage

      void selectImage(javafx.scene.input.MouseEvent event)
      Allows the user to select an image file using a FileChooser dialog. If an image is selected, it sets the `image` field to the selected image.
      Parameters:
      event - MouseEvent object that triggered the function, providing information about the mouse event that initiated the image selection process.

      Event: MouseEvent Type: Input event related to mouse actions (clicks, moves, releases, etc.) Parameters: none

    • add_produit

      public void add_produit(javafx.event.ActionEvent actionEvent)
      Allows users to add a new product to a list. It validates user input, converts prices and quantities to integers, checks for invalid input, and adds the product to the existing list.
      Parameters:
      actionEvent - event that triggered the execution of the `add_produit()` method, which in this case is a button click.

      - `actionEvent` represents an action event triggered by the user, such as clicking on a button or selecting an image. - The event may contain additional information, such as the source of the action (e.g., a button or a link) and the ID of the element that was activated.

    • modifier_produit

      void modifier_produit(Product produit)
      Modifies the values of a `Product` object, such as its category, name, price, description, image, quantity, and ID, before saving the modified data to the database using a `ProductService`.
      Parameters:
      produit - Product object to be modified, containing the product's ID, category name, nom, prix, description, image, and quantity.

      - `nouvelleCategorie`: The new category name for the product. - `nouveauNom`: The new product name. - `nouveauPrix`: The new price of the product. - `nouvelleDescription`: The new product description. - `img`: The new image associated with the product. - `nouvelleQuantite`: The new quantity of the product in stock. - `id`: The unique identifier for the product in the database.

    • afficher_produit

      void afficher_produit()
      1) sets the style class for the cell containing the Product object, 2) updates the graphic and text of the cell based on the Product object, and 3) makes the cell editable.
    • initDeleteColumn

      private void initDeleteColumn()
      Sets up a delete button for each item in a table, with the button's on-action triggering the deletion of the corresponding item from the data source and updating the table view accordingly.
    • changerImage

      private void changerImage(Product produit)
      Allows the user to select an image, then sets the selected image as the product's image using a database connection.
      Parameters:
      produit - object being updated with the selected image.

      - `produit`: A `Product` object representing the product whose image is being changed. - `image`: A string containing the URL of the existing image associated with the product.

    • GestionCategorie

      void GestionCategorie(javafx.event.ActionEvent event) throws IOException
      Loads a new user interface (`DesignCategorieAdmin.fxml`) into a scene, creates a new stage with the new interface, and replaces the current stage with it, while closing the original stage.
      Parameters:
      event - event that triggered the function, specifically the button click event that initiated the category management process.

      - `event` is an `ActionEvent` object representing the triggering event for the function.

      Throws:
      IOException
    • search

      private void search(String keyword)
      Searches for products based on a given keyword, filtering an observable list of products from the `ProductService`. It adds the filtered products to the `ProductTableView`.
      Parameters:
      keyword - search query provided by the user and is used to filter the list of products in the `produitservice.read()` method.
    • filterCategorieProducts

      private void filterCategorieProducts(String searchText)
      Filters a list of products based on a search query, by adding only the products that have the searched category name in their name.
      Parameters:
      searchText - search query entered by the user, which is used to filter the list of products in the `Product_tableview`.
    • getAllCategories

      private List<Product> getAllCategories()
      Retrieves a list of product categories from the service layer using the `ProductService`. The returned list contains all product categories.
    • filtrer

      void filtrer(javafx.scene.input.MouseEvent event)
      Updates the opacity and visibility of an ancestor element, sets a `CheckBox` list as visible, clears existing check boxes, retrieves unique addresses from a database, creates a `VBox` for each address, adds the `VBox` to a parent element, and makes the parent element visible.
      Parameters:
      event - MouseEvent that triggered the function execution and provides information about the event, such as the button that was clicked or the location of the click within the screen.

      - `event` is an instance of `MouseEvent`, which represents a mouse event such as a click or a drag. - The event may have various properties such as the `button` (which button was clicked), `clickCount` (the number of times the button was clicked), and `location` (the coordinates of the event).

    • getProductCategory

      public List<String> getProductCategory()
      Retrieves a list of category names from a database and returns it as a list of strings.
    • filtercinema

      public void filtercinema(javafx.event.ActionEvent event)
      Filters a list of cinemas based on selected categories and statuses, updates the TableView with the filtered results.
      Parameters:
      event - action event that triggers the execution of the `filtercinema()` method.

      - Type: ActionEvent, indicating that the event was triggered by an action (e.g., button click) - Source: the object that generated the event (e.g., a button)

      In summary, `event` is an instance of the ActionEvent class, providing information about the source and type of the event.

    • getSelectedCategories

      private List<String> getSelectedCategories()
      Streams, filters, and collects the selected addresses from the `addressCheckBoxes` array, returning a list of strings representing the selected categories.
    • cinemaclient

      void cinemaclient(javafx.event.ActionEvent event)
      Charges a new FXML file (`CommentaireProduct.fxml`), creates a new scene with it, and attaches the scene to a new stage. It then closes the current stage and shows the new one.
      Parameters:
      event - ActionEvent object that triggered the function execution, providing information about the source of the event and allowing the function to handle the appropriate action.

      - `event`: an ActionEvent object representing a user action that triggered the function.

    • eventClient

      void eventClient(javafx.event.ActionEvent event)
      Loads a new FXML file "/ui//ui/DesignEvenementAdmin.fxml" and creates a new scene with it, replacing the current stage with the new scene.
      Parameters:
      event - ActionEvent object that triggered the event handling, providing the source of the event and allowing the code to access the relevant information.

      - `event` is an `ActionEvent` representing a user action that triggered the function execution. - The source of the event is the element in the UI that was interacted with by the user, which is passed as the parameter to the function.

    • produitClient

      void produitClient(javafx.event.ActionEvent event)
      Loads a new FXML interface, creates a new scene, and attaches it to a new stage, replacing the current stage.
      Parameters:
      event - ActionEvent object triggered by the user's action, which initiates the code execution and loads the new interface in the scene.

      - It is an instance of `ActionEvent`, which represents an event triggered by a user action on a JavaFX component. - The source of the event is typically a button or other control that initiated the action.

    • profilclient

      void profilclient(javafx.event.ActionEvent event)
      Appears to be a handler for an action event, likely related to the execution of client-side code. It does not contain any explicit logic or functionality beyond calling the default behavior of the `void` return type.
      Parameters:
      event - occurrence of an action event that triggered the execution of the `profilclient` method.
    • MovieClient

      void MovieClient(javafx.event.ActionEvent event)
      Loads a new user interface, creates a new stage with it, and replaces the current stage with the new one.
      Parameters:
      event - ActionEvent object that triggered the `MovieClient()` method, providing information about the action that was performed, such as the source of the event and the type of event.

      - Event type: The event type is `ActionEvent`, indicating that the event was triggered by an action (such as clicking a button or pressing a key).

    • SerieClient

      void SerieClient(javafx.event.ActionEvent event)
      Loads a new FXML view, creates a new scene and stage, and replaces the current stage with the new one.
      Parameters:
      event - ActionEvent that triggered the function, providing information about the source of the event and any relevant data.

      - Event source: The object that generated the event. - Type of event: The type of event (e.g., button click, window closing).

    • importImage

      void importImage(javafx.scene.input.MouseEvent event)
      Allows the user to select an image file from a list of accepted formats, saves it to a specified directory, and sets the selected image as the `image` field's new image.
      Parameters:
      event - MouseEvent object that triggered the function's execution and provides information about the user's action, such as the button that was clicked or the position of the mouse pointer, which is not used in this particular function.

      - `MouseEvent event`: represents an event generated by a mouse button press or release, or a mouse move.