/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import controller.commands.CommandAnnehmen;
import controller.commands.CommandBeenden;
import controller.commands.CommandInvite;
import controller.commands.CommandRegister;
import gui.Hauptfenster;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Logger;
import logger.OhmLogger;
import model.SIPmodel;

/**
 *
 * @author Jan
 * Controller für Buttons und zuweisung der commands an die jeweiligen Buttons
 */
public class CommandController implements ActionListener
{
  private static final Logger lc = OhmLogger.getLogger();
  private SIPmodel model;
  private Hauptfenster view;
  private CommandInvoker invoker;
  public CommandController(SIPmodel model, Hauptfenster view)
  {
    this.model = model;
    this.view = view;
    invoker = new CommandInvoker(); 

  }
  public void registerEvents()
  {
    view.getBtn1().addActionListener(this);
    view.getBtn2().addActionListener(this);
    view.getBtnannehmen().addActionListener(this);
    view.getBtnbeenden().addActionListener(this);
  }
  public void registerCommands()
  {
    //invoker.addCommand(view.getMnuioeffnen(), new CommandOpen(view, model));
    
    invoker.addCommand(view.getBtn1(), new CommandRegister(model, view));
    invoker.addCommand(view.getBtn2(), new CommandInvite(model, view));
    invoker.addCommand(view.getBtnannehmen(), new CommandAnnehmen(model,view));
    invoker.addCommand(view.getBtnbeenden(), new CommandBeenden(model, view));
  }

  @Override
  public void actionPerformed(ActionEvent e)
  {
    Object key = e.getSource();
    
    invoker.executeCommand(key);
  
  }
}
