KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > gui > ShortcutPrefixActiveEvent


1 /*
2  * ShortcutPrefixActiveEvent.java - Event fired when jEdit starts and stops
3  * listening for shortcut completions
4  * :tabSize=8:indentSize=8:noTabs=false:
5  * :folding=explicit:collapseFolds=1:
6  *
7  * Copyright (C) 2005 Jeffrey Hoyt
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */

23 package org.gjt.sp.jedit.gui;
24
25 //{{{ Imports
26
import java.util.Hashtable JavaDoc;
27
28 import javax.swing.event.ChangeEvent JavaDoc;
29 import javax.swing.event.ChangeListener JavaDoc;
30 import javax.swing.event.EventListenerList JavaDoc;
31
32 import org.gjt.sp.util.Log;
33 //}}}
34

35 /**
36  * Description of the Class
37  *
38  *@author jchoyt
39  *@created December 17, 2005
40  */

41 public class ShortcutPrefixActiveEvent extends ChangeEvent JavaDoc
42 {
43
44     /**
45      * Description of the Field
46      */

47     protected Hashtable JavaDoc bindings;
48     /**
49      * Description of the Field
50      */

51     protected boolean active;//}}}
52

53         /**
54      * Description of the Field
55      */

56     protected static EventListenerList JavaDoc listenerList = new EventListenerList JavaDoc();
57
58     //{{{ Constructor
59
/**
60      * Constructor for the ShortcutPrefixActiveEvent object
61      *
62      *@param bindings Description of the Parameter
63      *@param active Description of the Parameter
64      */

65     public ShortcutPrefixActiveEvent( Hashtable JavaDoc bindings, boolean active )
66     {
67         super( new Object JavaDoc() );
68         this.bindings = bindings;
69         this.active = active;
70     } //}}}
71

72     //{{{ addChangeEventListener() method
73
/**
74      * Adds a feature to the ChangeEventListener attribute of the
75      * ShortcutPrefixActiveEvent class
76      *
77      *@param l The feature to be added to the ChangeEventListener attribute
78      */

79     public static void addChangeEventListener( ChangeListener JavaDoc l )
80     {
81         listenerList.add( ChangeListener JavaDoc.class, l );
82         Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener added. " + listenerList.getListenerList().length + " left." );
83     }//}}}
84

85     //{{{ removeChangeEventListener() method
86
/**
87      * Description of the Method
88      *
89      *@param l Description of the Parameter
90      */

91     public static void removeChangeEventListener( ChangeListener JavaDoc l )
92     {
93         listenerList.remove( ChangeListener JavaDoc.class, l );
94         Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener removed. " + listenerList.getListenerList().length + " left." );
95     }//}}}
96

97     //{{{ firePrefixStateChange() method
98
/**
99      * Description of the Method
100      *
101      *@param bindings Description of the Parameter
102      *@param listeningForShortcutCompletion Description of the Parameter
103      */

104     protected static void firePrefixStateChange( Hashtable JavaDoc bindings, boolean listeningForShortcutCompletion )
105     {
106         //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "firePrefixStateChange() called, listening? " + listeningForShortcutCompletion );
107
// Guaranteed to return a non-null array
108
Object JavaDoc[] listeners = listenerList.getListenerList();
109         //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, listeners.length + " listeners." );
110
// Process the listeners last to first, notifying
111
// those that are interested in this event
112
for ( int i = listeners.length - 2; i >= 0; i -= 2 )
113         {
114             //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "firePrefixStateChange() called, listening? " + listeningForShortcutCompletion );
115
ChangeEvent JavaDoc event = new ShortcutPrefixActiveEvent( bindings, listeningForShortcutCompletion );
116             ( ( ChangeListener JavaDoc ) listeners[i + 1] ).stateChanged( event );
117         }
118     }//}}}
119

120
121     //{{{ getBindings()
122
/**
123      * Gets the bindings attribute of the ShortcutPrefixActiveEvent object
124      *
125      *@return The bindings value
126      */

127     public Hashtable JavaDoc getBindings()
128     {
129         return bindings;
130     }//}}}
131

132     //{{{ getActive()
133
/**
134      * Gets the active attribute of the ShortcutPrefixActiveEvent object
135      *
136      *@return The active value
137      */

138     public boolean getActive()
139     {
140         return active;
141     }
142     //}}}
143
}
144
145
Popular Tags