From 19fd23c6388b90cf8135ee6c8b409b8790a9d391 Mon Sep 17 00:00:00 2001 From: ahren Date: Mon, 18 Dec 2023 13:18:49 +0100 Subject: [PATCH] =?UTF-8?q?versuch=20=C3=BCber=20invoker=20in=20GrafikCont?= =?UTF-8?q?roller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatProgramm/controller/GrafikController.java | 12 ++++++++++++ .../controller/commands/CommandSend.java | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ChatProgramm/controller/GrafikController.java b/src/ChatProgramm/controller/GrafikController.java index 0fcbb9a..fe13b4a 100644 --- a/src/ChatProgramm/controller/GrafikController.java +++ b/src/ChatProgramm/controller/GrafikController.java @@ -5,12 +5,16 @@ package ChatProgramm.controller; +import ChatProgramm.controller.commands.CommandConnect; +import ChatProgramm.controller.commands.CommandInvoker; +import ChatProgramm.controller.commands.CommandSend; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import ChatProgramm.model.GrafikModel; import ChatProgramm.view.GrafikView; +import java.awt.Component; /** * @@ -20,6 +24,7 @@ public class GrafikController extends MouseAdapter implements MouseMotionListene { private GrafikView view; private GrafikModel model; + private CommandInvoker invoker; public GrafikController(GrafikView view, GrafikModel model) { @@ -32,6 +37,11 @@ public class GrafikController extends MouseAdapter implements MouseMotionListene view.addMouseMotionListener(this); view.addMouseListener(this); } + public void registerCommands(){ + CommandSend commandSend = new CommandSend(view); + invoker.addCommand(view.getTfNachricht(), commandSend); + } + @Override public void mouseDragged(MouseEvent evt) @@ -50,6 +60,8 @@ public class GrafikController extends MouseAdapter implements MouseMotionListene public void mouseReleased(MouseEvent evt) { model.endShape(); + Component key = (Component)evt.getSource(); + invoker.executeCommand(key); // if (evt.getButton() == MouseEvent.BUTTON3) // { // view.doPrint(); diff --git a/src/ChatProgramm/controller/commands/CommandSend.java b/src/ChatProgramm/controller/commands/CommandSend.java index 70bda03..ea8b6df 100644 --- a/src/ChatProgramm/controller/commands/CommandSend.java +++ b/src/ChatProgramm/controller/commands/CommandSend.java @@ -13,6 +13,7 @@ import ChatProgramm.view.ChatView; import java.util.logging.Logger; import javax.swing.JTextField; import ChatProgramm.model.Nachricht; +import ChatProgramm.view.GrafikView; /** * @@ -23,7 +24,7 @@ public class CommandSend implements CommandInterface private static Logger lg = OhmLogger.getLogger(); private JTextField eingabeFeld; private String nachricht; - private ChatView view; + private GrafikView view; public TransmitterInterface transmitterInterface; public Server server; public Client client; @@ -31,7 +32,7 @@ public class CommandSend implements CommandInterface - public CommandSend(ChatView view) + public CommandSend(GrafikView view) { this.view = view; //ToDo: Hier muss auch der gFrame referenziert werden