01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.him.window.messages;
20:
21: import java.util.ArrayList;
22: import java.util.Iterator;
23:
24: /**
25: *
26: * @author Matthew Large
27: * @version $Revision: 1.1 $
28: *
29: */
30: public class MessageHandler {
31:
32: public static String TYPE_CONFIRM = "CONFIRM";
33: public static String TYPE_INFORMATION = "INFO";
34: public static String TYPE_ERROR = "ERROR";
35:
36: private static MessageHandler m_instance = null;
37:
38: private ArrayList m_listeners = new ArrayList();
39:
40: /**
41: *
42: */
43: private MessageHandler() {
44: super ();
45: }
46:
47: public static MessageHandler getInstance() {
48: if (m_instance == null) {
49: m_instance = new MessageHandler();
50: }
51: return m_instance;
52: }
53:
54: public void addMessageListener(MessageListener listener) {
55: this .m_listeners.add(listener);
56: }
57:
58: public void removeMessageListener(MessageListener listener) {
59: this .m_listeners.remove(listener);
60: }
61:
62: public void fireMessageEvent(String sMessage, String sMessageType) {
63: Iterator itor = this .m_listeners.iterator();
64: MessageEvent me = new MessageEvent(sMessage, sMessageType);
65: while (itor.hasNext()) {
66: MessageListener listener = (MessageListener) itor.next();
67: listener.messageEvent(me);
68: }
69: }
70:
71: }
|