001: package org.acm.seguin.pmd.swingui.event;
002:
003: import org.acm.seguin.pmd.PMDException;
004: import org.acm.seguin.pmd.RuleSet;
005: import org.acm.seguin.pmd.swingui.MessageDialog;
006: import org.acm.seguin.pmd.swingui.PMDViewer;
007:
008: import java.util.EventObject;
009: import java.util.Iterator;
010: import java.util.List;
011:
012: /**
013: *
014: * @author Donald A. Leckie
015: * @since December 13, 2002
016: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
017: */
018: public class PMDDirectoryRequestEvent extends EventObject {
019:
020: private List m_ruleSetList;
021: private RuleSet m_ruleSet;
022: private int m_lowestPriorityForAnalysis;
023:
024: /**
025: *****************************************************************************
026: *
027: * @param source
028: */
029: private PMDDirectoryRequestEvent(Object source) {
030: super (source);
031: }
032:
033: /**
034: *****************************************************************************
035: *
036: * @param source
037: * @param ruleSetList
038: */
039: private PMDDirectoryRequestEvent(Object source, List ruleSetList) {
040: super (source);
041:
042: m_ruleSetList = ruleSetList;
043: }
044:
045: /**
046: *****************************************************************************
047: *
048: * @param source
049: * @param ruleSet
050: */
051: private PMDDirectoryRequestEvent(Object source, RuleSet ruleSet) {
052: super (source);
053:
054: m_ruleSet = ruleSet;
055: }
056:
057: /**
058: *****************************************************************************
059: *
060: * @param source
061: * @param lowestPriorityForAnalysis
062: */
063: private PMDDirectoryRequestEvent(Object source,
064: int lowestPriorityForAnalysis) {
065: super (source);
066:
067: m_lowestPriorityForAnalysis = lowestPriorityForAnalysis;
068: }
069:
070: /**
071: *****************************************************************************
072: *
073: * @return
074: */
075: public List getRuleSetList() {
076: return m_ruleSetList;
077: }
078:
079: /**
080: *****************************************************************************
081: *
082: * @return
083: */
084: public RuleSet getRuleSet() {
085: return m_ruleSet;
086: }
087:
088: /**
089: *****************************************************************************
090: *
091: * @return
092: */
093: public int getLowestPriorityForAnalysis() {
094: return m_lowestPriorityForAnalysis;
095: }
096:
097: /**
098: *****************************************************************************
099: *
100: * @param source
101: */
102: public static final void notifyRequestRuleSetPath(Object source) {
103: PMDDirectoryRequestEvent event = new PMDDirectoryRequestEvent(
104: source);
105: List listenerList = ListenerList
106: .getListeners(PMDDirectoryRequestEventListener.class);
107: Iterator listeners = listenerList.iterator();
108:
109: while (listeners.hasNext()) {
110: PMDDirectoryRequestEventListener listener;
111:
112: listener = (PMDDirectoryRequestEventListener) listeners
113: .next();
114: listener.requestRuleSetPath(event);
115: }
116: }
117:
118: /**
119: *****************************************************************************
120: *
121: * @param source
122: */
123: public static final void notifyRequestAllRuleSets(Object source) {
124: PMDDirectoryRequestEvent event = new PMDDirectoryRequestEvent(
125: source);
126: List listenerList = ListenerList
127: .getListeners(PMDDirectoryRequestEventListener.class);
128: Iterator listeners = listenerList.iterator();
129:
130: while (listeners.hasNext()) {
131: try {
132: PMDDirectoryRequestEventListener listener;
133:
134: listener = (PMDDirectoryRequestEventListener) listeners
135: .next();
136: listener.requestAllRuleSets(event);
137: } catch (PMDException pmdException) {
138: String message = pmdException.getMessage();
139: Exception exception = pmdException.getReason();
140: MessageDialog.show(PMDViewer.getViewer(), message,
141: exception);
142: }
143: }
144: }
145:
146: /**
147: *****************************************************************************
148: *
149: * @param source
150: */
151: public static final void notifyRequestDefaultRuleSets(Object source) {
152: PMDDirectoryRequestEvent event = new PMDDirectoryRequestEvent(
153: source);
154: List listenerList = ListenerList
155: .getListeners(PMDDirectoryRequestEventListener.class);
156: Iterator listeners = listenerList.iterator();
157:
158: while (listeners.hasNext()) {
159: PMDDirectoryRequestEventListener listener;
160:
161: listener = (PMDDirectoryRequestEventListener) listeners
162: .next();
163: listener.requestDefaultRuleSets(event);
164: }
165: }
166:
167: /**
168: *****************************************************************************
169: *
170: * @param source
171: */
172: public static final void notifyRequestIncludedRules(Object source,
173: int lowestPriorityForAnalysis) {
174: PMDDirectoryRequestEvent event = new PMDDirectoryRequestEvent(
175: source, lowestPriorityForAnalysis);
176: List listenerList = ListenerList
177: .getListeners(PMDDirectoryRequestEventListener.class);
178: Iterator listeners = listenerList.iterator();
179:
180: while (listeners.hasNext()) {
181: try {
182: PMDDirectoryRequestEventListener listener;
183:
184: listener = (PMDDirectoryRequestEventListener) listeners
185: .next();
186: listener.requestIncludedRules(event);
187: } catch (PMDException pmdException) {
188: String message = pmdException.getMessage();
189: Exception exception = pmdException.getReason();
190: MessageDialog.show(PMDViewer.getViewer(), message,
191: exception);
192: }
193: }
194: }
195: }
|