1 23 package org.gjt.sp.jedit.gui; 24 25 import java.util.Hashtable ; 27 28 import javax.swing.event.ChangeEvent ; 29 import javax.swing.event.ChangeListener ; 30 import javax.swing.event.EventListenerList ; 31 32 import org.gjt.sp.util.Log; 33 35 41 public class ShortcutPrefixActiveEvent extends ChangeEvent 42 { 43 44 47 protected Hashtable bindings; 48 51 protected boolean active; 53 56 protected static EventListenerList listenerList = new EventListenerList (); 57 58 65 public ShortcutPrefixActiveEvent( Hashtable bindings, boolean active ) 66 { 67 super( new Object () ); 68 this.bindings = bindings; 69 this.active = active; 70 } 72 79 public static void addChangeEventListener( ChangeListener l ) 80 { 81 listenerList.add( ChangeListener .class, l ); 82 Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener added. " + listenerList.getListenerList().length + " left." ); 83 } 85 91 public static void removeChangeEventListener( ChangeListener l ) 92 { 93 listenerList.remove( ChangeListener .class, l ); 94 Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener removed. " + listenerList.getListenerList().length + " left." ); 95 } 97 104 protected static void firePrefixStateChange( Hashtable bindings, boolean listeningForShortcutCompletion ) 105 { 106 Object [] listeners = listenerList.getListenerList(); 109 for ( int i = listeners.length - 2; i >= 0; i -= 2 ) 113 { 114 ChangeEvent event = new ShortcutPrefixActiveEvent( bindings, listeningForShortcutCompletion ); 116 ( ( ChangeListener ) listeners[i + 1] ).stateChanged( event ); 117 } 118 } 120 121 127 public Hashtable getBindings() 128 { 129 return bindings; 130 } 132 138 public boolean getActive() 139 { 140 return active; 141 } 142 } 144 145 | Popular Tags |