00001 /* Copyright (C) 2004 Thomas N. Valine 00002 * tvaline@users.sourceforge.net 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00017 * 02111-1307, USA. */ 00018 00019 package com.ohrasys.app; 00020 import java.awt.event.*; 00021 import java.util.*; 00022 00030 public abstract class AbstractAppModel 00031 implements AppControllerEventListener { 00033 protected transient AppModelEventListener controller = null; 00034 00041 public void actionPerformed(ActionEvent evt) { 00042 ActionEvent response = processEvent(evt); 00043 if(response != null){notifyController(response);} 00044 } 00045 00054 public synchronized void setController(AppModelEventListener controller) 00055 throws TooManyListenersException { 00056 if(controller == null){this.controller = null;} 00057 else { 00058 if(this.controller != null){throw new TooManyListenersException();} 00059 this.controller = controller; 00060 } 00061 } 00062 00068 public String toString(){return super.toString();} 00069 00081 protected abstract ActionEvent processEvent(ActionEvent evt); 00082 00088 protected void notifyController(ActionEvent event) { 00089 if(controller == null){return;} 00090 controller.actionPerformed(event); 00091 } 00092 } // end class AbstractAppModel 00093 00094 00095 /* This material is distributed under the GNU General Public License. 00096 * For more information please go to http://www.gnu.org/copyleft/gpl.html */