1 19 20 package org.netbeans.modules.debugger.jpda.ui.actions; 21 22 import java.util.Collections ; 23 import java.util.Set ; 24 import org.netbeans.api.debugger.ActionsManager; 25 26 27 import org.netbeans.api.debugger.DebuggerManager; 28 import org.netbeans.spi.debugger.ContextProvider; 29 import org.netbeans.api.debugger.jpda.JPDADebugger; 30 import org.netbeans.api.debugger.jpda.JPDAThread; 31 32 33 38 public class MakeCalleeCurrentActionProvider extends JPDADebuggerAction { 39 40 private ContextProvider lookupProvider; 41 42 43 public MakeCalleeCurrentActionProvider (ContextProvider lookupProvider) { 44 super ( 45 (JPDADebugger) lookupProvider.lookupFirst 46 (null, JPDADebugger.class) 47 ); 48 this.lookupProvider = lookupProvider; 49 getDebuggerImpl ().addPropertyChangeListener 50 (JPDADebugger.PROP_CURRENT_CALL_STACK_FRAME, this); 51 } 52 53 public Set getActions () { 54 return Collections.singleton (ActionsManager.ACTION_MAKE_CALLEE_CURRENT); 55 } 56 57 public void doAction (Object action) { 58 JPDAThread t = getDebuggerImpl ().getCurrentThread (); 59 if (t == null) return; 60 int i = MakeCallerCurrentActionProvider.getCurrentCallStackFrameIndex 61 (getDebuggerImpl ()); 62 if (i == 0) return; 63 MakeCallerCurrentActionProvider.setCurrentCallStackFrameIndex 64 (getDebuggerImpl (), --i, lookupProvider); 65 } 66 67 protected void checkEnabled (int debuggerState) { 68 if (debuggerState == getDebuggerImpl ().STATE_STOPPED) { 69 JPDAThread t = getDebuggerImpl ().getCurrentThread (); 70 if (t != null) { 71 int i = MakeCallerCurrentActionProvider.getCurrentCallStackFrameIndex 72 (getDebuggerImpl ()); 73 setEnabled ( 74 ActionsManager.ACTION_MAKE_CALLEE_CURRENT, 75 i > 0 76 ); 77 return; 78 } 79 } 80 setEnabled ( 81 ActionsManager.ACTION_MAKE_CALLEE_CURRENT, 82 false 83 ); 84 } 85 } 86 | Popular Tags |