123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /*
- * 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 commands.CommandAdd;
- import commands.CommandDelete;
- import commands.CommandInvoker;
- import commands.CommandOpen;
- import commands.CommandSave;
- import java.awt.Component;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.prefs.Preferences;
- import model.model;
- import view.gui;
-
- /**
- * Command Controller execute
- * @author matthias
- */
- public class C_MenuListener implements ActionListener{
- private gui view;
- private CommandInvoker invoker;
- private String PathID;
- private String FildID;
- private Preferences prfs;
- private model mdl;
-
- public C_MenuListener(gui g, String pid, String fid, Preferences p, model m, CommandInvoker inv)
- {
- this.view = g;
- this.invoker = inv;
- this.PathID = pid;
- this.FildID = fid;
- this.prfs = p;
- this.mdl = m;
-
- this.view.getContentTable1().getjTable().setModel(this.mdl);
- }
-
- /**
- * regestriert alle Events mit dem Command Controller als Listener
- */
- public void registerEvents()
- {
- this.view.getBtnSave().addActionListener(this);
- this.view.getMiSave().addActionListener(this);
- this.view.getMiSave_popup().addActionListener(this);
-
- this.view.getBtnOpen().addActionListener(this);
- this.view.getMiOpen().addActionListener(this);
- this.view.getMiOpen_popup().addActionListener(this);
-
- this.view.getContentTable1().getBtnAdd().addActionListener(this);
- this.view.getContentTable1().getBtnDel().addActionListener(this);
- this.view.getContentTable1().getCtmiAdd_popup().addActionListener(this);
- this.view.getContentTable1().getCtmiDelRow_popup().addActionListener(this);
- }
-
- /**
- * fügt alle Commands mit zugehörigem Event dem Invoker zu
- */
- public void registerCommands()
- {
- this.invoker.addCommand(this.view.getBtnSave(), new CommandSave(this.view, this.prfs, this.mdl, this.PathID));
- this.invoker.addCommand(this.view.getMiSave(), new CommandSave(this.view,this.prfs, this.mdl, this.PathID));
- this.invoker.addCommand(this.view.getMiSave_popup(), new CommandSave(this.view, this.prfs, this.mdl, this.PathID));
-
- this.invoker.addCommand(this.view.getBtnOpen(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl));
- this.invoker.addCommand(this.view.getMiOpen(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl));
- this.invoker.addCommand(this.view.getMiOpen_popup(), new CommandOpen(this.view, this.prfs,this.PathID, this.FildID, this.mdl));
-
- this.invoker.addCommand(this.view.getContentTable1().getBtnAdd(), new CommandAdd(this.view, this.prfs, this.mdl, this.PathID));
- this.invoker.addCommand(this.view.getContentTable1().getCtmiAdd_popup(), new CommandAdd(this.view, this.prfs, this.mdl, this.PathID));
-
- this.invoker.addCommand(this.view.getContentTable1().getCtmiDelRow_popup(), new CommandDelete(this.view, this.prfs, this.mdl, this.PathID));
- this.invoker.addCommand(this.view.getContentTable1().getBtnDel(), new CommandDelete(this.view, this.prfs, this.mdl, this.PathID));
- }
-
- /**
- * ausführen vom executeCommand aus dem Invoker
- * @param ae (AktionEvent)
- */
- @Override
- public void actionPerformed(ActionEvent ae) {
- Component key = (Component) ae.getSource();
- this.invoker.executeCommand(key);
- }
-
- }
|