001: package org.acm.seguin.pmd.swingui.event;
002:
003: import org.acm.seguin.pmd.Rule;
004: import org.acm.seguin.pmd.swingui.RulesTreeNode;
005:
006: import java.util.EventObject;
007: import java.util.Iterator;
008: import java.util.List;
009:
010: /**
011: *
012: * @author Donald A. Leckie
013: * @since December 13, 2002
014: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
015: */
016: public class RulesTreeModelEvent extends EventObject {
017:
018: private RulesTreeNode m_parentNode;
019: private Rule m_rule;
020:
021: /**
022: ******************************************************************************
023: *
024: * @param source
025: */
026: private RulesTreeModelEvent(Object source) {
027: super (source);
028: }
029:
030: /**
031: ******************************************************************************
032: *
033: * @param source
034: * @param parentNode
035: */
036: private RulesTreeModelEvent(Object source, RulesTreeNode parentNode) {
037: super (source);
038:
039: m_parentNode = parentNode;
040: }
041:
042: /**
043: ******************************************************************************
044: *
045: * @param source
046: * @param rule
047: */
048: private RulesTreeModelEvent(Object source, Rule rule) {
049: super (source);
050:
051: m_rule = rule;
052: }
053:
054: /**
055: ******************************************************************************
056: *
057: * @return
058: */
059: public RulesTreeNode getParentNode() {
060: return m_parentNode;
061: }
062:
063: /**
064: ******************************************************************************
065: *
066: * @return
067: */
068: public Rule getRule() {
069: return m_rule;
070: }
071:
072: /**
073: ******************************************************************************
074: *
075: */
076: public static void notifyReload(Object source,
077: RulesTreeNode parentNode) {
078: if ((source != null) && (parentNode != null)) {
079: RulesTreeModelEvent event = new RulesTreeModelEvent(source,
080: parentNode);
081: List listenerList = ListenerList
082: .getListeners(RulesTreeModelEventListener.class);
083: Iterator listeners = listenerList.iterator();
084:
085: while (listeners.hasNext()) {
086: RulesTreeModelEventListener listener;
087:
088: listener = (RulesTreeModelEventListener) listeners
089: .next();
090: listener.reload(event);
091: }
092: }
093: }
094:
095: /**
096: ******************************************************************************
097: *
098: */
099: public static void notifyRequestSelectedRule(Object source) {
100: if (source != null) {
101: RulesTreeModelEvent event = new RulesTreeModelEvent(source);
102: List listenerList = ListenerList
103: .getListeners(RulesTreeModelEventListener.class);
104: Iterator listeners = listenerList.iterator();
105:
106: while (listeners.hasNext()) {
107: RulesTreeModelEventListener listener;
108:
109: listener = (RulesTreeModelEventListener) listeners
110: .next();
111: listener.requestSelectedRule(event);
112: }
113: }
114: }
115:
116: /**
117: ******************************************************************************
118: *
119: */
120: public static void notifyReturnedSelectedRule(Object source,
121: Rule selectedRule) {
122: if (source != null) {
123: RulesTreeModelEvent event = new RulesTreeModelEvent(source,
124: selectedRule);
125: List listenerList = ListenerList
126: .getListeners(RulesTreeModelEventListener.class);
127: Iterator listeners = listenerList.iterator();
128:
129: while (listeners.hasNext()) {
130: RulesTreeModelEventListener listener;
131:
132: listener = (RulesTreeModelEventListener) listeners
133: .next();
134: listener.returnedSelectedRule(event);
135: }
136: }
137: }
138: }
|