1 19 20 package org.netbeans.modules.web.debug.breakpoints; 21 22 import org.netbeans.api.debugger.*; 23 import org.netbeans.api.debugger.jpda.*; 24 25 import org.netbeans.modules.web.debug.util.Utils; 26 import java.util.*; 27 import org.openide.util.NbBundle; 28 29 30 34 public class JspLineBreakpoint extends Breakpoint { 35 36 37 public static final String PROP_ENABLED = JPDABreakpoint.PROP_ENABLED; 38 39 public static final String PROP_SUSPEND = JPDABreakpoint.PROP_SUSPEND; 40 public static final String PROP_HIDDEN = JPDABreakpoint.PROP_HIDDEN; 41 public static final String PROP_PRINT_TEXT = JPDABreakpoint.PROP_PRINT_TEXT; 42 43 public static final int SUSPEND_ALL = JPDABreakpoint.SUSPEND_ALL; 44 public static final int SUSPEND_EVENT_THREAD = JPDABreakpoint.SUSPEND_EVENT_THREAD; 45 public static final int SUSPEND_NONE = JPDABreakpoint.SUSPEND_NONE; 46 47 public static final String PROP_LINE_NUMBER = LineBreakpoint.PROP_LINE_NUMBER; 48 public static final String PROP_URL = LineBreakpoint.PROP_URL; 49 public static final String PROP_CONDITION = LineBreakpoint.PROP_CONDITION; 50 51 private boolean enabled = true; 52 private boolean hidden = false; 53 private int suspend = SUSPEND_ALL; 54 private String printText; 55 56 private String url = ""; private int lineNumber; 58 private String condition = ""; 60 private LineBreakpoint javalb; 61 62 63 public JspLineBreakpoint() { } 64 65 66 public JspLineBreakpoint(String url, int lineNumber) { 67 super(); 68 69 this.url = url; 70 this.lineNumber = lineNumber; 71 String pt = NbBundle.getMessage(JspLineBreakpoint.class, "CTL_Default_Print_Text"); 72 this.printText = org.openide.util.Utilities.replaceString(pt, "{jspName}", Utils.getJspName(url)); 73 74 DebuggerManager d = DebuggerManager.getDebuggerManager(); 75 76 Utils.getEM().log("jsp url: " + url); 77 78 String filter = Utils.getClassFilter(url); 79 Utils.getEM().log("filter: " + filter); 80 81 javalb = LineBreakpoint.create(url, lineNumber); 82 javalb.setStratum("JSP"); javalb.setSourceName(Utils.getJspName(url)); 84 javalb.setSourcePath(Utils.getJspPath(url)); 85 javalb.setPreferredClassName(filter); 86 javalb.setHidden(true); 87 javalb.setPrintText(printText); 88 89 String context = Utils.getContextPath(url); 90 String condition = "request.getContextPath().equals(\"" + context + "\")"; javalb.setCondition(condition); 92 Utils.getEM().log("condition: " + condition); 93 94 d.addBreakpoint(javalb); 95 96 this.setURL(url); 97 this.setLineNumber(lineNumber); 98 } 99 100 107 public static JspLineBreakpoint create(String url, int lineNumber) { 108 return new JspLineBreakpoint(url, lineNumber); 109 } 110 111 116 public int getSuspend () { 117 return suspend; 118 } 119 120 125 public void setSuspend (int s) { 126 if (s == suspend) return; 127 int old = suspend; 128 suspend = s; 129 if (javalb != null) { 130 javalb.setSuspend(s); 131 } 132 firePropertyChange(PROP_SUSPEND, new Integer (old), new Integer (s)); 133 } 134 135 140 public boolean isHidden () { 141 return hidden; 142 } 143 144 149 public void setHidden (boolean h) { 150 if (h == hidden) return; 151 boolean old = hidden; 152 hidden = h; 153 firePropertyChange(PROP_HIDDEN, Boolean.valueOf(old), Boolean.valueOf(h)); 154 } 155 156 161 public String getPrintText () { 162 return printText; 163 } 164 165 170 public void setPrintText (String printText) { 171 if (this.printText == printText) return; 172 String old = this.printText; 173 this.printText = printText; 174 if (javalb != null) { 175 javalb.setPrintText(printText); 176 } 177 firePropertyChange(PROP_PRINT_TEXT, old, printText); 178 } 179 180 183 protected void dispose() { 184 if (javalb != null) { 185 DebuggerManager.getDebuggerManager().removeBreakpoint(javalb); 186 } 187 } 188 189 194 public boolean isEnabled() { 195 return enabled; 196 } 197 198 201 public void disable() { 202 if (!enabled) return; 203 enabled = false; 204 if (javalb != null) { 205 javalb.disable(); 206 } 207 firePropertyChange(PROP_ENABLED, Boolean.TRUE, Boolean.FALSE); 208 } 209 210 213 public void enable() { 214 if (enabled) return; 215 enabled = true; 216 if (javalb != null) { 217 javalb.enable(); 218 } 219 firePropertyChange(PROP_ENABLED, Boolean.FALSE, Boolean.TRUE); 220 } 221 222 227 public void setURL (String url) { 228 if ( (url == this.url) || 229 ((url != null) && (this.url != null) && url.equals (this.url)) 230 ) return; 231 String old = url; 232 this.url = url; 233 firePropertyChange(PROP_URL, old, url); 234 } 235 236 241 public String getURL () { 242 return url; 243 } 244 245 250 public int getLineNumber () { 251 return lineNumber; 252 } 253 254 259 public void setLineNumber (int ln) { 260 if (ln == lineNumber) return; 261 int old = lineNumber; 262 lineNumber = ln; 263 if (javalb != null) { 264 javalb.setLineNumber(ln); 265 } 266 firePropertyChange(PROP_LINE_NUMBER, new Integer (old), new Integer (getLineNumber())); 267 } 268 269 274 public void setCondition (String c) { 275 if (c != null) c = c.trim (); 276 if ( (c == condition) || 277 ((c != null) && (condition != null) && condition.equals (c)) 278 ) return; 279 String old = condition; 280 condition = c; 281 if (javalb != null) { 282 javalb.setCondition(c); 283 } 284 firePropertyChange(PROP_CONDITION, old, condition); 285 } 286 287 292 public String getCondition () { 293 return condition; 294 } 295 296 301 public String toString () { 302 return "JspLineBreakpoint " + url + " : " + lineNumber; 303 } 304 305 309 public LineBreakpoint getJavalb() { 310 return javalb; 311 } 312 313 317 public void setJavalb(LineBreakpoint javalb) { 318 this.javalb = javalb; 319 } 320 321 326 public void setGroupName(String newGroupName) { 327 super.setGroupName(newGroupName); 328 javalb.setGroupName(newGroupName); 329 } 330 } 331 | Popular Tags |