1 19 20 package org.netbeans.spi.debugger; 21 22 import java.util.HashSet ; 23 import java.util.Vector ; 24 25 26 33 public abstract class ActionsProviderSupport extends ActionsProvider { 34 35 private HashSet enabled = new HashSet (); 36 private Vector listeners = new Vector (); 37 38 39 44 public abstract void doAction (Object action); 45 46 56 public boolean isEnabled (Object action) { 57 return enabled.contains (action); 58 } 59 60 66 protected final void setEnabled (Object action, boolean enabled) { 67 boolean fire = false; 68 if (enabled) 69 fire = this.enabled.add (action); 70 else 71 fire = this.enabled.remove (action); 72 if (fire) 73 fireActionStateChanged (action, enabled); 74 } 75 76 82 protected void fireActionStateChanged (Object action, boolean enabled) { 83 Vector v = (Vector ) listeners.clone (); 84 int i, k = v.size (); 85 for (i = 0; i < k; i++) 86 ((ActionsProviderListener) v.elementAt (i)).actionStateChange ( 87 action, enabled 88 ); 89 } 90 91 96 public final void addActionsProviderListener (ActionsProviderListener l) { 97 listeners.addElement (l); 98 } 99 100 105 public final void removeActionsProviderListener (ActionsProviderListener l) { 106 listeners.removeElement (l); 107 } 108 } 109 110 | Popular Tags |