001: package org.acm.seguin.pmd.swingui.event;
002:
003: import java.io.File;
004: import java.util.EventObject;
005: import java.util.Iterator;
006: import java.util.List;
007:
008: /**
009: *
010: * @author Donald A. Leckie
011: * @since December 13, 2002
012: * @version $Revision: 1.1 $, $Date: 2003/07/29 20:51:59 $
013: */
014: public class DirectoryTableEvent extends EventObject {
015:
016: private File m_selectedFile;
017:
018: /**
019: ****************************************************************************
020: *
021: */
022: private DirectoryTableEvent(Object source, File selectedFile) {
023: super (source);
024:
025: m_selectedFile = selectedFile;
026: }
027:
028: /**
029: ****************************************************************************
030: *
031: * @return
032: */
033: public File getSelectedFile() {
034: return m_selectedFile;
035: }
036:
037: /**
038: *******************************************************************************
039: *
040: * @param dataNode
041: */
042: public static void notifyRequestFileSelected(Object source) {
043: if (source != null) {
044: DirectoryTableEvent event = new DirectoryTableEvent(source,
045: null);
046: List listenerList = ListenerList
047: .getListeners(DirectoryTableEventListener.class);
048: Iterator listeners = listenerList.iterator();
049:
050: while (listeners.hasNext()) {
051: DirectoryTableEventListener listener;
052:
053: listener = (DirectoryTableEventListener) listeners
054: .next();
055: listener.requestSelectedFile(event);
056: }
057: }
058: }
059:
060: /**
061: *******************************************************************************
062: *
063: * @param dataNode
064: */
065: public static void notifyFileSelectionChanged(Object source,
066: File newFile) {
067: if (source != null) {
068: DirectoryTableEvent event = new DirectoryTableEvent(source,
069: newFile);
070: List listenerList = ListenerList
071: .getListeners(DirectoryTableEventListener.class);
072: Iterator listeners = listenerList.iterator();
073:
074: while (listeners.hasNext()) {
075: DirectoryTableEventListener listener;
076:
077: listener = (DirectoryTableEventListener) listeners
078: .next();
079: listener.fileSelectionChanged(event);
080: }
081: }
082: }
083:
084: /**
085: *******************************************************************************
086: *
087: * @param dataNode
088: */
089: public static void notifySelectedFile(Object source,
090: File selectedFile) {
091: if ((source != null) && (selectedFile != null)) {
092: DirectoryTableEvent event = new DirectoryTableEvent(source,
093: selectedFile);
094: List listenerList = ListenerList
095: .getListeners(DirectoryTableEventListener.class);
096: Iterator listeners = listenerList.iterator();
097:
098: while (listeners.hasNext()) {
099: DirectoryTableEventListener listener;
100:
101: listener = (DirectoryTableEventListener) listeners
102: .next();
103: listener.fileSelected(event);
104: }
105: }
106: }
107: }
|