java.lang.Object
ai.tutor.cab302exceptionalhandlers.controller.ChatSetupController
Direct Known Subclasses:
ChatCreateController, ChatUpdateController

public abstract class ChatSetupController extends Object
Abstract base class for managing the chat setup screen in the AI tutor application.

Provides shared functionality for creating or updating chats, including UI components for configuring chat settings (e.g., response attitude, quiz difficulty) and navigation back to the chat screen. Subclasses must implement setupConfirmChatButton() to handle chat creation or updates. Interacts with the database via UserDAO, ChatDAO, and MessageDAO, and uses SceneManager for navigation.

See Also:
  • Field Details

    • responseAttitude

      protected javafx.scene.control.ComboBox<String> responseAttitude
    • educationLevel

      protected javafx.scene.control.ComboBox<String> educationLevel
    • quizDifficulty

      protected javafx.scene.control.ComboBox<String> quizDifficulty
    • quizLength

      protected javafx.scene.control.Slider quizLength
    • downloadButton

      protected javafx.scene.control.Button downloadButton
    • chatNameInput

      protected javafx.scene.control.TextField chatNameInput
    • chatTopic

      protected javafx.scene.control.TextField chatTopic
    • startChatButton

      protected javafx.scene.control.Button startChatButton
    • exitButton

      protected javafx.scene.control.Button exitButton
    • backgroundOverlay

      protected javafx.scene.layout.Pane backgroundOverlay
    • settingsTitle

      protected javafx.scene.control.Label settingsTitle
    • db

      protected final SQLiteConnection db
    • currentUser

      protected final User currentUser
    • userDAO

      protected final UserDAO userDAO
    • chatDAO

      protected final ChatDAO chatDAO
    • messageDAO

      protected final MessageDAO messageDAO
  • Constructor Details

  • Method Details

    • initialize

      public void initialize()
      Initializes the chat setup screen’s UI components and event handlers.

      Sets up the confirm chat button (setupConfirmChatButton()), exit button (setupExitButton()), and background exit functionality (setupBackgroundExit()). Called automatically by JavaFX when the FXML is loaded.

    • setupConfirmChatButton

      protected abstract void setupConfirmChatButton()
      Abstract method to set up the confirm chat button.

      Subclasses must implement this method to define the behavior of startChatButton, typically handling chat creation or updates.

    • downloadChat

      protected void downloadChat()
      Initiates the download of chat messages for the current chat as a text file.

      Checks if a chat is selected using getCurrentChat(), retrieves all messages for the chat using MessageDAO, formats them into a text file, and prompts the user to save it using a FileChooser. Displays alerts for no chat selected, no messages, or successful/failed operations. Subclasses are responsible for providing the chat context.

    • getCurrentChat

      protected abstract Chat getCurrentChat()
      Abstract method to get the current chat context.

      Subclasses must implement this method to provide the chat being edited or viewed, or return null if no chat is selected (e.g., in Create mode).

      Returns:
      The current Chat object, or null if no chat is selected
    • chatReturn

      protected void chatReturn() throws Exception
      Navigates back to the chat screen for the current user.

      Uses SceneManager to transition to the chat interface, passing the current user. Any exceptions during navigation are propagated to the caller.

      Throws:
      Exception - If navigation or scene management fails
      See Also: