1 19 20 package org.netbeans.modules.web.debug.breakpoints; 21 22 import java.beans.PropertyChangeEvent ; 23 import java.util.ArrayList ; 24 import org.netbeans.api.debugger.Breakpoint; 25 import org.netbeans.api.debugger.DebuggerEngine; 26 27 import org.netbeans.api.debugger.DebuggerManager; 28 import org.netbeans.api.debugger.DebuggerManagerListener; 29 import org.netbeans.api.debugger.LazyDebuggerManagerListener; 30 import org.netbeans.api.debugger.Properties; 31 import org.netbeans.api.debugger.Session; 32 import org.netbeans.api.debugger.Watch; 33 34 42 public class PersistenceManager implements LazyDebuggerManagerListener { 43 44 private static final String JSP_PROPERTY = "jsp"; 45 46 public Breakpoint[] initBreakpoints () { 47 Properties p = Properties.getDefault ().getProperties ("debugger"). 48 getProperties (DebuggerManager.PROP_BREAKPOINTS); 49 Breakpoint[] breakpoints = (Breakpoint[]) p.getArray ( 50 JSP_PROPERTY, 51 new Breakpoint [0] 52 ); 53 for (int i = 0; i < breakpoints.length; i++) { 54 breakpoints[i].addPropertyChangeListener(this); 55 } 56 return breakpoints; 57 } 58 59 public void initWatches () { 60 } 61 62 public String [] getProperties () { 63 return new String [] { 64 DebuggerManager.PROP_BREAKPOINTS_INIT, 65 DebuggerManager.PROP_BREAKPOINTS, 66 }; 67 } 68 69 public void breakpointAdded (Breakpoint breakpoint) { 70 if (breakpoint instanceof JspLineBreakpoint) { 71 Properties p = Properties.getDefault ().getProperties ("debugger"). 72 getProperties (DebuggerManager.PROP_BREAKPOINTS); 73 p.setArray ( 74 JSP_PROPERTY, 75 getBreakpoints () 76 ); 77 breakpoint.addPropertyChangeListener(this); 78 } 79 } 80 81 public void breakpointRemoved (Breakpoint breakpoint) { 82 if (breakpoint instanceof JspLineBreakpoint) { 83 Properties p = Properties.getDefault ().getProperties ("debugger"). 84 getProperties (DebuggerManager.PROP_BREAKPOINTS); 85 p.setArray ( 86 JSP_PROPERTY, 87 getBreakpoints () 88 ); 89 breakpoint.removePropertyChangeListener(this); 90 } 91 } 92 public void watchAdded (Watch watch) { 93 } 94 95 public void watchRemoved (Watch watch) { 96 } 97 98 public void propertyChange (PropertyChangeEvent evt) { 99 if (evt.getSource() instanceof Breakpoint) { 100 Properties.getDefault ().getProperties ("debugger"). 101 getProperties (DebuggerManager.PROP_BREAKPOINTS).setArray ( 102 JSP_PROPERTY, 103 getBreakpoints () 104 ); 105 } 106 } 107 108 public void sessionAdded (Session session) {} 109 public void sessionRemoved (Session session) {} 110 public void engineAdded (DebuggerEngine engine) {} 111 public void engineRemoved (DebuggerEngine engine) {} 112 113 114 private static Breakpoint[] getBreakpoints () { 115 Breakpoint[] bs = DebuggerManager.getDebuggerManager (). 116 getBreakpoints (); 117 int i, k = bs.length; 118 ArrayList bb = new ArrayList (); 119 for (i = 0; i < k; i++) 120 if (bs[i] instanceof JspLineBreakpoint) 122 bb.add (bs [i]); 123 bs = new Breakpoint [bb.size ()]; 124 return (Breakpoint[]) bb.toArray (bs); 125 } 126 } 127 128 | Popular Tags |