Class ChatCreateController
Extends ChatSetupController
to provide functionality for creating a new
chat based on user inputs from the chat setup screen. Implements
setupConfirmChatButton()
to handle chat creation and uses
createNewChat(String, String, String, int, String, String)
to save the chat
to the database via ChatSetupController.chatDAO
. After creation, navigates back to the chat screen.
- See Also:
-
Field Summary
Fields inherited from class ai.tutor.cab302exceptionalhandlers.controller.ChatSetupController
backgroundOverlay, chatDAO, chatNameInput, chatTopic, currentUser, db, downloadButton, educationLevel, exitButton, messageDAO, quizDifficulty, quizLength, responseAttitude, settingsTitle, startChatButton, userDAO
-
Constructor Summary
ConstructorsConstructorDescriptionChatCreateController
(SQLiteConnection db, User currentUser) Constructs a ChatCreateController with a database connection and authenticated user. -
Method Summary
Modifier and TypeMethodDescriptioncreateNewChat
(String name, String responseAttitude, String quizDifficulty, int quizLength, String educationLevel, String studyArea) Creates a new chat record using user inputs from the UI.protected Chat
Abstract method to get the current chat context.void
Initializes the chat creation screen’s UI components and event handlers.protected void
Configures the confirm chat button to create a new chat.Methods inherited from class ai.tutor.cab302exceptionalhandlers.controller.ChatSetupController
chatReturn, downloadChat
-
Constructor Details
-
ChatCreateController
public ChatCreateController(SQLiteConnection db, User currentUser) throws IllegalStateException, RuntimeException, SQLException Constructs a ChatCreateController with a database connection and authenticated user.Calls the superclass constructor to initialize the database connection (
ChatSetupController.db
), current user (ChatSetupController.currentUser
), and DAO objects (ChatSetupController.userDAO
,ChatSetupController.chatDAO
,ChatSetupController.messageDAO
).- Parameters:
db
- The SQLite database connectioncurrentUser
- The currently authenticated user- Throws:
IllegalStateException
- If the user is nullRuntimeException
- If unexpected errors occur during setupSQLException
- If database initialization fails
-
-
Method Details
-
initialize
public void initialize()Initializes the chat creation screen’s UI components and event handlers.Calls the superclass’s
ChatSetupController.initialize()
method to set up shared UI components and event handlers (e.g., exit button, background overlay).- Overrides:
initialize
in classChatSetupController
-
getCurrentChat
Description copied from class:ChatSetupController
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).
- Specified by:
getCurrentChat
in classChatSetupController
- Returns:
- The current
Chat
object, or null if no chat is selected
-
setupConfirmChatButton
protected void setupConfirmChatButton()Configures the confirm chat button to create a new chat.Sets up
ChatSetupController.startChatButton
to create a new chat using user inputs fromChatSetupController.chatNameInput
,ChatSetupController.responseAttitude
,ChatSetupController.quizDifficulty
,ChatSetupController.quizLength
,ChatSetupController.educationLevel
, andChatSetupController.chatTopic
. CallscreateNewChat(String, String, String, int, String, String)
to save the chat to the database and then navigates back to the chat screen usingChatSetupController.chatReturn()
. Displays an error alert if creation fails.- Specified by:
setupConfirmChatButton
in classChatSetupController
-
createNewChat
public Chat createNewChat(String name, String responseAttitude, String quizDifficulty, int quizLength, String educationLevel, String studyArea) throws IllegalArgumentException, SQLException Creates a new chat record using user inputs from the UI.Validates the chat name, response attitude, and quiz difficulty, then creates a new
Chat
object and saves it to the database viaChatSetupController.chatDAO
. Allows optional fields (education level and study area) to be null.- Parameters:
name
- The inputted chat nameresponseAttitude
- The selected response attitudequizDifficulty
- The selected quiz difficultyquizLength
- The chosen quiz lengtheducationLevel
- The selected education level (optional)studyArea
- The inputted study area (optional)- Returns:
- The newly created
Chat
- Throws:
IllegalArgumentException
- If the chat name, response attitude, or quiz difficulty is emptySQLException
- If database operations fail
-