01: package com.vividsolutions.jump.workbench.ui;
02:
03: import java.awt.event.ActionEvent;
04: import java.awt.event.ActionListener;
05:
06: import java.util.ArrayList;
07: import java.util.Iterator;
08:
09: /**
10: * Keeps registry of action listeners, triggers each of them on demand
11: * with a given ActionEvent.
12: */
13:
14: public class ActionEventFirer {
15: private ArrayList actionListeners = new ArrayList();
16:
17: public void add(ActionListener listener) {
18: actionListeners.add(listener);
19: }
20:
21: public void remove(ActionListener listener) {
22: actionListeners.remove(listener);
23: }
24:
25: public void fire(Object source, int id, String command) {
26: for (Iterator i = actionListeners.iterator(); i.hasNext();) {
27: ActionListener listener = (ActionListener) i.next();
28: listener.actionPerformed(new ActionEvent(source, id,
29: command));
30: }
31: }
32: }
|