Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / DefaultActionListenerSupport.java @ 1251

History | View | Annotate | Download (1.05 KB)

1
package org.gvsig.tools.swing.impl;
2

    
3
import java.awt.event.ActionEvent;
4
import java.awt.event.ActionListener;
5
import java.util.HashSet;
6
import java.util.Iterator;
7
import java.util.Set;
8
import org.gvsig.tools.swing.api.ActionListenerSupport;
9

    
10
public class DefaultActionListenerSupport implements ActionListenerSupport {
11

    
12
    protected Set listeners = new HashSet();
13

    
14
    public void addActionListener(ActionListener listener) {
15
        listeners.add(listener);
16
    }
17

    
18
    public ActionListener[] getActionListeners() {
19
        return (ActionListener[]) this.listeners.toArray(new ActionListener[this.listeners.size()]);
20
    }
21

    
22
    public void removeActionListener(ActionListener listener) {
23
        listeners.remove(listener);
24
    }
25

    
26
    public void removeAllActionListener() {
27
        this.listeners.clear();
28
    }
29

    
30
    public void fireActionEvent(ActionEvent event) {
31
        Iterator it = this.listeners.iterator();
32
        while (it.hasNext()) {
33
            ActionListener listener = (ActionListener) it.next();
34
            listener.actionPerformed(event);
35
        }
36
    }
37

    
38
}