Merge branch 'main' into feat/chat-tests
# Conflicts: # src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/chatui/ChatBoxController.java # src/main/java/ch/unibas/dmi/dbis/cs108/casono/client/ui/chatui/ChatViewController.java
This commit is contained in:
+13
-11
@@ -21,7 +21,6 @@ import javafx.scene.control.MenuButton;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Priority;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
@@ -31,16 +30,10 @@ public class ChatBoxController {
|
||||
|
||||
private final ChatController chatController;
|
||||
|
||||
@FXML private VBox chatBox;
|
||||
|
||||
@FXML private TabPane chatTabPane;
|
||||
|
||||
@FXML private MenuButton addWhisperChatButton;
|
||||
|
||||
@FXML private HBox menuBox;
|
||||
|
||||
private FXMLLoader fxmlLoader;
|
||||
|
||||
private final List<String> activeWhisperChats;
|
||||
|
||||
@FXML private final Map<String, Tab> usernameTabMap;
|
||||
@@ -77,7 +70,7 @@ public class ChatBoxController {
|
||||
ChatModel globalChatModel = new ChatModel(global, username, -1, null);
|
||||
chatController.getChatModelMap().put(new ChatController.ChatKey(global), globalChatModel);
|
||||
addChatTab("GLOBAL", globalChatModel, global);
|
||||
addWhisperChatButton.setOnAction(event -> addWhisperChatButton.show());
|
||||
addWhisperChatButton.setOnAction(_ -> addWhisperChatButton.show());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,7 +90,7 @@ public class ChatBoxController {
|
||||
MenuItem menuItem = new MenuItem(targetUserName);
|
||||
addWhisperChatButton.getItems().add(menuItem);
|
||||
menuItem.setOnAction(
|
||||
event ->
|
||||
_ ->
|
||||
addWhisperChat(
|
||||
targetUserName,
|
||||
new ChatModel(
|
||||
@@ -131,7 +124,7 @@ public class ChatBoxController {
|
||||
if (oldUsername.equals(item.getText())) {
|
||||
item.setText(newUsername);
|
||||
item.setOnAction(
|
||||
event ->
|
||||
_ ->
|
||||
addWhisperChat(
|
||||
newUsername,
|
||||
new ChatModel(
|
||||
@@ -203,6 +196,15 @@ public class ChatBoxController {
|
||||
try {
|
||||
ChatViewController chatViewController =
|
||||
new ChatViewController(
|
||||
this.chatController, chatModel, this);
|
||||
|
||||
ChatKey chatKey;
|
||||
if (chatType.equals(ChatType.WHISPER)) {
|
||||
chatKey = new ChatKey(chatType, title);
|
||||
} else {
|
||||
chatKey = new ChatKey(chatType);
|
||||
}
|
||||
chatController.activeChatControllers.put(chatKey, chatViewController);
|
||||
this.chatController, chatModel, this.username, this);
|
||||
|
||||
ChatKey chatKey;
|
||||
@@ -218,7 +220,7 @@ public class ChatBoxController {
|
||||
VBox vbox = new VBox();
|
||||
VBox.setVgrow(vbox, Priority.ALWAYS);
|
||||
vbox.getChildren().add(load);
|
||||
chatModel.addListener((msg) -> chatViewController.showMessage(msg));
|
||||
chatModel.addListener(chatViewController::showMessage);
|
||||
Tab newChat = new Tab(title, vbox);
|
||||
usernameTabMap.put(title, newChat);
|
||||
chatTabPane.getTabs().add(newChat);
|
||||
|
||||
+6
-10
@@ -8,6 +8,10 @@ import java.util.ResourceBundle;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
@@ -20,10 +24,6 @@ public class ChatViewController implements Initializable {
|
||||
|
||||
@FXML private TextField inputField;
|
||||
|
||||
@FXML private VBox chatInterfaceVBox;
|
||||
|
||||
@FXML private HBox controlBar;
|
||||
|
||||
@FXML private ScrollPane scrollPane;
|
||||
|
||||
@FXML private VBox chat;
|
||||
@@ -42,8 +42,6 @@ public class ChatViewController implements Initializable {
|
||||
|
||||
private final ChatModel chatModel;
|
||||
|
||||
private final String username;
|
||||
|
||||
private final ChatController controller;
|
||||
|
||||
private static final int CHAT_PADDING = 20;
|
||||
@@ -51,10 +49,8 @@ public class ChatViewController implements Initializable {
|
||||
public ChatViewController(
|
||||
ChatController chatController,
|
||||
ChatModel chatModel,
|
||||
String username,
|
||||
ChatBoxController chatBoxController) {
|
||||
this.controller = chatController;
|
||||
this.username = username;
|
||||
this.chatModel = chatModel;
|
||||
this.chatBoxController = chatBoxController;
|
||||
tabIsOpen = true;
|
||||
@@ -70,8 +66,8 @@ public class ChatViewController implements Initializable {
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resourceBundle) {
|
||||
inputField.setOnAction(event -> sendMessage());
|
||||
sendButton.setOnAction(event -> sendMessage());
|
||||
inputField.setOnAction(_ -> sendMessage());
|
||||
sendButton.setOnAction(_ -> sendMessage());
|
||||
scrollPane.vvalueProperty().bind(chat.heightProperty());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user