feature/separacao-gerenciadores #1

Merged
gustavo merged 31 commits from feature/separacao-gerenciadores into main 2026-09-30 18:34:54 -03:00
5 changed files with 8 additions and 5 deletions
Showing only changes of commit 23559dcc06 - Show all commits

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,7 +20,6 @@ public class ChatController {
private final HashMap<TcpConnection, JMenuItem> chatMenus; private final HashMap<TcpConnection, JMenuItem> chatMenus;
private final HashMap<TcpConnection, ChatWindow> chatWindows; private final HashMap<TcpConnection, ChatWindow> chatWindows;
public ChatController(MainWindow mainWindow, ChatMenu chatMenu) { public ChatController(MainWindow mainWindow, ChatMenu chatMenu) {
this.mainWindow = mainWindow; this.mainWindow = mainWindow;
publicChatWindow = new PublicChatWindow(mainWindow); publicChatWindow = new PublicChatWindow(mainWindow);
@@ -28,7 +27,9 @@ public class ChatController {
chatMenus = new HashMap<>(); chatMenus = new HashMap<>();
chatWindows = new HashMap<>(); chatWindows = new HashMap<>();
chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow); this.chatMenu = chatMenu;
this.chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow);
} }
public void addChatWindow(TcpConnection tcpConnection) { public void addChatWindow(TcpConnection tcpConnection) {
@@ -36,10 +37,8 @@ public class ChatController {
PrivateChatWindow newChat = new PrivateChatWindow(mainWindow, tcpConnection); PrivateChatWindow newChat = new PrivateChatWindow(mainWindow, tcpConnection);
chatWindows.put(tcpConnection, newChat); chatWindows.put(tcpConnection, newChat);
JMenuItem newMenuItem = new JMenuItem(); JMenuItem newMenuItem = new JMenuItem();
chatMenus.put(tcpConnection, newMenuItem); chatMenus.put(tcpConnection, newMenuItem);
newMenuItem.setText(tcpConnection.getAddress().toString()); newMenuItem.setText(tcpConnection.getAddress().toString());
chatMenu.newMenuItem(newMenuItem, newChat); chatMenu.newMenuItem(newMenuItem, newChat);
} }
+5 -1
View File
@@ -8,6 +8,7 @@ import pitiupi.net.Message;
import pitiupi.net.tcp.TcpConnection; import pitiupi.net.tcp.TcpConnection;
import pitiupi.plugin.PrivateConnectionPlugin; import pitiupi.plugin.PrivateConnectionPlugin;
import javax.swing.*;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
@@ -57,9 +58,12 @@ public class TestChat implements PrivateConnectionPlugin{
chatController.receivePublic(testChatMessage); chatController.receivePublic(testChatMessage);
} }
@Override @Override
public void receivePrivateConnection(TcpConnection tcpConnection) { public void receivePrivateConnection(TcpConnection tcpConnection) {
chatController.addChatWindow(tcpConnection); SwingUtilities.invokeLater(() -> {
chatController.addChatWindow(tcpConnection);
});
} }
@Override @Override