|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- /*
- * 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 command.CommandInterface;
- import command.CommandInvoker;
- import command.commands.CommandEintragHinzufuegen;
- import command.commands.CommandEintragLoeschen;
- import command.commands.CommandOpenFile;
- import command.commands.CommandSaveFile;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.util.prefs.Preferences;
- import model.AdressVerwaltungModel;
- import view.MainWindow;
-
- /**
- *
- * @author PC
- */
-
-
-
- public class CommandController implements ActionListener, WindowListener{
-
- private MainWindow view;
- private AdressVerwaltungModel model;
- private CommandInvoker invoker;
- //private Preferences prefs;
-
- public CommandController(MainWindow view, AdressVerwaltungModel model)
- {
- this.view = view;
- this.model = model;
- this.invoker = new CommandInvoker();
- //this.prefs = Preferences.userRoot().node(this.getClass().getName());
-
-
- registerEvents();
- registerCommands();
-
- }
-
-
- public void registerEvents()
- {
- view.getJpopEintragHinzufuegen().addActionListener(this);
- view.getJpopEintragLoeschen().addActionListener(this);
-
- view.getJbOpen().addActionListener(this);
- view.getJbSave().addActionListener(this);
-
- view.getFileOpen().addActionListener(this);
- view.getFileSave().addActionListener(this);
-
- view.getMiUndo().addActionListener(this);
-
- }
-
-
- public void registerCommands()
- {
- CommandEintragHinzufuegen cmdHinzufuegen = new CommandEintragHinzufuegen(view, model);
- CommandEintragLoeschen cmdLoeschen = new CommandEintragLoeschen(view, model);
- CommandSaveFile cmdSaveFile = new CommandSaveFile(view, model);
- CommandOpenFile cmdOpenFile = new CommandOpenFile(view, model);
-
-
-
- invoker.addCommand(view.getJpopEintragHinzufuegen(), cmdHinzufuegen);
- invoker.addCommand(view.getJpopEintragLoeschen(), cmdLoeschen);
- invoker.addCommand(view.getJbOpen(), cmdOpenFile);
- invoker.addCommand(view.getJbSave(), cmdSaveFile);
- invoker.addCommand(view.getFileOpen(), cmdOpenFile);
- invoker.addCommand(view.getFileSave(), cmdSaveFile);
-
- }
-
-
-
-
-
- /**
- * actionPerformed Funktion wird aufgerufen
- * @param evt
- * <br>
- * Hallo Guten Tag
- */
-
- @Override
- public void actionPerformed(ActionEvent evt) {
- Object key = evt.getSource();
-
- if(key == view.getMiUndo())
- {
- invoker.undoCommand();
- }
- else
- {
- invoker.executeCommand(key);
- }
-
-
-
-
- }
-
- @Override
- public void windowOpened(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowClosing(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowClosed(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowIconified(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowDeiconified(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowActivated(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- @Override
- public void windowDeactivated(WindowEvent we) {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-
- }
|