001: package org.acm.seguin.pmd.swingui;
002:
003: import org.acm.seguin.pmd.PMDException;
004: import org.acm.seguin.pmd.RuleSet;
005: import org.acm.seguin.pmd.swingui.event.DirectoryTableEvent;
006: import org.acm.seguin.pmd.swingui.event.DirectoryTableEventListener;
007: import org.acm.seguin.pmd.swingui.event.ListenerList;
008: import org.acm.seguin.pmd.swingui.event.RulesInMemoryEvent;
009: import org.acm.seguin.pmd.swingui.event.RulesInMemoryEventListener;
010:
011: import java.io.File;
012:
013: /**
014: *
015: * @author Donald A. Leckie
016: * @since August 27, 2002
017: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
018: */
019: class AnalysisResultsViewer extends ResultsViewer {
020:
021: private RuleSet m_ruleSet;
022:
023: /**
024: ********************************************************************************
025: */
026: protected AnalysisResultsViewer() {
027: super ();
028:
029: //
030: // Add listeners
031: //
032: ListenerList
033: .addListener((DirectoryTableEventListener) new DirectoryTableEventHandler());
034: ListenerList
035: .addListener((RulesInMemoryEventListener) new RulesInMemoryEventHandler());
036: }
037:
038: /**
039: ***********************************************************************************
040: ***********************************************************************************
041: ***********************************************************************************
042: */
043: private class DirectoryTableEventHandler implements
044: DirectoryTableEventListener {
045:
046: /**
047: ***************************************************************************
048: *
049: * @param event
050: */
051: public void requestSelectedFile(DirectoryTableEvent event) {
052: }
053:
054: /**
055: ***************************************************************************
056: *
057: * @param event
058: */
059: public void fileSelectionChanged(DirectoryTableEvent event) {
060: try {
061: File[] file = { event.getSelectedFile() };
062: int priority = Preferences.getPreferences()
063: .getLowestPriorityForAnalysis();
064: RulesInMemoryEvent.notifyRequestIncludedRules(this ,
065: priority);
066: AnalysisResultsViewer.this .analyze(file, m_ruleSet);
067: } catch (PMDException pmdException) {
068: MessageDialog.show(PMDViewer.getViewer(), pmdException
069: .getMessage(), pmdException.getReason());
070: }
071: }
072:
073: /**
074: ***************************************************************************
075: *
076: * @param event
077: */
078: public void fileSelected(DirectoryTableEvent event) {
079: }
080: }
081:
082: /**
083: ***************************************************************************
084: ***************************************************************************
085: ***************************************************************************
086: */
087: private class RulesInMemoryEventHandler implements
088: RulesInMemoryEventListener {
089:
090: /**
091: ***********************************************************************
092: *
093: * @param event
094: */
095: public void requestAllRules(RulesInMemoryEvent event) {
096: }
097:
098: /**
099: ***********************************************************************
100: *
101: * @param event
102: */
103: public void requestIncludedRules(RulesInMemoryEvent event) {
104: }
105:
106: /**
107: ***********************************************************************
108: *
109: * @param event
110: */
111: public void returnedRules(RulesInMemoryEvent event) {
112: m_ruleSet = event.getRules();
113: }
114: }
115: }
|