1 19 20 package org.netbeans.modules.ant.debugger.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 public Breakpoint[] initBreakpoints () { 45 Properties p = Properties.getDefault ().getProperties ("debugger"). 46 getProperties (DebuggerManager.PROP_BREAKPOINTS); 47 Breakpoint[] breakpoints = (Breakpoint[]) p.getArray ( 48 "ant", 49 new Breakpoint [0] 50 ); 51 for (int i = 0; i < breakpoints.length; i++) { 52 breakpoints[i].addPropertyChangeListener(this); 53 } 54 return breakpoints; 55 } 56 57 public void initWatches () { 58 } 59 60 public String [] getProperties () { 61 return new String [] { 62 DebuggerManager.PROP_BREAKPOINTS_INIT, 63 DebuggerManager.PROP_BREAKPOINTS, 64 }; 65 } 66 67 public void breakpointAdded (Breakpoint breakpoint) { 68 if (breakpoint instanceof AntBreakpoint) { 69 Properties p = Properties.getDefault ().getProperties ("debugger"). 70 getProperties (DebuggerManager.PROP_BREAKPOINTS); 71 p.setArray ( 72 "ant", 73 getBreakpoints () 74 ); 75 breakpoint.addPropertyChangeListener(this); 76 } 77 } 78 79 public void breakpointRemoved (Breakpoint breakpoint) { 80 if (breakpoint instanceof AntBreakpoint) { 81 Properties p = Properties.getDefault ().getProperties ("debugger"). 82 getProperties (DebuggerManager.PROP_BREAKPOINTS); 83 p.setArray ( 84 "ant", 85 getBreakpoints () 86 ); 87 breakpoint.removePropertyChangeListener(this); 88 } 89 } 90 public void watchAdded (Watch watch) { 91 } 92 93 public void watchRemoved (Watch watch) { 94 } 95 96 public void propertyChange (PropertyChangeEvent evt) { 97 if (evt.getSource() instanceof Breakpoint) { 98 Properties.getDefault ().getProperties ("debugger"). 99 getProperties (DebuggerManager.PROP_BREAKPOINTS).setArray ( 100 "ant", 101 getBreakpoints () 102 ); 103 } 104 } 105 106 public void sessionAdded (Session session) {} 107 public void sessionRemoved (Session session) {} 108 public void engineAdded (DebuggerEngine engine) {} 109 public void engineRemoved (DebuggerEngine engine) {} 110 111 112 private static Breakpoint[] getBreakpoints () { 113 Breakpoint[] bs = DebuggerManager.getDebuggerManager (). 114 getBreakpoints (); 115 int i, k = bs.length; 116 ArrayList bb = new ArrayList (); 117 for (i = 0; i < k; i++) 118 if (bs[i] instanceof AntBreakpoint) 120 bb.add (bs [i]); 121 bs = new Breakpoint [bb.size ()]; 122 return (Breakpoint[]) bb.toArray (bs); 123 } 124 } 125 126 | Popular Tags |