Feat/chat visual improvement #315
+8
-8
@@ -166,17 +166,17 @@ public class ChatBoxController {
|
|||||||
if (!activeWhisperChats.contains(target)) {
|
if (!activeWhisperChats.contains(target)) {
|
||||||
activeWhisperChats.add(target);
|
activeWhisperChats.add(target);
|
||||||
ChatType whisper = ChatType.WHISPER;
|
ChatType whisper = ChatType.WHISPER;
|
||||||
chatController
|
chatController.getChatModelMap().put(new ChatKey(whisper, target), chatModel);
|
||||||
.getChatModelMap()
|
|
||||||
.put(new ChatKey(whisper, target), chatModel);
|
|
||||||
ChatViewController chatViewController = addChatTab(target, chatModel, whisper);
|
ChatViewController chatViewController = addChatTab(target, chatModel, whisper);
|
||||||
Tab chatTab = chatViewController.getChatTab();
|
Tab chatTab = chatViewController.getChatTab();
|
||||||
chatTab.setOnCloseRequest(_ -> {
|
chatTab.setOnCloseRequest(
|
||||||
|
_ -> {
|
||||||
chatViewController.tabIsOpen = false;
|
chatViewController.tabIsOpen = false;
|
||||||
chatTabPane.getTabs().remove(chatTab);
|
chatTabPane.getTabs().remove(chatTab);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ChatViewController chatViewController = chatController.activeChatControllers.get(new ChatKey(ChatType.WHISPER, target));
|
ChatViewController chatViewController =
|
||||||
|
chatController.activeChatControllers.get(new ChatKey(ChatType.WHISPER, target));
|
||||||
if (!chatViewController.tabIsOpen) {
|
if (!chatViewController.tabIsOpen) {
|
||||||
reopenChatTab(chatViewController.getChatTab());
|
reopenChatTab(chatViewController.getChatTab());
|
||||||
chatViewController.tabIsOpen = true;
|
chatViewController.tabIsOpen = true;
|
||||||
@@ -211,8 +211,7 @@ public class ChatBoxController {
|
|||||||
} else {
|
} else {
|
||||||
chatKey = new ChatKey(chatType);
|
chatKey = new ChatKey(chatType);
|
||||||
}
|
}
|
||||||
chatController.activeChatControllers.put(
|
chatController.activeChatControllers.put(chatKey, chatViewController);
|
||||||
chatKey, chatViewController);
|
|
||||||
fxmlLoader.setController(chatViewController);
|
fxmlLoader.setController(chatViewController);
|
||||||
Node load = fxmlLoader.load();
|
Node load = fxmlLoader.load();
|
||||||
VBox.setVgrow(load, Priority.ALWAYS);
|
VBox.setVgrow(load, Priority.ALWAYS);
|
||||||
@@ -291,7 +290,8 @@ public class ChatBoxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reopenChatTab(Tab chatTab) {
|
public void reopenChatTab(Tab chatTab) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(
|
||||||
|
() -> {
|
||||||
chatTabPane.getTabs().add(chatTab);
|
chatTabPane.getTabs().add(chatTab);
|
||||||
chatTabPane.getSelectionModel().select(chatTab);
|
chatTabPane.getSelectionModel().select(chatTab);
|
||||||
});
|
});
|
||||||
|
|||||||
+10
-4
@@ -2,15 +2,17 @@ package ch.unibas.dmi.dbis.cs108.casono.client.ui.chatui;
|
|||||||
|
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatController;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatModel;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatModel;
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.ChatType;
|
|
||||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
@@ -50,7 +52,11 @@ public class ChatViewController implements Initializable {
|
|||||||
|
|
||||||
private static final int CHAT_PADDING = 20;
|
private static final int CHAT_PADDING = 20;
|
||||||
|
|
||||||
public ChatViewController(ChatController chatController, ChatModel chatModel, String username, ChatBoxController chatBoxController) {
|
public ChatViewController(
|
||||||
|
ChatController chatController,
|
||||||
|
ChatModel chatModel,
|
||||||
|
String username,
|
||||||
|
ChatBoxController chatBoxController) {
|
||||||
this.controller = chatController;
|
this.controller = chatController;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
|
|||||||
Reference in New Issue
Block a user