Class ChatSetupController
- Direct Known Subclasses:
ChatCreateController
,ChatUpdateController
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 Summary
FieldsModifier and TypeFieldDescriptionprotected javafx.scene.layout.Pane
protected final ChatDAO
protected javafx.scene.control.TextField
protected javafx.scene.control.TextField
protected final User
protected final SQLiteConnection
protected javafx.scene.control.Button
protected javafx.scene.control.ComboBox
<String> protected javafx.scene.control.Button
protected final MessageDAO
protected javafx.scene.control.ComboBox
<String> protected javafx.scene.control.Slider
protected javafx.scene.control.ComboBox
<String> protected javafx.scene.control.Label
protected javafx.scene.control.Button
protected final UserDAO
-
Constructor Summary
ConstructorsConstructorDescriptionChatSetupController
(SQLiteConnection db, User authenticatedUser) Constructs a ChatSetupController with a database connection and authenticated user. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Navigates back to the chat screen for the current user.protected void
Initiates the download of chat messages for the current chat as a text file.protected abstract Chat
Abstract method to get the current chat context.void
Initializes the chat setup screen’s UI components and event handlers.protected abstract void
Abstract method to set up the confirm chat button.
-
Field Details
-
responseAttitude
-
educationLevel
-
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
-
currentUser
-
userDAO
-
chatDAO
-
messageDAO
-
-
Constructor Details
-
ChatSetupController
public ChatSetupController(SQLiteConnection db, User authenticatedUser) throws IllegalStateException, RuntimeException, SQLException Constructs a ChatSetupController with a database connection and authenticated user.Initializes the
db
connection, sets thecurrentUser
, and creates instances ofUserDAO
,ChatDAO
, andMessageDAO
. Throws an exception if the user is null.- Parameters:
db
- The SQLite database connectionauthenticatedUser
- 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 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 usingMessageDAO
, formats them into a text file, and prompts the user to save it using aFileChooser
. Displays alerts for no chat selected, no messages, or successful/failed operations. Subclasses are responsible for providing the chat context. -
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
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:
-