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 @ 2339
History | View | Annotate | Download (1.23 KB)
1 | 1251 | jjdelcerro | 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 | 1282 | jjdelcerro | @Override
|
15 | 1251 | jjdelcerro | public void addActionListener(ActionListener listener) { |
16 | listeners.add(listener); |
||
17 | } |
||
18 | |||
19 | 1282 | jjdelcerro | @Override
|
20 | 1251 | jjdelcerro | public ActionListener[] getActionListeners() { |
21 | return (ActionListener[]) this.listeners.toArray(new ActionListener[this.listeners.size()]); |
||
22 | } |
||
23 | |||
24 | 1282 | jjdelcerro | @Override
|
25 | 1645 | jjdelcerro | public boolean hasActionListeners() { |
26 | 1657 | jjdelcerro | return !this.listeners.isEmpty(); |
27 | 1645 | jjdelcerro | } |
28 | |||
29 | @Override
|
||
30 | 1251 | jjdelcerro | public void removeActionListener(ActionListener listener) { |
31 | listeners.remove(listener); |
||
32 | } |
||
33 | |||
34 | 1282 | jjdelcerro | @Override
|
35 | 1251 | jjdelcerro | public void removeAllActionListener() { |
36 | this.listeners.clear();
|
||
37 | } |
||
38 | |||
39 | 1282 | jjdelcerro | @Override
|
40 | 1251 | jjdelcerro | public void fireActionEvent(ActionEvent event) { |
41 | Iterator it = this.listeners.iterator(); |
||
42 | while (it.hasNext()) {
|
||
43 | ActionListener listener = (ActionListener) it.next(); |
||
44 | listener.actionPerformed(event); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | } |