PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/gui/ShortcutPrefixActiveEvent.java

#
Java | 147 lines | 50 code | 12 blank | 85 comment | 1 complexity | 7c5235f64f5ec44c01b583bd5108418c MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. //{{{ Imports
  25. import javax.swing.KeyStroke;
  26. import java.awt.event.KeyEvent;
  27. import java.awt.event.InputEvent;
  28. import java.awt.Toolkit;
  29. import java.util.Hashtable;
  30. import java.util.StringTokenizer;
  31. import org.gjt.sp.jedit.*;
  32. import org.gjt.sp.util.Log;
  33. import org.gjt.sp.jedit.msg.*;
  34. import javax.swing.event.*;
  35. //}}}
  36. /**
  37. * Description of the Class
  38. *
  39. *@author jchoyt
  40. *@created December 17, 2005
  41. */
  42. public class ShortcutPrefixActiveEvent extends ChangeEvent
  43. {
  44. /**
  45. * Description of the Field
  46. */
  47. protected Hashtable bindings;
  48. /**
  49. * Description of the Field
  50. */
  51. protected boolean active;//}}}
  52. /**
  53. * Description of the Field
  54. */
  55. protected static EventListenerList listenerList = new EventListenerList();
  56. //{{{ Constructor
  57. /**
  58. * Constructor for the ShortcutPrefixActiveEvent object
  59. *
  60. *@param bindings Description of the Parameter
  61. *@param active Description of the Parameter
  62. */
  63. public ShortcutPrefixActiveEvent( Hashtable bindings, boolean active )
  64. {
  65. super( new Object() );
  66. this.bindings = bindings;
  67. this.active = active;
  68. } //}}}
  69. //{{{ addChangeEventListener() method
  70. /**
  71. * Adds a feature to the ChangeEventListener attribute of the
  72. * ShortcutPrefixActiveEvent class
  73. *
  74. *@param l The feature to be added to the ChangeEventListener attribute
  75. */
  76. public static void addChangeEventListener( ChangeListener l )
  77. {
  78. listenerList.add( ChangeListener.class, l );
  79. Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener added. " + listenerList.getListenerList().length + " left." );
  80. }//}}}
  81. //{{{ removeChangeEventListener() method
  82. /**
  83. * Description of the Method
  84. *
  85. *@param l Description of the Parameter
  86. */
  87. public static void removeChangeEventListener( ChangeListener l )
  88. {
  89. listenerList.remove( ChangeListener.class, l );
  90. Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "Listener removed. " + listenerList.getListenerList().length + " left." );
  91. }//}}}
  92. //{{{ firePrefixStateChange() method
  93. /**
  94. * Description of the Method
  95. *
  96. *@param bindings Description of the Parameter
  97. *@param listeningForShortcutCompletion Description of the Parameter
  98. */
  99. protected static void firePrefixStateChange( Hashtable bindings, boolean listeningForShortcutCompletion )
  100. {
  101. //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "firePrefixStateChange() called, listening? " + listeningForShortcutCompletion );
  102. // Guaranteed to return a non-null array
  103. Object[] listeners = listenerList.getListenerList();
  104. //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, listeners.length + " listeners." );
  105. // Process the listeners last to first, notifying
  106. // those that are interested in this event
  107. for ( int i = listeners.length - 2; i >= 0; i -= 2 )
  108. {
  109. //Log.log( Log.DEBUG, ShortcutPrefixActiveEvent.class, "firePrefixStateChange() called, listening? " + listeningForShortcutCompletion );
  110. ChangeEvent event = new ShortcutPrefixActiveEvent( bindings, listeningForShortcutCompletion );
  111. ( ( ChangeListener ) listeners[i + 1] ).stateChanged( event );
  112. }
  113. }//}}}
  114. //{{{ getBindings()
  115. /**
  116. * Gets the bindings attribute of the ShortcutPrefixActiveEvent object
  117. *
  118. *@return The bindings value
  119. */
  120. public Hashtable getBindings()
  121. {
  122. return bindings;
  123. }//}}}
  124. //{{{ getActive()
  125. /**
  126. * Gets the active attribute of the ShortcutPrefixActiveEvent object
  127. *
  128. *@return The active value
  129. */
  130. public boolean getActive()
  131. {
  132. return active;
  133. }
  134. //}}}
  135. }