Class ApplicationUIHelper

java.lang.Object
com.ntu.fdae.group1.bto.views.ApplicationUIHelper

public class ApplicationUIHelper extends Object
Helper class for application-related UI operations in the BTO Management System.

This class provides reusable UI components for handling BTO application workflows, including application submission, status viewing, withdrawal requests, and listing applications for administrative review.

The helper follows a composition pattern, working with a BaseUI instance for common UI operations and controllers for application and project data access. It is designed to be used by both applicant-focused UIs (ApplicantUI) and administrative UIs (HDBOfficerUI, HDBManagerUI) to maintain consistent user experience and reduce code duplication.

  • Constructor Details

    • ApplicationUIHelper

      public ApplicationUIHelper(BaseUI baseUI, ApplicationController appCtrl, ProjectController projCtrl, UserController userCtrl)
      Constructs a new ApplicationUIHelper with the specified dependencies.
      Parameters:
      baseUI - An instance of BaseUI for console I/O operations
      appCtrl - Controller for application-related operations
      projCtrl - Controller for project-related operations
      userCtrl - Controller for user-related operations
      Throws:
      NullPointerException - if any parameter is null
  • Method Details

    • performApplicationSubmission

      public void performApplicationSubmission(User user, String projectId)
      Guides the user through submitting an application for a specific project, including handling flat type preferences based on eligibility and availability.

      This method: - Retrieves the project details - Determines selectable flat types (eligible and available) for the user - Prompts for preference selection if multiple selectable types exist - Confirms submission with the user - Submits the application via the ApplicationController - Displays success confirmation or error messages

      Parameters:
      user - The applicant user submitting the application
      projectId - The ID of the project they are applying for
    • performViewAndWithdraw

      public void performViewAndWithdraw(User user)
      Displays the details of the applicant's current or most recent application and provides an option to request withdrawal if applicable.

      This method: - Retrieves the user's application via the ApplicationController - Displays comprehensive application details (ID, project, status, etc.) - Determines if withdrawal is allowed based on the application status - Presents withdrawal option when applicable - Delegates to performWithdrawalAction if withdrawal is chosen

      Parameters:
      user - The applicant user whose application is being viewed
    • displayApplicationList

      public Map<Integer,Application> displayApplicationList(List<Application> apps, String title)
      Displays a formatted list of applications and returns a map for selection.

      This method presents a comprehensive list of applications with key details: - Application ID - Applicant NRIC - Project name and ID - Application status (including withdrawal requests) - Flat type preference - Submission date

      The method returns a map that associates displayed index numbers with their corresponding Application objects, facilitating easy selection in calling methods.

      Parameters:
      apps - List of applications to display
      title - Title for the list header
      Returns:
      A map where keys are display indices and values are Application objects Returns an empty map if the input list is null or empty