001 // This file is part of the program FRYSK. 002 // 003 // Copyright 2005, Red Hat Inc. 004 // 005 // FRYSK is free software; you can redistribute it and/or modify it 006 // under the terms of the GNU General Public License as published by 007 // the Free Software Foundation; version 2 of the License. 008 // 009 // FRYSK is distributed in the hope that it will be useful, but 010 // WITHOUT ANY WARRANTY; without even the implied warranty of 011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 // General Public License for more details. 013 // type filter text 014 // You should have received a copy of the GNU General Public License 015 // along with FRYSK; if not, write to the Free Software Foundation, 016 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 017 // 018 // In addition, as a special exception, Red Hat, Inc. gives You the 019 // additional right to link the code of FRYSK with code not covered 020 // under the GNU General Public License ("Non-GPL Code") and to 021 // distribute linked combinations including the two, subject to the 022 // limitations in this paragraph. Non-GPL Code permitted under this 023 // exception must only link to the code of FRYSK through those well 024 // defined interfaces identified in the file named EXCEPTION found in 025 // the source code files (the "Approved Interfaces"). The files of 026 // Non-GPL Code may instantiate templates or use macros or inline 027 // functions from the Approved Interfaces without causing the 028 // resulting work to be covered by the GNU General Public 029 // License. Only Red Hat, Inc. may make changes or additions to the 030 // list of Approved Interfaces. You must obey the GNU General Public 031 // License in all respects for all of the FRYSK code and other code 032 // used in conjunction with FRYSK except the Non-GPL Code covered by 033 // this exception. If you modify this file, you may extend this 034 // exception to your version of the file, but you are not obligated to 035 // do so. If you do not wish to provide this exception without 036 // modification, you must delete this exception statement from your 037 // version and license this file solely under the GPL without 038 // exception. 039 040 041 package frysk.gui.monitor.actions; 042 043 import java.util.Observable; 044 045 import frysk.gui.monitor.ObservableLinkedList; 046 047 /** 048 * Only once instance. Keeps a list of available actions. Provides an interface 049 * for instantiating those actions. 050 */ 051 public class ActionManager 052 extends Observable 053 { 054 055 public static ActionManager theManager = new ActionManager(); 056 057 private ObservableLinkedList procActions; 058 059 private ObservableLinkedList taskActions; 060 061 private ObservableLinkedList genericActions; 062 063 public ActionManager () 064 { 065 this.procActions = new ObservableLinkedList(); 066 this.taskActions = new ObservableLinkedList(); 067 this.genericActions = new ObservableLinkedList(); 068 this.initActionList(); 069 } 070 071 /** 072 * Instantiates each one of the static task observers and adds it to the list. 073 */ 074 private void initActionList () 075 { 076 077 this.addGenericActionPrototype(new LogAction()); 078 this.addGenericActionPrototype(new NotifyUserAction()); 079 080 this.addTaskActionPrototype(new PrintTask()); 081 this.addTaskActionPrototype(new PrintTaskBacktrace()); 082 this.addProcActionPrototype(new PrintProc()); 083 } 084 085 public ObservableLinkedList getProcActions () 086 { 087 return this.procActions; 088 } 089 090 public ObservableLinkedList getTaskActions () 091 { 092 return this.taskActions; 093 } 094 095 public ObservableLinkedList getGenericActions () 096 { 097 return this.genericActions; 098 } 099 100 /** 101 * Add a ProcAction to the list of available ProcAction prototypes. 102 * 103 * @param prototype the action to be added. 104 */ 105 public void addProcActionPrototype (ProcAction prototype) 106 { 107 this.procActions.add(prototype); 108 } 109 110 /** 111 * Add a TaskAction to the list of available TaskAction prototypes. 112 * 113 * @param prototype the action to be added. 114 */ 115 public void addTaskActionPrototype (TaskAction prototype) 116 { 117 this.taskActions.add(prototype); 118 } 119 120 /** 121 * Add a generic Action to the list of available Action prototypes. 122 * 123 * @param prototype the action to be added. 124 */ 125 public void addGenericActionPrototype (Action prototype) 126 { 127 this.genericActions.add(prototype); 128 } 129 130 public void removeGenericActionPrototype (GenericAction genericAction) 131 { 132 this.genericActions.remove(genericAction); 133 } 134 135 public void removeTaskActionPrototype (TaskAction taskAction) 136 { 137 this.taskActions.remove(taskAction); 138 } 139 140 public void removeProcActionPrototype (ProcAction procAction) 141 { 142 this.procActions.remove(procAction); 143 } 144 }