2023-12-18 13:56:06 +01:00

58 lines
1.6 KiB
Java

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package ChatProgramm.controller;
import ChatProgramm.controller.commands.CommandConnect;
import ChatProgramm.controller.commands.CommandInvoker;
import ChatProgramm.controller.commands.CommandSend;
import ChatProgramm.view.ChatView;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
*
* @author ahren
*/
public class CommandController implements ActionListener{
private ChatView view;
private CommandInvoker invoker;
public CommandController(ChatView view){
this.view = view;
this.invoker = new CommandInvoker();
}
public void registerEvents(){
view.getBtnConnect().addActionListener(this);
//ToDo: muss auf gFrame referenzieren
//view.getTfNachricht().addActionListener(this);
}
public void registerCommands(){
CommandSend commandSend = new CommandSend(view.getGvZeichenflaeche());
invoker.addCommand(view.getBtnConnect(), new CommandConnect(view, commandSend));
//invoker.addCommand(view.getTfNachricht(), commandSend);
}
/**
* Ausführen des jeweiligen Kommandos
* @param e Referenz auf das Event
*/
@Override
public void actionPerformed(ActionEvent e) {
Component key = (Component)e.getSource();
invoker.executeCommand(key);
// if(key == view.getBtnOpen()|| key==view.getMiOpen())
// invoker.deleteStack();
// }
}
}