You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Controller.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package controller;
  7. import adressverwaltung.model.AdressverwaltungModel;
  8. import controller.commands.CommandOpen;
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import prfourgui.View.AdressbuchView;
  12. /**
  13. *
  14. * @author jechowma68968
  15. */
  16. public class Controller implements ActionListener
  17. {
  18. private AdressbuchView view;
  19. private AdressverwaltungModel model;
  20. private Invoker invoker;
  21. public Controller(AdressbuchView view, AdressverwaltungModel model)
  22. {
  23. this.view = view;
  24. this.model = model;
  25. this.invoker = new Invoker();
  26. }
  27. /**
  28. * Hinterlegen aller Objekte in View die Interaktion ausüben
  29. */
  30. public void registerEvents(){
  31. view.getMnuOpen().addActionListener(this);
  32. }
  33. public void registerCommands(){
  34. invoker.addCommand(view.getMnuOpen(), new CommandOpen(view, model));
  35. }
  36. @Override
  37. public void actionPerformed(ActionEvent ae)
  38. {
  39. Object key = ae.getSource();
  40. invoker.executeCommand(key);
  41. }
  42. }