PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/gui/ShortcutPrefixActiveEvent.java

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