Package View

Class AdminDashboardView

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class AdminDashboardView extends JPanel
The AdminDashboardView class represents a graphical user interface panel for the admin dashboard.

The admin dashboard view provides administrators with a user interface for managing utility bills and services. It includes multiple sections for displaying admin information, service-related controls, total bills, and a search interface for accessing specific utility bills.

See Also:
  • Field Details

    • adminInfoPanel

      private JPanel adminInfoPanel
      A panel displaying admin information, including the admin's name and email.
      See Also:
    • servicesPanel

      private JPanel servicesPanel
      A panel displaying utility services and associated information.
      See Also:
    • totalPanel

      private JPanel totalPanel
      A panel displaying the total utility bill cost.
      See Also:
    • searchResultsContainer

      private JPanel searchResultsContainer
      A panel displaying search results.
      See Also:
    • searchResults

      private JPanel searchResults
      A panel displaying search results.
      See Also:
    • app

      protected App app
      The parent application.
      See Also:
  • Constructor Details

    • AdminDashboardView

      public AdminDashboardView(App app)
      Constructs an instance of AdminDashboardView.
      Parameters:
      app - The parent application.

      This constructor initializes the admin dashboard view with various panels and components, such as the admin information panel and service-related panels.

  • Method Details

    • createContentPane

      private JPanel createContentPane()
      Creates and returns the content pane for displaying search results.

      This method generates a graphical panel, referred to as the content pane, designed to display search results in a vertical layout. The panel's background color is set to white to provide a clean and visually appealing backdrop for the search results.

      The content pane primarily contains the searchResultsContainer component, which is populated with search results. It arranges search results in a vertical stack, allowing users to scroll through a list of utility bills and related information.

      Returns:
      The content pane for displaying search results.
      See Also:
    • createAdminInfoPanel

      private JPanel createAdminInfoPanel()
      Creates and returns the admin information panel with account details and a logout button.

      This method generates a graphical panel in the user interface to display the admin's account information, including the admin's name, email, and a logout button. The admin's name is presented as a large, bold title, and the email is shown in italics. A "Logout" button is included, which allows the admin to log out of the system.

      The panel's background color is set to a specific shade of blue (hex color code: #98c1d9) to provide a visually distinct appearance for the admin information section. The layout of the panel is defined using a GroupLayout, which allows precise control over the placement and alignment of components.

      The admin's account information and the "Logout" button are aligned horizontally in the center of the panel. The button's appearance is customized by setting its background color to a dark shade (hex color code: #293241) and the text color to white, providing a clear visual cue for user interaction.

      Returns:
      The admin information panel displaying the admin's account details and a "Logout" button.
      See Also:
    • createServicesPanel

      private JPanel createServicesPanel()
      Creates and returns the services panel displaying utility services and associated information.

      This method generates a panel in the user interface that lists various utility services, including their names, service charges, and unit charges. It also includes an "Edit" button for each service, allowing administrators to modify service details.

      The services panel is organized using GridLayout, with a single row and multiple columns. Each service is displayed in a separate sub-panel, with labels indicating the service name, service charge, and unit charge. The "Edit" button is available for each service, allowing administrators to access the service editing page using the App.editServicePage(ServiceType) method.

      The services' data, such as service charges and unit charges, are fetched from the ServiceController class. The layout includes appropriate spacing and padding for a visually appealing presentation.

      Returns:
      The services panel displaying utility services, their charges, and "Edit" buttons.
      See Also:
    • createSearchBar

      private JPanel createSearchBar()
      Creates and returns the search bar panel with search input and button.

      This method creates a panel that serves as a search bar in the user interface. The search bar includes a text area where users can input search text, a "Search" button to initiate the search operation, and associated event listeners for user interaction.

      The search bar layout is based on GridBagLayout for precise placement of components. It includes a text area for entering search text, and a button to trigger the search operation. The button's action listener is set to invoke the performSearch(String) method when clicked. The text area also has a document listener to dynamically respond to changes in the search text input.

      The method sets up GridBagConstraints for fine-tuning the layout, such as adding padding around components.

      Returns:
      The search bar panel that includes a search text input area and a "Search" button.
      See Also:
    • performSearch

      private void performSearch(String searchText)
      Performs a search operation based on the provided search text.
      Parameters:
      searchText - The text to be used for searching utility bills.

      This method performs a search operation based on the provided search text. It retrieves utility bills that match the search criteria and displays the search results within the search results panel. If no matching utility bills are found, the search results panel displays a message indicating that no results were found. This method is typically triggered when the user initiates a search action within the application.

      searchText - The text used for searching utility bills.
      See Also:
    • refreshSearchResultsPanel

      private void refreshSearchResultsPanel()
      Refreshes the search results panel with updated content.

      This method updates the search results panel with new content. It removes the current content from the search results container, adds the updated search results, and then triggers a revalidation and repaint of the container to reflect the changes. This method is called to refresh the displayed search results when updates or changes occur.

      If the search results container is null or empty, no action is performed.

    • createResultsPanel

      private JPanel createResultsPanel(ArrayList<UtilityBill> bills)
      Creates a panel to display utility bill information.
      Parameters:
      bills - An ArrayList of UtilityBill objects to display.
      Returns:
      A panel displaying utility bill information or a "None" message if the list is empty.

      This method generates a panel to display detailed information about utility bills, including customer name, utility type, usage data, price, and date. If the provided bills list is empty or null, it displays a message indicating no utility bills are available. Each bill's information is enclosed in a separate sub-panel with proper spacing. The total utility bill cost is also calculated and displayed at the end of the panel.

      See Also:
    • createBillPanel

      private JPanel createBillPanel(UtilityBill bill)
      Creates a panel to display detailed information about a utility bill.
      Parameters:
      bill - A UtilityBill object containing bill information.
      bill - The UtilityBill object representing the utility bill to be displayed.
      Returns:
      A panel displaying the utility bill details.

      This method generates a panel to display detailed information about a utility bill. The information includes the customer's name, utility type, usage data, price, and date of the bill. Each piece of information is presented in a properly formatted label within the panel. This method is typically used in the context of displaying individual utility bills within a larger view.

      See Also:
    • createTotalPanel

      private JPanel createTotalPanel()
      Creates a panel to display the total utility bill cost.
      Returns:
      A panel displaying the total utility bill cost.

      This method generates a panel to display the total utility bill cost for all utility bills. It calculates the total bill cost using the StaffController.calculateTotalPrice() method and presents it in the panel with proper formatting and styling.

      See Also: