1 19 package org.netbeans.modules.web.debug.actions; 20 21 import java.beans.*; 22 import java.util.*; 23 24 import org.netbeans.api.debugger.*; 25 import org.netbeans.api.debugger.jpda.*; 26 import org.netbeans.spi.debugger.*; 27 import org.netbeans.modules.web.debug.Context; 28 import org.netbeans.modules.web.debug.util.*; 29 import org.netbeans.modules.web.debug.breakpoints.*; 30 31 32 36 public class JspGoToCursorActionProvider extends ActionsProviderSupport implements PropertyChangeListener { 37 38 private JPDADebugger debugger; 39 private Session session; 40 private JspLineBreakpoint breakpoint; 41 42 43 public JspGoToCursorActionProvider(ContextProvider contextProvider) { 44 debugger = (JPDADebugger) contextProvider.lookupFirst(null, JPDADebugger.class); 45 session = (Session) contextProvider.lookupFirst(null, Session.class); 46 debugger.addPropertyChangeListener(debugger.PROP_STATE, this); 47 Context.addPropertyChangeListener(this); 48 } 49 50 private void destroy () { 51 debugger.removePropertyChangeListener (debugger.PROP_STATE, this); 52 Context.removePropertyChangeListener (this); 53 } 54 55 public void propertyChange (PropertyChangeEvent evt) { 56 setEnabled ( 57 ActionsManager.ACTION_RUN_TO_CURSOR, 58 (debugger.getState () == debugger.STATE_STOPPED) && 59 (Utils.isJsp(Context.getCurrentURL()) || Utils.isTag(Context.getCurrentURL())) 60 ); 61 if ((debugger.getState () != debugger.STATE_RUNNING) && (breakpoint != null)) { 62 DebuggerManager.getDebuggerManager ().removeBreakpoint (breakpoint); 63 breakpoint = null; 64 } 65 if (debugger.getState () == debugger.STATE_DISCONNECTED) { 66 destroy (); 67 } 68 } 69 70 public Set getActions () { 71 return Collections.singleton (ActionsManager.ACTION_RUN_TO_CURSOR); 72 } 73 74 public void doAction (Object action) { 75 if (breakpoint != null) { 76 DebuggerManager.getDebuggerManager ().removeBreakpoint (breakpoint); 77 breakpoint = null; 78 } 79 breakpoint = JspLineBreakpoint.create ( 80 Context.getCurrentURL(), 81 Context.getCurrentLineNumber() 82 ); 83 breakpoint.setHidden(true); 84 DebuggerManager.getDebuggerManager().addBreakpoint (breakpoint); 85 session.getEngineForLanguage ("JSP").getActionsManager ().doAction ( 86 ActionsManager.ACTION_CONTINUE 87 ); 88 } 89 } 90 | Popular Tags |