| 1 | /* |
| 2 | * $Id: FireEvent.java,v 1.1.1.5 2004/05/25 20:23:30 hastings Exp $ |
| 3 | * |
| 4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This material may be reproduced by or for the U. S. Government |
| 9 | * pursuant to the copyright license under the clause at |
| 10 | * DFARS 252.227-7014 (OCT 2001). |
| 11 | */ |
| 12 | |
| 13 | package com.moesol.util; |
| 14 | |
| 15 | import java.util.logging.Logger; |
| 16 | |
| 17 | /** |
| 18 | * @author hastings |
| 19 | * |
| 20 | * To change the template for this generated type comment go to |
| 21 | * Window>Preferences>Java>Code Generation>Code and Comments |
| 22 | */ |
| 23 | public class FireEvent { |
| 24 | public static void fireEvent( |
| 25 | javax.swing.event.EventListenerList listener_list, |
| 26 | EventFirer fire, |
| 27 | Object event, Logger logger) |
| 28 | { |
| 29 | Object[] listeners = listener_list.getListenerList(); |
| 30 | for (int i = listeners.length - 2; i >= 0; i -= 2) { |
| 31 | if (listeners[i] != fire.getListenerType()) { |
| 32 | continue; |
| 33 | } |
| 34 | try { |
| 35 | // any one failure will not cause remaining to be skipped |
| 36 | fire.fireEvent(listeners[i + 1], event); |
| 37 | } catch (Throwable t) { |
| 38 | logger.log(java.util.logging.Level.INFO, "listener caused exception", t); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | } |