1 19 20 package org.netbeans.api.debugger.jpda; 21 22 import com.sun.jdi.request.EventRequest; 23 24 import java.util.Collection ; 25 import java.util.HashSet ; 26 import java.util.Iterator ; 27 28 import org.netbeans.api.debugger.Breakpoint; 29 import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent; 30 import org.netbeans.api.debugger.jpda.event.JPDABreakpointListener; 31 32 37 public class JPDABreakpoint extends Breakpoint { 38 39 41 42 public static final String PROP_SUSPEND = "suspend"; 44 public static final String PROP_HIDDEN = "hidden"; 46 public static final String PROP_PRINT_TEXT = "printText"; 48 49 public static final int SUSPEND_ALL = EventRequest.SUSPEND_ALL; 50 51 public static final int SUSPEND_EVENT_THREAD = EventRequest.SUSPEND_EVENT_THREAD; 52 53 public static final int SUSPEND_NONE = EventRequest.SUSPEND_NONE; 54 55 56 58 59 private boolean enabled = true; 60 private boolean hidden = false; 61 private int suspend = SUSPEND_ALL; 62 private String printText; 63 private Collection <JPDABreakpointListener> breakpointListeners = new HashSet <JPDABreakpointListener>(); 64 65 66 JPDABreakpoint () { 67 } 68 69 70 72 77 public int getSuspend () { 78 return suspend; 79 } 80 81 86 public void setSuspend (int s) { 87 if (s == suspend) return; 88 int old = suspend; 89 suspend = s; 90 firePropertyChange (PROP_SUSPEND, new Integer (old), new Integer (s)); 91 } 92 93 98 public boolean isHidden () { 99 return hidden; 100 } 101 102 107 public void setHidden (boolean h) { 108 if (h == hidden) return; 109 boolean old = hidden; 110 hidden = h; 111 firePropertyChange (PROP_HIDDEN, Boolean.valueOf (old), Boolean.valueOf (h)); 112 } 113 114 119 public String getPrintText () { 120 return printText; 121 } 122 123 128 public void setPrintText (String printText) { 129 if (this.printText == printText) return; 130 String old = this.printText; 131 this.printText = printText; 132 firePropertyChange (PROP_PRINT_TEXT, old, printText); 133 } 134 135 140 public boolean isEnabled () { 141 return enabled; 142 } 143 144 147 public void disable () { 148 if (!enabled) return; 149 enabled = false; 150 firePropertyChange 151 (PROP_ENABLED, Boolean.TRUE, Boolean.FALSE); 152 } 153 154 157 public void enable () { 158 if (enabled) return; 159 enabled = true; 160 firePropertyChange 161 (PROP_ENABLED, Boolean.FALSE, Boolean.TRUE); 162 } 163 164 169 public synchronized void addJPDABreakpointListener ( 170 JPDABreakpointListener listener 171 ) { 172 breakpointListeners.add (listener); 173 } 174 175 180 public synchronized void removeJPDABreakpointListener ( 181 JPDABreakpointListener listener 182 ){ 183 breakpointListeners.remove (listener); 184 } 185 186 191 void fireJPDABreakpointChange (JPDABreakpointEvent event) { 192 Iterator <JPDABreakpointListener> i = 193 new HashSet <JPDABreakpointListener>(breakpointListeners).iterator(); 194 while (i.hasNext ()) 195 i.next().breakpointReached (event); 196 } 197 } 198 | Popular Tags |