01: package org.acm.seguin.pmd.swingui.event;
02:
03: import org.acm.seguin.pmd.RuleSet;
04:
05: import java.util.EventObject;
06: import java.util.Iterator;
07: import java.util.List;
08:
09: /**
10: *
11: * @author Donald A. Leckie
12: * @since December 13, 2002
13: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
14: */
15: public class RuleSetChangedEvent extends EventObject {
16:
17: private RuleSet m_ruleSet;
18:
19: /**
20: *******************************************************************************
21: *
22: * @param ruleSet
23: */
24: private RuleSetChangedEvent(Object source, RuleSet ruleSet) {
25: super (source);
26:
27: m_ruleSet = ruleSet;
28: }
29:
30: /**
31: *******************************************************************************
32: *
33: * @return
34: */
35: public boolean allRuleSetsChanged() {
36: return m_ruleSet == null;
37: }
38:
39: /**
40: *******************************************************************************
41: *
42: * @return
43: */
44: public RuleSet getRuleSet() {
45: return m_ruleSet;
46: }
47:
48: /**
49: *******************************************************************************
50: *
51: * @param ruleSet
52: */
53: public static void notifyRuleSetChanged(Object source,
54: RuleSet ruleSet) {
55: if ((source != null) && (ruleSet != null)) {
56: RuleSetChangedEvent event = new RuleSetChangedEvent(source,
57: ruleSet);
58: List listenerList = ListenerList
59: .getListeners(RuleSetChangedEventListener.class);
60: Iterator listeners = listenerList.iterator();
61:
62: while (listeners.hasNext()) {
63: RuleSetChangedEventListener listener;
64:
65: listener = (RuleSetChangedEventListener) listeners
66: .next();
67: listener.ruleSetChanged(event);
68: }
69: }
70: }
71:
72: /**
73: *******************************************************************************
74: *
75: */
76: public static void notifyRuleSetsChanged(Object source) {
77: if (source != null) {
78: RuleSetChangedEvent event = new RuleSetChangedEvent(source,
79: null);
80: List listenerList = ListenerList
81: .getListeners(RuleSetChangedEventListener.class);
82: Iterator listeners = listenerList.iterator();
83:
84: while (listeners.hasNext()) {
85: RuleSetChangedEventListener listener;
86:
87: listener = (RuleSetChangedEventListener) listeners
88: .next();
89: listener.ruleSetsChanged(event);
90: }
91: }
92: }
93: }
|